Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Unified Diff: content/browser/loader/resource_message_filter.cc

Issue 1970693002: Use mojo for Chrome Loading, Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 416dc37faabb6024100b7b30ca09394f63c965df..d38aca76dcd4af34b6d9fdff60810e1b07db09af 100644
--- a/content/browser/loader/resource_message_filter.cc
+++ b/content/browser/loader/resource_message_filter.cc
@@ -46,6 +46,12 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message) {
return ResourceDispatcherHostImpl::Get()->OnMessageReceived(message, this);
}
+void ResourceMessageFilter::OnDestruct() const {
+ // Destroy the filter on the IO thread since that's where its weak pointers
+ // are being used.
+ BrowserThread::DeleteOnIOThread::Destruct(this);
+}
+
void ResourceMessageFilter::GetContexts(
ResourceType resource_type,
int origin_pid,
@@ -55,7 +61,29 @@ void ResourceMessageFilter::GetContexts(
request_context);
}
+bool ResourceMessageFilter::Send(IPC::Message* message) {
+ // We don't support sending synchronous messages from the browser.
+ DCHECK(!message->is_sync());
+
+ 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();
}

Powered by Google App Engine
This is Rietveld 408576698