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

Side by Side Diff: content/child/service_worker/web_service_worker_provider_impl.cc

Issue 2658603003: ServiceWorker: Enable UseCounter for ServiceWorkerGlobalScope (Closed)
Patch Set: ready to review Created 3 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/child/service_worker/web_service_worker_provider_impl.h" 5 #include "content/child/service_worker/web_service_worker_provider_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "content/child/service_worker/service_worker_dispatcher.h" 10 #include "content/child/service_worker/service_worker_dispatcher.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // the single provider context across threads. (http://crbug.com/366538 46 // the single provider context across threads. (http://crbug.com/366538
47 // for more context) 47 // for more context)
48 GetDispatcher()->AddProviderClient(context_->provider_id(), client); 48 GetDispatcher()->AddProviderClient(context_->provider_id(), client);
49 49
50 if (!context_->controller()) 50 if (!context_->controller())
51 return; 51 return;
52 scoped_refptr<WebServiceWorkerImpl> controller = 52 scoped_refptr<WebServiceWorkerImpl> controller =
53 GetDispatcher()->GetOrCreateServiceWorker( 53 GetDispatcher()->GetOrCreateServiceWorker(
54 ServiceWorkerHandleReference::Create(context_->controller()->info(), 54 ServiceWorkerHandleReference::Create(context_->controller()->info(),
55 thread_safe_sender_.get())); 55 thread_safe_sender_.get()));
56
57 // Sync controllee's use counter with service worker's use counter.
58 for (uint32_t feature : context_->used_features())
59 client->countFeature(feature);
56 client->setController(WebServiceWorkerImpl::CreateHandle(controller), 60 client->setController(WebServiceWorkerImpl::CreateHandle(controller),
57 false /* shouldNotifyControllerChange */); 61 false /* shouldNotifyControllerChange */);
58 } 62 }
59 63
60 void WebServiceWorkerProviderImpl::registerServiceWorker( 64 void WebServiceWorkerProviderImpl::registerServiceWorker(
61 const WebURL& pattern, 65 const WebURL& pattern,
62 const WebURL& script_url, 66 const WebURL& script_url,
63 std::unique_ptr<WebServiceWorkerRegistrationCallbacks> callbacks) { 67 std::unique_ptr<WebServiceWorkerRegistrationCallbacks> callbacks) {
64 GetDispatcher()->RegisterServiceWorker(context_->provider_id(), pattern, 68 GetDispatcher()->RegisterServiceWorker(context_->provider_id(), pattern,
65 script_url, std::move(callbacks)); 69 script_url, std::move(callbacks));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 ServiceWorkerDispatcher::GetThreadSpecificInstance(); 112 ServiceWorkerDispatcher::GetThreadSpecificInstance();
109 if (dispatcher) 113 if (dispatcher)
110 dispatcher->RemoveProviderClient(context_->provider_id()); 114 dispatcher->RemoveProviderClient(context_->provider_id());
111 } 115 }
112 116
113 ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() { 117 ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() {
114 return ServiceWorkerDispatcher::GetThreadSpecificInstance(); 118 return ServiceWorkerDispatcher::GetThreadSpecificInstance();
115 } 119 }
116 120
117 } // namespace content 121 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698