Index: content/browser/loader/resource_message_filter.cc |
diff --git a/content/browser/loader/resource_message_filter.cc b/content/browser/loader/resource_message_filter.cc |
index 186bf66316ef0ebe2a3f3df44d01520e9d2146bd..3e0613108d1f0fac0d4748eedc89cbe89364187d 100644 |
--- a/content/browser/loader/resource_message_filter.cc |
+++ b/content/browser/loader/resource_message_filter.cc |
@@ -64,7 +64,35 @@ const HostZoomMap* ResourceMessageFilter::GetHostZoomMap() const { |
return NULL; |
} |
+bool ResourceMessageFilter::Send(IPC::Message* message) { |
+ if (message->is_sync()) { |
+ // We don't support sending synchronous messages from the browser. If we |
+ // really needed it, we can make this class derive from SyncMessageFilter |
+ // but it seems better to not allow sending synchronous messages from the |
+ // browser, since it might allow a corrupt/malicious renderer to hang us. |
+ NOTREACHED() << "Can't send sync message through ResourceMessageFilter!"; |
+ return false; |
+ } |
+ |
+ if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, FROM_HERE, |
+ base::Bind(base::IgnoreResult(&ResourceMessageFilter::Send), this, |
+ message)); |
+ return true; |
+ } |
+ |
+ if (ResourceDispatcherHostImpl::Get()->SendWithMojoIfPossible(*message, |
+ this)) { |
+ delete message; |
+ return true; |
+ } |
+ |
+ return BrowserMessageFilter::Send(message); |
+} |
+ |
base::WeakPtr<ResourceMessageFilter> ResourceMessageFilter::GetWeakPtr() { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
return weak_ptr_factory_.GetWeakPtr(); |
} |