Clear protocol handlers on exit
This commit is contained in:
parent
3481acd570
commit
627028e3a0
5 changed files with 27 additions and 2 deletions
|
@ -26,6 +26,18 @@ namespace atom {
|
|||
|
||||
namespace api {
|
||||
|
||||
namespace {
|
||||
|
||||
// Clear protocol handlers in IO thread.
|
||||
void ClearJobFactoryInIO(
|
||||
scoped_refptr<brightray::URLRequestContextGetter> request_context_getter) {
|
||||
auto job_factory = static_cast<AtomURLRequestJobFactory*>(
|
||||
request_context_getter->job_factory());
|
||||
job_factory->Clear();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||
: request_context_getter_(static_cast<brightray::URLRequestContextGetter*>(
|
||||
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<std::string>& schemes) {
|
||||
atom::AtomBrowserClient::SetCustomServiceWorkerSchemes(schemes);
|
||||
|
|
|
@ -43,6 +43,7 @@ class Protocol : public mate::TrackableObject<Protocol> {
|
|||
|
||||
protected:
|
||||
Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context);
|
||||
~Protocol();
|
||||
|
||||
private:
|
||||
// Possible errors.
|
||||
|
|
|
@ -25,7 +25,6 @@ const char* kGeolocationProviderURL =
|
|||
} // namespace
|
||||
|
||||
AtomAccessTokenStore::AtomAccessTokenStore() {
|
||||
LOG(ERROR) << "AtomAccessTokenStore";
|
||||
content::GeolocationProvider::GetInstance()->UserDidOptIntoLocationServices();
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue