diff --git a/atom/browser/api/atom_api_protocol.cc b/atom/browser/api/atom_api_protocol.cc index c762559ab62c..8d542b36f9d7 100644 --- a/atom/browser/api/atom_api_protocol.cc +++ b/atom/browser/api/atom_api_protocol.cc @@ -26,6 +26,18 @@ namespace atom { namespace api { +namespace { + +// Clear protocol handlers in IO thread. +void ClearJobFactoryInIO( + scoped_refptr request_context_getter) { + auto job_factory = static_cast( + request_context_getter->job_factory()); + job_factory->Clear(); +} + +} // namespace + Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context) : request_context_getter_(static_cast( browser_context->GetRequestContext())), @@ -33,6 +45,12 @@ Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context) Init(isolate); } +Protocol::~Protocol() { + content::BrowserThread::PostTask( + content::BrowserThread::IO, FROM_HERE, + base::Bind(ClearJobFactoryInIO, request_context_getter_)); +} + void Protocol::RegisterServiceWorkerSchemes( const std::vector& schemes) { atom::AtomBrowserClient::SetCustomServiceWorkerSchemes(schemes); diff --git a/atom/browser/api/atom_api_protocol.h b/atom/browser/api/atom_api_protocol.h index 379c43bfcd78..b5d47def68c4 100644 --- a/atom/browser/api/atom_api_protocol.h +++ b/atom/browser/api/atom_api_protocol.h @@ -43,6 +43,7 @@ class Protocol : public mate::TrackableObject { protected: Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context); + ~Protocol(); private: // Possible errors. diff --git a/atom/browser/atom_access_token_store.cc b/atom/browser/atom_access_token_store.cc index 9f57148120c8..21ef8edaece9 100644 --- a/atom/browser/atom_access_token_store.cc +++ b/atom/browser/atom_access_token_store.cc @@ -25,7 +25,6 @@ const char* kGeolocationProviderURL = } // namespace AtomAccessTokenStore::AtomAccessTokenStore() { - LOG(ERROR) << "AtomAccessTokenStore"; content::GeolocationProvider::GetInstance()->UserDidOptIntoLocationServices(); } diff --git a/atom/browser/net/atom_url_request_job_factory.cc b/atom/browser/net/atom_url_request_job_factory.cc index d78b7026e563..d0caf183e91b 100644 --- a/atom/browser/net/atom_url_request_job_factory.cc +++ b/atom/browser/net/atom_url_request_job_factory.cc @@ -20,7 +20,7 @@ typedef net::URLRequestJobFactory::ProtocolHandler ProtocolHandler; AtomURLRequestJobFactory::AtomURLRequestJobFactory() {} AtomURLRequestJobFactory::~AtomURLRequestJobFactory() { - STLDeleteValues(&protocol_handler_map_); + Clear(); } bool AtomURLRequestJobFactory::SetProtocolHandler( @@ -77,6 +77,10 @@ bool AtomURLRequestJobFactory::HasProtocolHandler( return ContainsKey(protocol_handler_map_, scheme); } +void AtomURLRequestJobFactory::Clear() { + STLDeleteValues(&protocol_handler_map_); +} + net::URLRequestJob* AtomURLRequestJobFactory::MaybeCreateJobWithProtocolHandler( const std::string& scheme, net::URLRequest* request, diff --git a/atom/browser/net/atom_url_request_job_factory.h b/atom/browser/net/atom_url_request_job_factory.h index ea2710bb4cf3..5b439c2f9cd8 100644 --- a/atom/browser/net/atom_url_request_job_factory.h +++ b/atom/browser/net/atom_url_request_job_factory.h @@ -39,6 +39,9 @@ class AtomURLRequestJobFactory : public net::URLRequestJobFactory { // Whether the protocol handler is registered by the job factory. bool HasProtocolHandler(const std::string& scheme) const; + // Clear all protocol handlers. + void Clear(); + // URLRequestJobFactory implementation net::URLRequestJob* MaybeCreateJobWithProtocolHandler( const std::string& scheme,