use current session when not defined
This commit is contained in:
parent
57244e4718
commit
de3ccc4b98
4 changed files with 10 additions and 9 deletions
|
@ -39,7 +39,7 @@ template<>
|
||||||
struct Converter<net::URLRequestContextGetter*> {
|
struct Converter<net::URLRequestContextGetter*> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
||||||
net::URLRequestContextGetter** out) {
|
net::URLRequestContextGetter** out) {
|
||||||
if (val->IsNull() || val->IsUndefined()) {
|
if (val->IsNull()) {
|
||||||
*out = nullptr;
|
*out = nullptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ struct Converter<net::URLRequestContextGetter*> {
|
||||||
atom::api::Session* session;
|
atom::api::Session* session;
|
||||||
if (!Converter<atom::api::Session*>::FromV8(isolate, val, &session))
|
if (!Converter<atom::api::Session*>::FromV8(isolate, val, &session))
|
||||||
return false;
|
return false;
|
||||||
*out = session->GetBrowserContext()->GetRequestContext();
|
*out = session->browser_context()->GetRequestContext();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -144,7 +144,8 @@ class CustomProtocolRequestJob : public AdapterRequestJob {
|
||||||
} else if (name == "RequestHttpJob") {
|
} else if (name == "RequestHttpJob") {
|
||||||
GURL url;
|
GURL url;
|
||||||
std::string method, referrer;
|
std::string method, referrer;
|
||||||
net::URLRequestContextGetter* getter;
|
net::URLRequestContextGetter* getter =
|
||||||
|
registry_->browser_context()->GetRequestContext();
|
||||||
dict.Get("url", &url);
|
dict.Get("url", &url);
|
||||||
dict.Get("method", &method);
|
dict.Get("method", &method);
|
||||||
dict.Get("referrer", &referrer);
|
dict.Get("referrer", &referrer);
|
||||||
|
@ -231,7 +232,8 @@ std::string ConvertErrorCode(int error_code) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Protocol::Protocol(AtomBrowserContext* browser_context)
|
Protocol::Protocol(AtomBrowserContext* browser_context)
|
||||||
: job_factory_(browser_context->job_factory()) {
|
: browser_context_(browser_context),
|
||||||
|
job_factory_(browser_context->job_factory()) {
|
||||||
CHECK(job_factory_);
|
CHECK(job_factory_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,8 @@ class Protocol : public mate::EventEmitter {
|
||||||
|
|
||||||
JsProtocolHandler GetProtocolHandler(const std::string& scheme);
|
JsProtocolHandler GetProtocolHandler(const std::string& scheme);
|
||||||
|
|
||||||
|
AtomBrowserContext* browser_context() const { return browser_context_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit Protocol(AtomBrowserContext* browser_context);
|
explicit Protocol(AtomBrowserContext* browser_context);
|
||||||
|
|
||||||
|
@ -92,6 +94,7 @@ class Protocol : public mate::EventEmitter {
|
||||||
const JsProtocolHandler& handler);
|
const JsProtocolHandler& handler);
|
||||||
int UninterceptProtocolInIO(const std::string& scheme);
|
int UninterceptProtocolInIO(const std::string& scheme);
|
||||||
|
|
||||||
|
AtomBrowserContext* browser_context_;
|
||||||
AtomURLRequestJobFactory* job_factory_;
|
AtomURLRequestJobFactory* job_factory_;
|
||||||
ProtocolHandlersMap protocol_handlers_;
|
ProtocolHandlersMap protocol_handlers_;
|
||||||
|
|
||||||
|
|
|
@ -203,10 +203,6 @@ Session::Session(AtomBrowserContext* browser_context)
|
||||||
Session::~Session() {
|
Session::~Session() {
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomBrowserContext* Session::GetBrowserContext() const {
|
|
||||||
return browser_context_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Session::ResolveProxy(const GURL& url, ResolveProxyCallback callback) {
|
void Session::ResolveProxy(const GURL& url, ResolveProxyCallback callback) {
|
||||||
new ResolveProxyHelper(browser_context_, url, callback);
|
new ResolveProxyHelper(browser_context_, url, callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Session: public mate::TrackableObject<Session> {
|
||||||
static mate::Handle<Session> CreateFrom(
|
static mate::Handle<Session> CreateFrom(
|
||||||
v8::Isolate* isolate, AtomBrowserContext* browser_context);
|
v8::Isolate* isolate, AtomBrowserContext* browser_context);
|
||||||
|
|
||||||
AtomBrowserContext* GetBrowserContext() const;
|
AtomBrowserContext* browser_context() const { return browser_context_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit Session(AtomBrowserContext* browser_context);
|
explicit Session(AtomBrowserContext* browser_context);
|
||||||
|
|
Loading…
Reference in a new issue