using content::BrowserThread
This commit is contained in:
parent
f05199d4e4
commit
d01aa51686
2 changed files with 15 additions and 17 deletions
|
@ -25,6 +25,8 @@
|
|||
#include "base/nix/xdg_util.h"
|
||||
#endif
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace brightray {
|
||||
|
||||
class BrowserContext::ResourceContext : public content::ResourceContext {
|
||||
|
@ -79,7 +81,7 @@ void BrowserContext::Initialize() {
|
|||
base::PrefServiceFactory prefs_factory;
|
||||
prefs_factory.SetUserPrefsFile(prefs_path,
|
||||
JsonPrefStore::GetTaskRunnerForFile(
|
||||
prefs_path, content::BrowserThread::GetBlockingPool()));
|
||||
prefs_path, BrowserThread::GetBlockingPool()));
|
||||
|
||||
auto registry = make_scoped_refptr(new PrefRegistrySimple);
|
||||
RegisterInternalPrefs(registry);
|
||||
|
@ -89,9 +91,9 @@ void BrowserContext::Initialize() {
|
|||
}
|
||||
|
||||
BrowserContext::~BrowserContext() {
|
||||
content::BrowserThread::DeleteSoon(content::BrowserThread::IO,
|
||||
FROM_HERE,
|
||||
resource_context_.release());
|
||||
BrowserThread::DeleteSoon(BrowserThread::IO,
|
||||
FROM_HERE,
|
||||
resource_context_.release());
|
||||
}
|
||||
|
||||
void BrowserContext::RegisterInternalPrefs(PrefRegistrySimple* registry) {
|
||||
|
@ -102,14 +104,10 @@ net::URLRequestContextGetter* BrowserContext::CreateRequestContext(
|
|||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::ProtocolHandlerScopedVector protocol_interceptors) {
|
||||
DCHECK(!url_request_getter_);
|
||||
auto io_loop = content::BrowserThread::UnsafeGetMessageLoopForThread(
|
||||
content::BrowserThread::IO);
|
||||
auto file_loop = content::BrowserThread::UnsafeGetMessageLoopForThread(
|
||||
content::BrowserThread::FILE);
|
||||
url_request_getter_ = new URLRequestContextGetter(
|
||||
GetPath(),
|
||||
io_loop,
|
||||
file_loop,
|
||||
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),
|
||||
BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE),
|
||||
base::Bind(&BrowserContext::CreateNetworkDelegate, base::Unretained(this)),
|
||||
protocol_handlers,
|
||||
protocol_interceptors.Pass());
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include "net/url_request/url_request_job_factory_impl.h"
|
||||
#include "webkit/browser/quota/special_storage_policy.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace brightray {
|
||||
|
||||
URLRequestContextGetter::URLRequestContextGetter(
|
||||
|
@ -51,7 +53,7 @@ URLRequestContextGetter::URLRequestContextGetter(
|
|||
network_delegate_factory_(network_delegate_factory),
|
||||
protocol_interceptors_(protocol_interceptors.Pass()) {
|
||||
// Must first be created on the UI thread.
|
||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
|
||||
std::swap(protocol_handlers_, *protocol_handlers);
|
||||
|
||||
|
@ -67,7 +69,7 @@ net::HostResolver* URLRequestContextGetter::host_resolver() {
|
|||
}
|
||||
|
||||
net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
|
||||
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
|
||||
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
||||
|
||||
if (!url_request_context_.get()) {
|
||||
url_request_context_.reset(new net::URLRequestContext());
|
||||
|
@ -117,8 +119,7 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
|
|||
net::CACHE_BACKEND_DEFAULT,
|
||||
cache_path,
|
||||
0,
|
||||
content::BrowserThread::GetMessageLoopProxyForThread(
|
||||
content::BrowserThread::CACHE));
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
|
||||
|
||||
net::HttpNetworkSession::Params network_session_params;
|
||||
network_session_params.cert_verifier =
|
||||
|
@ -163,7 +164,7 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
|
|||
job_factory->SetProtocolHandler(
|
||||
content::kFileScheme,
|
||||
new net::FileProtocolHandler(
|
||||
content::BrowserThread::GetBlockingPool()->
|
||||
BrowserThread::GetBlockingPool()->
|
||||
GetTaskRunnerWithShutdownBehavior(
|
||||
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
|
||||
|
||||
|
@ -187,8 +188,7 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
|
|||
|
||||
scoped_refptr<base::SingleThreadTaskRunner>
|
||||
URLRequestContextGetter::GetNetworkTaskRunner() const {
|
||||
return content::BrowserThread::GetMessageLoopProxyForThread(
|
||||
content::BrowserThread::IO);
|
||||
return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
|
||||
}
|
||||
|
||||
} // namespace brightray
|
||||
|
|
Loading…
Reference in a new issue