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

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..9aec15cbd0d14b7a740339406718d29027b9d67e 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,32 @@ void ResourceMessageFilter::GetContexts(
request_context);
}
+bool ResourceMessageFilter::Send(IPC::Message* message) {
+ if (message->is_sync()) {
+ // We don't support sending synchronous messages from the browser.
+ NOTREACHED() << "Can't send sync message through ResourceMessageFilter!";
kinuko 2016/05/20 09:38:51 nit: any reason we don't use CHECK or DCHECK here,
yhirano 2016/05/20 11:32:54 NOTREACHED is DCHECK. https://code.google.com/p/c
kinuko 2016/05/20 15:56:46 I'm meaning this: https://www.chromium.org/develo
+ 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();
}

Powered by Google App Engine
This is Rietveld 408576698