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

* refactor: desttroy URLRequestContextGetter on IO thread

* Accepts a factory class that can customize the creation of URLRequestContext
* Use a separate request context for media which is derived from the default
* Notify URLRequestContextGetter observers and cleanup on IO thread
* Move most of brightray net/ classes into atom net/

* refactor: remove refs to URLRequestContextGetter on shutdown

* refactor: remove brigtray switches.{cc|h}

* refactor: remove brightray network_delegate.{cc|h}

* refactor: make AtomURLRequestJobFactory the top level factory.

* Allows to use the default handler from content/ for http{s}, ws{s} schemes.
* Removes the storage of job factory in URLRequestContextGetter.
This commit is contained in:
Robo 2018-08-14 03:52:45 +05:30 committed by Samuel Attard
parent cb4b3e7be0
commit 1c0bb06d4a
34 changed files with 985 additions and 1121 deletions

View file

@ -95,8 +95,8 @@ void Protocol::UnregisterProtocol(const std::string& scheme,
Protocol::ProtocolError Protocol::UnregisterProtocolInIO(
scoped_refptr<brightray::URLRequestContextGetter> request_context_getter,
const std::string& scheme) {
auto* job_factory = static_cast<AtomURLRequestJobFactory*>(
request_context_getter->job_factory());
auto* job_factory = static_cast<const AtomURLRequestJobFactory*>(
request_context_getter->GetURLRequestContext()->job_factory());
if (!job_factory->HasProtocolHandler(scheme))
return PROTOCOL_NOT_REGISTERED;
job_factory->SetProtocolHandler(scheme, nullptr);
@ -117,7 +117,9 @@ void Protocol::IsProtocolHandled(const std::string& scheme,
bool Protocol::IsProtocolHandledInIO(
scoped_refptr<brightray::URLRequestContextGetter> request_context_getter,
const std::string& scheme) {
return request_context_getter->job_factory()->IsHandledProtocol(scheme);
return request_context_getter->GetURLRequestContext()
->job_factory()
->IsHandledProtocol(scheme);
}
void Protocol::UninterceptProtocol(const std::string& scheme,
@ -136,8 +138,8 @@ void Protocol::UninterceptProtocol(const std::string& scheme,
Protocol::ProtocolError Protocol::UninterceptProtocolInIO(
scoped_refptr<brightray::URLRequestContextGetter> request_context_getter,
const std::string& scheme) {
return static_cast<AtomURLRequestJobFactory*>(
request_context_getter->job_factory())
return static_cast<const AtomURLRequestJobFactory*>(
request_context_getter->GetURLRequestContext()->job_factory())
->UninterceptProtocol(scheme)
? PROTOCOL_OK
: PROTOCOL_NOT_INTERCEPTED;