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