Skip to content

Commit

Permalink
Emit erros when getting errors in IO thread.
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Sep 3, 2013
1 parent 7737708 commit c7fed48
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion browser/api/atom_api_protocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -311,8 +321,15 @@ void Protocol::UninterceptProtocolInIO(const std::string& scheme) {
// Check if the protocol handler is intercepted.
CustomProtocolHandler* handler = static_cast<CustomProtocolHandler*>(
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.
Expand Down

0 comments on commit c7fed48

Please sign in to comment.