dict.Get("referrer", &referrer);
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
- base::Bind(&AdapterRequestJob::CreateHttpJobAndStart,
- GetWeakPtr(), url, method, referrer));
+ base::Bind(&AdapterRequestJob::CreateHttpJobAndStart, GetWeakPtr(),
+ registry_->browser_context(), url, method, referrer));
return;
}
}
JsProtocolHandler GetProtocolHandler(const std::string& scheme);
+ AtomBrowserContext* browser_context() const { return browser_context_; }
+
protected:
explicit Protocol(AtomBrowserContext* browser_context);
real_job_->Start();
}
-void AdapterRequestJob::CreateHttpJobAndStart(const GURL& url,
- const std::string& method,
- const std::string& referrer) {
+void AdapterRequestJob::CreateHttpJobAndStart(
+ AtomBrowserContext* browser_context,
+ const GURL& url,
+ const std::string& method,
+ const std::string& referrer) {
if (!url.is_valid()) {
CreateErrorJobAndStart(net::ERR_INVALID_URL);
return;
}
- real_job_ = new URLRequestFetchJob(request(), network_delegate(), url,
- method, referrer);
+ real_job_ = new URLRequestFetchJob(browser_context, request(),
+ network_delegate(), url, method, referrer);
real_job_->Start();
}
namespace atom {
+class AtomBrowserContext;
+
// Ask JS which type of job it wants, and then delegate corresponding methods.
class AdapterRequestJob : public net::URLRequestJob {
public:
const std::string& charset,
scoped_refptr<base::RefCountedBytes> data);
void CreateFileJobAndStart(const base::FilePath& path);
- void CreateHttpJobAndStart(const GURL& url,
+ void CreateHttpJobAndStart(AtomBrowserContext* browser_context,
+ const GURL& url,
const std::string& method,
const std::string& referrer);
void CreateJobFromProtocolHandlerAndStart();
} // namespace
URLRequestFetchJob::URLRequestFetchJob(
+ AtomBrowserContext* browser_context,
net::URLRequest* request,
net::NetworkDelegate* network_delegate,
const GURL& url,
request_type = GetRequestType(method);
fetcher_.reset(net::URLFetcher::Create(url, request_type, this));
- auto context = AtomBrowserContext::Get()->url_request_context_getter();
- fetcher_->SetRequestContext(context);
+ fetcher_->SetRequestContext(browser_context->url_request_context_getter());
fetcher_->SaveResponseWithWriter(make_scoped_ptr(new ResponsePiper(this)));
// Use |request|'s referrer if |referrer| is not specified.
namespace atom {
+class AtomBrowserContext;
+
class URLRequestFetchJob : public net::URLRequestJob,
public net::URLFetcherDelegate {
public:
- URLRequestFetchJob(net::URLRequest* request,
+ URLRequestFetchJob(AtomBrowserContext* browser_context,
+ net::URLRequest* request,
net::NetworkDelegate* network_delegate,
const GURL& url,
const std::string& method,