Initialize job factory as early as possible.

Fixes atom/atom#3255.
This commit is contained in:
Cheng Zhao 2014-08-15 11:35:13 +08:00
parent e8d1c69ea8
commit 1b70ca2098
2 changed files with 2 additions and 7 deletions

View file

@ -4,7 +4,6 @@
#include "atom/browser/api/atom_api_protocol.h"
#include "base/stl_util.h"
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/net/adapter_request_job.h"
#include "atom/browser/net/atom_url_request_job_factory.h"
@ -153,6 +152,7 @@ class CustomProtocolHandler : public ProtocolHandler {
Protocol::Protocol()
: job_factory_(AtomBrowserContext::Get()->job_factory()) {
CHECK(job_factory_);
}
Protocol::JsProtocolHandler Protocol::GetProtocolHandler(
@ -323,10 +323,6 @@ namespace {
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
v8::Handle<v8::Context> context, void* priv) {
// Make sure the job factory has been created.
atom::AtomBrowserContext::Get()->url_request_context_getter()->
GetURLRequestContext();
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("protocol", atom::api::Protocol::Create(isolate));

View file

@ -19,7 +19,7 @@ using content::BrowserThread;
namespace atom {
AtomBrowserContext::AtomBrowserContext()
: job_factory_(NULL) {
: job_factory_(new AtomURLRequestJobFactory) {
}
AtomBrowserContext::~AtomBrowserContext() {
@ -29,7 +29,6 @@ scoped_ptr<net::URLRequestJobFactory>
AtomBrowserContext::CreateURLRequestJobFactory(
content::ProtocolHandlerMap* handlers,
content::ProtocolHandlerScopedVector* interceptors) {
job_factory_ = new AtomURLRequestJobFactory;
scoped_ptr<AtomURLRequestJobFactory> job_factory(job_factory_);
for (content::ProtocolHandlerMap::iterator it = handlers->begin();