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

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

Issue 1799413002: ServiceWorker: Release a reference when it fails to dispatch ExtendableMessageEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_dispatch_extendable_message_event
Patch Set: Created 4 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/embedded_worker_test_helper.h" 5 #include "content/browser/service_worker/embedded_worker_test_helper.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 181
182 bool EmbeddedWorkerTestHelper::OnMessageToWorker( 182 bool EmbeddedWorkerTestHelper::OnMessageToWorker(
183 int thread_id, 183 int thread_id,
184 int embedded_worker_id, 184 int embedded_worker_id,
185 const IPC::Message& message) { 185 const IPC::Message& message) {
186 bool handled = true; 186 bool handled = true;
187 current_embedded_worker_id_ = embedded_worker_id; 187 current_embedded_worker_id_ = embedded_worker_id;
188 IPC_BEGIN_MESSAGE_MAP(EmbeddedWorkerTestHelper, message) 188 IPC_BEGIN_MESSAGE_MAP(EmbeddedWorkerTestHelper, message)
189 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ActivateEvent, OnActivateEventStub) 189 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ActivateEvent, OnActivateEventStub)
190 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ExtendableMessageEvent,
191 OnExtendableMessageEventStub)
190 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_InstallEvent, OnInstallEventStub) 192 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_InstallEvent, OnInstallEventStub)
191 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FetchEvent, OnFetchEventStub) 193 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FetchEvent, OnFetchEventStub)
192 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_PushEvent, OnPushEventStub) 194 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_PushEvent, OnPushEventStub)
193 IPC_MESSAGE_UNHANDLED(handled = false) 195 IPC_MESSAGE_UNHANDLED(handled = false)
194 IPC_END_MESSAGE_MAP() 196 IPC_END_MESSAGE_MAP()
195 // Record all messages directed to inner script context. 197 // Record all messages directed to inner script context.
196 inner_sink_.OnMessageReceived(message); 198 inner_sink_.OnMessageReceived(message);
197 return handled; 199 return handled;
198 } 200 }
199 201
200 void EmbeddedWorkerTestHelper::OnSetupMojo(ServiceRegistry* service_registry) {} 202 void EmbeddedWorkerTestHelper::OnSetupMojo(ServiceRegistry* service_registry) {}
201 203
202 void EmbeddedWorkerTestHelper::OnActivateEvent(int embedded_worker_id, 204 void EmbeddedWorkerTestHelper::OnActivateEvent(int embedded_worker_id,
203 int request_id) { 205 int request_id) {
204 SimulateSend( 206 SimulateSend(
205 new ServiceWorkerHostMsg_ActivateEventFinished( 207 new ServiceWorkerHostMsg_ActivateEventFinished(
206 embedded_worker_id, request_id, 208 embedded_worker_id, request_id,
207 blink::WebServiceWorkerEventResultCompleted)); 209 blink::WebServiceWorkerEventResultCompleted));
208 } 210 }
209 211
212 void EmbeddedWorkerTestHelper::OnExtendableMessageEvent(int embedded_worker_id,
213 int request_id) {
214 SimulateSend(new ServiceWorkerHostMsg_ExtendableMessageEventFinished(
215 embedded_worker_id, request_id,
216 blink::WebServiceWorkerEventResultCompleted));
217 }
218
210 void EmbeddedWorkerTestHelper::OnInstallEvent(int embedded_worker_id, 219 void EmbeddedWorkerTestHelper::OnInstallEvent(int embedded_worker_id,
211 int request_id) { 220 int request_id) {
212 // The installing worker may have been doomed and terminated. 221 // The installing worker may have been doomed and terminated.
213 if (!registry()->GetWorker(embedded_worker_id)) 222 if (!registry()->GetWorker(embedded_worker_id))
214 return; 223 return;
215 SimulateSend( 224 SimulateSend(
216 new ServiceWorkerHostMsg_InstallEventFinished( 225 new ServiceWorkerHostMsg_InstallEventFinished(
217 embedded_worker_id, request_id, 226 embedded_worker_id, request_id,
218 blink::WebServiceWorkerEventResultCompleted)); 227 blink::WebServiceWorkerEventResultCompleted));
219 } 228 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 base::Bind( 364 base::Bind(
356 base::IgnoreResult(&EmbeddedWorkerTestHelper::OnMessageToWorker), 365 base::IgnoreResult(&EmbeddedWorkerTestHelper::OnMessageToWorker),
357 weak_factory_.GetWeakPtr(), 366 weak_factory_.GetWeakPtr(),
358 thread_id, 367 thread_id,
359 embedded_worker_id, 368 embedded_worker_id,
360 message)); 369 message));
361 } 370 }
362 371
363 void EmbeddedWorkerTestHelper::OnActivateEventStub(int request_id) { 372 void EmbeddedWorkerTestHelper::OnActivateEventStub(int request_id) {
364 base::ThreadTaskRunnerHandle::Get()->PostTask( 373 base::ThreadTaskRunnerHandle::Get()->PostTask(
365 FROM_HERE, 374 FROM_HERE, base::Bind(&EmbeddedWorkerTestHelper::OnActivateEvent,
366 base::Bind(&EmbeddedWorkerTestHelper::OnActivateEvent, 375 weak_factory_.GetWeakPtr(),
367 weak_factory_.GetWeakPtr(), 376 current_embedded_worker_id_, request_id));
368 current_embedded_worker_id_, 377 }
369 request_id)); 378
379 void EmbeddedWorkerTestHelper::OnExtendableMessageEventStub(
380 int request_id,
381 const ServiceWorkerMsg_ExtendableMessageEvent_Params& params) {
382 base::ThreadTaskRunnerHandle::Get()->PostTask(
383 FROM_HERE, base::Bind(&EmbeddedWorkerTestHelper::OnExtendableMessageEvent,
384 weak_factory_.GetWeakPtr(),
385 current_embedded_worker_id_, request_id));
370 } 386 }
371 387
372 void EmbeddedWorkerTestHelper::OnInstallEventStub(int request_id) { 388 void EmbeddedWorkerTestHelper::OnInstallEventStub(int request_id) {
373 base::ThreadTaskRunnerHandle::Get()->PostTask( 389 base::ThreadTaskRunnerHandle::Get()->PostTask(
374 FROM_HERE, 390 FROM_HERE,
375 base::Bind(&EmbeddedWorkerTestHelper::OnInstallEvent, 391 base::Bind(&EmbeddedWorkerTestHelper::OnInstallEvent,
376 weak_factory_.GetWeakPtr(), 392 weak_factory_.GetWeakPtr(),
377 current_embedded_worker_id_, 393 current_embedded_worker_id_,
378 request_id)); 394 request_id));
379 } 395 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 433
418 MessagePortMessageFilter* 434 MessagePortMessageFilter*
419 EmbeddedWorkerTestHelper::NewMessagePortMessageFilter() { 435 EmbeddedWorkerTestHelper::NewMessagePortMessageFilter() {
420 scoped_refptr<MessagePortMessageFilter> filter( 436 scoped_refptr<MessagePortMessageFilter> filter(
421 new MockMessagePortMessageFilter); 437 new MockMessagePortMessageFilter);
422 message_port_message_filters_.push_back(filter); 438 message_port_message_filters_.push_back(filter);
423 return filter.get(); 439 return filter.get();
424 } 440 }
425 441
426 } // namespace content 442 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698