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