From c7fed48c4abb53fa8f66a71c662df9bcf2c3adb7 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 3 Sep 2013 17:21:10 +0800 Subject: [PATCH] Emit erros when getting errors in IO thread. --- browser/api/atom_api_protocol.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/browser/api/atom_api_protocol.cc b/browser/api/atom_api_protocol.cc index 3327745..498dae4 100644 --- a/browser/api/atom_api_protocol.cc +++ b/browser/api/atom_api_protocol.cc @@ -293,6 +293,16 @@ void Protocol::InterceptProtocolInIO(const std::string& scheme) { DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); AtomURLRequestJobFactory* job_factory(GetRequestJobFactory()); ProtocolHandler* original_handler = job_factory->GetProtocolHandler(scheme); + if (original_handler == NULL) { + content::BrowserThread::PostTask( + content::BrowserThread::UI, + FROM_HERE, + base::Bind(&EmitEventInUI, + "error", + "There is no protocol handler to intercpet")); + return; + } + job_factory->ReplaceProtocol(scheme, new CustomProtocolHandler(original_handler)); @@ -311,8 +321,15 @@ void Protocol::UninterceptProtocolInIO(const std::string& scheme) { // Check if the protocol handler is intercepted. CustomProtocolHandler* handler = static_cast( job_factory->GetProtocolHandler(scheme)); - if (!handler->original_handler()) + if (handler->original_handler() == NULL) { + content::BrowserThread::PostTask( + content::BrowserThread::UI, + FROM_HERE, + base::Bind(&EmitEventInUI, + "error", + "The protocol is not intercpeted")); return; + } // Reset the protocol handler to the orignal one and delete current // protocol handler. -- 2.7.4