Revert "[WIP] refactor: (Part I) make the ownership of URLRequestContextGetter more clear (#13956)"

This reverts commit 1c0bb06d4a.
This commit is contained in:
Charles Kerr 2018-08-13 16:16:04 -07:00
parent 1c0bb06d4a
commit b9490177da
34 changed files with 1121 additions and 985 deletions

View file

@ -78,13 +78,13 @@ class Protocol : public mate::TrackableObject<Protocol> {
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const override {
RequestJob* request_job = new RequestJob(request, network_delegate);
request_job->SetHandlerInfo(isolate_, request_context_, handler_);
request_job->SetHandlerInfo(isolate_, request_context_.get(), handler_);
return request_job;
}
private:
v8::Isolate* isolate_;
net::URLRequestContextGetter* request_context_;
scoped_refptr<net::URLRequestContextGetter> request_context_;
Protocol::Handler handler_;
DISALLOW_COPY_AND_ASSIGN(CustomProtocolHandler);
@ -113,8 +113,8 @@ class Protocol : public mate::TrackableObject<Protocol> {
v8::Isolate* isolate,
const std::string& scheme,
const Handler& handler) {
auto* job_factory = static_cast<const AtomURLRequestJobFactory*>(
request_context_getter->GetURLRequestContext()->job_factory());
auto* job_factory = static_cast<AtomURLRequestJobFactory*>(
request_context_getter->job_factory());
if (job_factory->IsHandledProtocol(scheme))
return PROTOCOL_REGISTERED;
auto protocol_handler = std::make_unique<CustomProtocolHandler<RequestJob>>(
@ -158,10 +158,13 @@ class Protocol : public mate::TrackableObject<Protocol> {
v8::Isolate* isolate,
const std::string& scheme,
const Handler& handler) {
auto* job_factory = static_cast<const AtomURLRequestJobFactory*>(
request_context_getter->GetURLRequestContext()->job_factory());
auto* job_factory = static_cast<AtomURLRequestJobFactory*>(
request_context_getter->job_factory());
if (!job_factory->IsHandledProtocol(scheme))
return PROTOCOL_NOT_REGISTERED;
// It is possible a protocol is handled but can not be intercepted.
if (!job_factory->HasProtocolHandler(scheme))
return PROTOCOL_FAIL;
auto protocol_handler = std::make_unique<CustomProtocolHandler<RequestJob>>(
isolate, request_context_getter.get(), handler);
if (!job_factory->InterceptProtocol(scheme, std::move(protocol_handler)))