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

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

Issue 516823003: ServiceWorker: Change the return value of ServiceWorkerRegistration::unregister to boolean (2/4) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/browser/message_port_message_filter.h" 9 #include "content/browser/message_port_message_filter.h"
10 #include "content/browser/message_port_service.h" 10 #include "content/browser/message_port_service.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 provider_id, 224 provider_id,
225 request_id)); 225 request_id));
226 } 226 }
227 227
228 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker( 228 void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker(
229 int thread_id, 229 int thread_id,
230 int request_id, 230 int request_id,
231 int provider_id, 231 int provider_id,
232 const GURL& pattern) { 232 const GURL& pattern) {
233 if (!GetContext()) { 233 if (!GetContext()) {
234 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( 234 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError(
235 thread_id, 235 thread_id,
236 request_id, 236 request_id,
237 blink::WebServiceWorkerError::ErrorTypeAbort, 237 blink::WebServiceWorkerError::ErrorTypeAbort,
238 base::ASCIIToUTF16(kShutdownErrorMessage))); 238 base::ASCIIToUTF16(kShutdownErrorMessage)));
239 return; 239 return;
240 } 240 }
241 241
242 ServiceWorkerProviderHost* provider_host = GetContext()->GetProviderHost( 242 ServiceWorkerProviderHost* provider_host = GetContext()->GetProviderHost(
243 render_process_id_, provider_id); 243 render_process_id_, provider_id);
244 if (!provider_host) { 244 if (!provider_host) {
245 BadMessageReceived(); 245 BadMessageReceived();
246 return; 246 return;
247 } 247 }
248 if (!provider_host->IsContextAlive()) { 248 if (!provider_host->IsContextAlive()) {
249 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( 249 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError(
250 thread_id, 250 thread_id,
251 request_id, 251 request_id,
252 blink::WebServiceWorkerError::ErrorTypeAbort, 252 blink::WebServiceWorkerError::ErrorTypeAbort,
253 base::ASCIIToUTF16(kShutdownErrorMessage))); 253 base::ASCIIToUTF16(kShutdownErrorMessage)));
254 return; 254 return;
255 } 255 }
256 256
257 if (!CanUnregisterServiceWorker(provider_host->document_url(), pattern)) { 257 if (!CanUnregisterServiceWorker(provider_host->document_url(), pattern)) {
258 BadMessageReceived(); 258 BadMessageReceived();
259 return; 259 return;
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 handle->DecrementRefCount(); 528 handle->DecrementRefCount();
529 if (handle->HasNoRefCount()) 529 if (handle->HasNoRefCount())
530 registration_handles_.Remove(registration_handle_id); 530 registration_handles_.Remove(registration_handle_id);
531 } 531 }
532 532
533 void ServiceWorkerDispatcherHost::UnregistrationComplete( 533 void ServiceWorkerDispatcherHost::UnregistrationComplete(
534 int thread_id, 534 int thread_id,
535 int request_id, 535 int request_id,
536 ServiceWorkerStatusCode status) { 536 ServiceWorkerStatusCode status) {
537 if (status != SERVICE_WORKER_OK) { 537 if (status != SERVICE_WORKER_OK) {
538 SendRegistrationError(thread_id, request_id, status); 538 SendUnregistrationError(thread_id, request_id, status);
539 return; 539 return;
540 } 540 }
541 541
542 Send(new ServiceWorkerMsg_ServiceWorkerUnregistered(thread_id, request_id)); 542 Send(new ServiceWorkerMsg_ServiceWorkerUnregistered(thread_id, request_id));
543 } 543 }
544 544
545 void ServiceWorkerDispatcherHost::SendRegistrationError( 545 void ServiceWorkerDispatcherHost::SendRegistrationError(
546 int thread_id, 546 int thread_id,
547 int request_id, 547 int request_id,
548 ServiceWorkerStatusCode status) { 548 ServiceWorkerStatusCode status) {
549 base::string16 error_message; 549 base::string16 error_message;
550 blink::WebServiceWorkerError::ErrorType error_type; 550 blink::WebServiceWorkerError::ErrorType error_type;
551 GetServiceWorkerRegistrationStatusResponse( 551 GetServiceWorkerRegistrationStatusResponse(
552 status, &error_type, &error_message); 552 status, &error_type, &error_message);
553 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( 553 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError(
554 thread_id, request_id, error_type, error_message)); 554 thread_id, request_id, error_type, error_message));
555 } 555 }
556 556
557 void ServiceWorkerDispatcherHost::SendUnregistrationError(
558 int thread_id,
559 int request_id,
560 ServiceWorkerStatusCode status) {
561 base::string16 error_message;
562 blink::WebServiceWorkerError::ErrorType error_type;
563 GetServiceWorkerRegistrationStatusResponse(
564 status, &error_type, &error_message);
565 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError(
566 thread_id, request_id, error_type, error_message));
567 }
568
557 ServiceWorkerContextCore* ServiceWorkerDispatcherHost::GetContext() { 569 ServiceWorkerContextCore* ServiceWorkerDispatcherHost::GetContext() {
558 return context_wrapper_->context(); 570 return context_wrapper_->context();
559 } 571 }
560 572
561 } // namespace content 573 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698