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

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

Issue 688413002: Add terminateServiceWorker method for layout tests - chromium side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move message Created 6 years, 1 month 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 "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/message_port_message_filter.h" 10 #include "content/browser/message_port_message_filter.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_ReportConsoleMessage, 189 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_ReportConsoleMessage,
190 OnReportConsoleMessage) 190 OnReportConsoleMessage)
191 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_IncrementServiceWorkerRefCount, 191 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_IncrementServiceWorkerRefCount,
192 OnIncrementServiceWorkerRefCount) 192 OnIncrementServiceWorkerRefCount)
193 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_DecrementServiceWorkerRefCount, 193 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_DecrementServiceWorkerRefCount,
194 OnDecrementServiceWorkerRefCount) 194 OnDecrementServiceWorkerRefCount)
195 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_IncrementRegistrationRefCount, 195 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_IncrementRegistrationRefCount,
196 OnIncrementRegistrationRefCount) 196 OnIncrementRegistrationRefCount)
197 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_DecrementRegistrationRefCount, 197 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_DecrementRegistrationRefCount,
198 OnDecrementRegistrationRefCount) 198 OnDecrementRegistrationRefCount)
199 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_TerminateWorker, OnTerminateWorker)
199 IPC_MESSAGE_UNHANDLED(handled = false) 200 IPC_MESSAGE_UNHANDLED(handled = false)
200 IPC_END_MESSAGE_MAP() 201 IPC_END_MESSAGE_MAP()
201 202
202 if (!handled && GetContext()) { 203 if (!handled && GetContext()) {
203 handled = 204 handled =
204 GetContext()->embedded_worker_registry()->OnMessageReceived(message); 205 GetContext()->embedded_worker_registry()->OnMessageReceived(message);
205 if (!handled) 206 if (!handled)
206 BadMessageReceived(); 207 BadMessageReceived();
207 } 208 }
208 209
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError( 857 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError(
857 thread_id, request_id, error_type, error_message)); 858 thread_id, request_id, error_type, error_message));
858 } 859 }
859 860
860 ServiceWorkerContextCore* ServiceWorkerDispatcherHost::GetContext() { 861 ServiceWorkerContextCore* ServiceWorkerDispatcherHost::GetContext() {
861 if (!context_wrapper_.get()) 862 if (!context_wrapper_.get())
862 return nullptr; 863 return nullptr;
863 return context_wrapper_->context(); 864 return context_wrapper_->context();
864 } 865 }
865 866
867 void ServiceWorkerDispatcherHost::OnTerminateWorker(int handle_id) {
868 ServiceWorkerHandle* handle = handles_.Lookup(handle_id);
869 if (!handle) {
870 BadMessageReceived();
871 return;
872 }
873 handle->version()->StopWorker(
874 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
875 }
876
866 } // namespace content 877 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698