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

Side by Side Diff: content/browser/service_worker/service_worker_dispatcher_host.cc

Issue 2396273002: ServiceWorker: Mojofication of ServiceWorkerDispatcherHost (Closed)
Patch Set: Moved ptr of dispatcher_host to SWNetworkProvider Created 4 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/service_worker/service_worker_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/debug/crash_logging.h" 9 #include "base/debug/crash_logging.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost( 95 ServiceWorkerDispatcherHost::ServiceWorkerDispatcherHost(
96 int render_process_id, 96 int render_process_id,
97 MessagePortMessageFilter* message_port_message_filter, 97 MessagePortMessageFilter* message_port_message_filter,
98 ResourceContext* resource_context) 98 ResourceContext* resource_context)
99 : BrowserMessageFilter(kFilteredMessageClasses, 99 : BrowserMessageFilter(kFilteredMessageClasses,
100 arraysize(kFilteredMessageClasses)), 100 arraysize(kFilteredMessageClasses)),
101 render_process_id_(render_process_id), 101 render_process_id_(render_process_id),
102 message_port_message_filter_(message_port_message_filter), 102 message_port_message_filter_(message_port_message_filter),
103 resource_context_(resource_context), 103 resource_context_(resource_context),
104 channel_ready_(false) { 104 channel_ready_(false),
105 weak_factory_(this) {
106 AddAssociatedInterface(
107 mojom::ServiceWorkerDispatcherHost::Name_,
108 base::Bind(&ServiceWorkerDispatcherHost::AddMojoBinding, GetWeakPtr()));
horo 2016/10/07 07:39:29 I think we don't need to use weak pointer. base::U
shimazu 2016/10/14 08:15:03 Done.
105 } 109 }
106 110
107 ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() { 111 ServiceWorkerDispatcherHost::~ServiceWorkerDispatcherHost() {
108 if (GetContext()) { 112 if (GetContext()) {
109 GetContext()->RemoveAllProviderHostsForProcess(render_process_id_); 113 GetContext()->RemoveAllProviderHostsForProcess(render_process_id_);
110 GetContext()->embedded_worker_registry()->RemoveChildProcessSender( 114 GetContext()->embedded_worker_registry()->RemoveChildProcessSender(
111 render_process_id_); 115 render_process_id_);
112 } 116 }
113 } 117 }
114 118
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (!handled && GetContext()) { 216 if (!handled && GetContext()) {
213 handled = GetContext()->embedded_worker_registry()->OnMessageReceived( 217 handled = GetContext()->embedded_worker_registry()->OnMessageReceived(
214 message, render_process_id_); 218 message, render_process_id_);
215 if (!handled) 219 if (!handled)
216 bad_message::ReceivedBadMessage(this, bad_message::SWDH_NOT_HANDLED); 220 bad_message::ReceivedBadMessage(this, bad_message::SWDH_NOT_HANDLED);
217 } 221 }
218 222
219 return handled; 223 return handled;
220 } 224 }
221 225
226 void ServiceWorkerDispatcherHost::AddMojoBinding(
227 mojo::ScopedInterfaceEndpointHandle handle) {
228 bindings_.AddBinding(
229 this, mojo::MakeAssociatedRequest<mojom::ServiceWorkerDispatcherHost>(
230 std::move(handle)));
231 }
232
222 bool ServiceWorkerDispatcherHost::Send(IPC::Message* message) { 233 bool ServiceWorkerDispatcherHost::Send(IPC::Message* message) {
223 if (channel_ready_) { 234 if (channel_ready_) {
224 BrowserMessageFilter::Send(message); 235 BrowserMessageFilter::Send(message);
225 // Don't bother passing through Send()'s result: it's not reliable. 236 // Don't bother passing through Send()'s result: it's not reliable.
226 return true; 237 return true;
227 } 238 }
228 239
229 pending_messages_.push_back(base::WrapUnique(message)); 240 pending_messages_.push_back(base::WrapUnique(message));
230 return true; 241 return true;
231 } 242 }
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 if (!handle) { 1466 if (!handle) {
1456 bad_message::ReceivedBadMessage(this, 1467 bad_message::ReceivedBadMessage(this,
1457 bad_message::SWDH_TERMINATE_BAD_HANDLE); 1468 bad_message::SWDH_TERMINATE_BAD_HANDLE);
1458 return; 1469 return;
1459 } 1470 }
1460 handle->version()->StopWorker( 1471 handle->version()->StopWorker(
1461 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 1472 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
1462 } 1473 }
1463 1474
1464 } // namespace content 1475 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698