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

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

Issue 893363003: ServiceWorker: Support SWRegistration.unregister() in SWGlobalScope [1/2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update header comment2 Created 5 years, 10 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 "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "content/browser/message_port_message_filter.h" 10 #include "content/browser/message_port_message_filter.h"
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 BadMessageReceived(); 554 BadMessageReceived();
555 555
556 // Retrieve the registration associated with |version_id|. 556 // Retrieve the registration associated with |version_id|.
557 ServiceWorkerVersion* version = GetContext()->GetLiveVersion(version_id); 557 ServiceWorkerVersion* version = GetContext()->GetLiveVersion(version_id);
558 if (!version) 558 if (!version)
559 return; 559 return;
560 ServiceWorkerRegistration* registration = 560 ServiceWorkerRegistration* registration =
561 GetContext()->GetLiveRegistration(version->registration_id()); 561 GetContext()->GetLiveRegistration(version->registration_id());
562 DCHECK(registration); 562 DCHECK(registration);
563 563
564 // Set the document URL to the script url in order to allow
565 // register/unregister/getRegistration on ServiceWorkerGlobalScope.
566 provider_host->SetDocumentUrl(version->script_url());
567
564 ServiceWorkerRegistrationObjectInfo info; 568 ServiceWorkerRegistrationObjectInfo info;
565 ServiceWorkerVersionAttributes attrs; 569 ServiceWorkerVersionAttributes attrs;
566 GetRegistrationObjectInfoAndVersionAttributes( 570 GetRegistrationObjectInfoAndVersionAttributes(
567 provider_host->AsWeakPtr(), registration, &info, &attrs); 571 provider_host->AsWeakPtr(), registration, &info, &attrs);
568 572
569 Send(new ServiceWorkerMsg_AssociateRegistrationWithServiceWorker( 573 Send(new ServiceWorkerMsg_AssociateRegistrationWithServiceWorker(
570 kDocumentMainThreadId, provider_id, info, attrs)); 574 kDocumentMainThreadId, provider_id, info, attrs));
571 } 575 }
572 576
573 ServiceWorkerRegistrationHandle* 577 ServiceWorkerRegistrationHandle*
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 ServiceWorkerHandle* handle = handles_.Lookup(handle_id); 942 ServiceWorkerHandle* handle = handles_.Lookup(handle_id);
939 if (!handle) { 943 if (!handle) {
940 BadMessageReceived(); 944 BadMessageReceived();
941 return; 945 return;
942 } 946 }
943 handle->version()->StopWorker( 947 handle->version()->StopWorker(
944 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 948 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
945 } 949 }
946 950
947 } // namespace content 951 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698