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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/loader/resource_message_filter.h" 5 #include "content/browser/loader/resource_message_filter.h"
6 6
7 #include "content/browser/appcache/chrome_appcache_service.h" 7 #include "content/browser/appcache/chrome_appcache_service.h"
8 #include "content/browser/blob_storage/chrome_blob_storage_context.h" 8 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
9 #include "content/browser/loader/resource_dispatcher_host_impl.h" 9 #include "content/browser/loader/resource_dispatcher_host_impl.h"
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" 10 #include "content/browser/service_worker/service_worker_context_wrapper.h"
(...skipping 28 matching lines...) Expand all
39 void ResourceMessageFilter::OnChannelClosing() { 39 void ResourceMessageFilter::OnChannelClosing() {
40 // Unhook us from all pending network requests so they don't get sent to a 40 // Unhook us from all pending network requests so they don't get sent to a
41 // deleted object. 41 // deleted object.
42 ResourceDispatcherHostImpl::Get()->CancelRequestsForProcess(child_id_); 42 ResourceDispatcherHostImpl::Get()->CancelRequestsForProcess(child_id_);
43 } 43 }
44 44
45 bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message) { 45 bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& message) {
46 return ResourceDispatcherHostImpl::Get()->OnMessageReceived(message, this); 46 return ResourceDispatcherHostImpl::Get()->OnMessageReceived(message, this);
47 } 47 }
48 48
49 void ResourceMessageFilter::OnDestruct() const {
50 // Destroy the filter on the IO thread since that's where its weak pointers
51 // are being used.
52 BrowserThread::DeleteOnIOThread::Destruct(this);
53 }
54
49 void ResourceMessageFilter::GetContexts( 55 void ResourceMessageFilter::GetContexts(
50 ResourceType resource_type, 56 ResourceType resource_type,
51 int origin_pid, 57 int origin_pid,
52 ResourceContext** resource_context, 58 ResourceContext** resource_context,
53 net::URLRequestContext** request_context) { 59 net::URLRequestContext** request_context) {
54 return get_contexts_callback_.Run(resource_type, origin_pid, resource_context, 60 return get_contexts_callback_.Run(resource_type, origin_pid, resource_context,
55 request_context); 61 request_context);
56 } 62 }
57 63
64 bool ResourceMessageFilter::Send(IPC::Message* message) {
65 if (message->is_sync()) {
66 // We don't support sending synchronous messages from the browser.
67 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
68 return false;
69 }
70
71 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
72 BrowserThread::PostTask(
73 BrowserThread::IO, FROM_HERE,
74 base::Bind(base::IgnoreResult(&ResourceMessageFilter::Send), this,
75 message));
76 return true;
77 }
78
79 if (ResourceDispatcherHostImpl::Get()->SendWithMojoIfPossible(*message,
80 this)) {
81 delete message;
82 return true;
83 }
84
85 return BrowserMessageFilter::Send(message);
86 }
87
58 base::WeakPtr<ResourceMessageFilter> ResourceMessageFilter::GetWeakPtr() { 88 base::WeakPtr<ResourceMessageFilter> ResourceMessageFilter::GetWeakPtr() {
89 DCHECK_CURRENTLY_ON(BrowserThread::IO);
59 return weak_ptr_factory_.GetWeakPtr(); 90 return weak_ptr_factory_.GetWeakPtr();
60 } 91 }
61 92
62 } // namespace content 93 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698