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

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

Issue 2658603003: ServiceWorker: Enable UseCounter for ServiceWorkerGlobalScope (Closed)
Patch Set: int32_t -> uint32_t 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/browser/service_worker/service_worker_provider_host.h" 5 #include "content/browser/service_worker/service_worker_provider_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 if (previous_version.get()) 241 if (previous_version.get())
242 previous_version->RemoveControllee(this); 242 previous_version->RemoveControllee(this);
243 243
244 if (!dispatcher_host_) 244 if (!dispatcher_host_)
245 return; // Could be NULL in some tests. 245 return; // Could be NULL in some tests.
246 246
247 // SetController message should be sent only for controllees. 247 // SetController message should be sent only for controllees.
248 DCHECK(IsProviderForClient()); 248 DCHECK(IsProviderForClient());
249 Send(new ServiceWorkerMsg_SetControllerServiceWorker( 249 Send(new ServiceWorkerMsg_SetControllerServiceWorker(
250 render_thread_id_, provider_id(), GetOrCreateServiceWorkerHandle(version), 250 render_thread_id_, provider_id(), GetOrCreateServiceWorkerHandle(version),
251 notify_controllerchange)); 251 notify_controllerchange,
252 version ? version->used_features() : std::set<uint32_t>()));
252 } 253 }
253 254
254 void ServiceWorkerProviderHost::SetHostedVersion( 255 void ServiceWorkerProviderHost::SetHostedVersion(
255 ServiceWorkerVersion* version) { 256 ServiceWorkerVersion* version) {
256 DCHECK(!IsProviderForClient()); 257 DCHECK(!IsProviderForClient());
257 DCHECK_EQ(EmbeddedWorkerStatus::STARTING, version->running_status()); 258 DCHECK_EQ(EmbeddedWorkerStatus::STARTING, version->running_status());
258 DCHECK_EQ(render_process_id_, version->embedded_worker()->process_id()); 259 DCHECK_EQ(render_process_id_, version->embedded_worker()->process_id());
259 running_hosted_version_ = version; 260 running_hosted_version_ = version;
260 } 261 }
261 262
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 ServiceWorkerMsg_MessageToDocument_Params params; 453 ServiceWorkerMsg_MessageToDocument_Params params;
453 params.thread_id = kDocumentMainThreadId; 454 params.thread_id = kDocumentMainThreadId;
454 params.provider_id = provider_id(); 455 params.provider_id = provider_id();
455 params.service_worker_info = GetOrCreateServiceWorkerHandle(version); 456 params.service_worker_info = GetOrCreateServiceWorkerHandle(version);
456 params.message = message; 457 params.message = message;
457 params.message_ports = sent_message_ports; 458 params.message_ports = sent_message_ports;
458 params.new_routing_ids = new_routing_ids; 459 params.new_routing_ids = new_routing_ids;
459 Send(new ServiceWorkerMsg_MessageToDocument(params)); 460 Send(new ServiceWorkerMsg_MessageToDocument(params));
460 } 461 }
461 462
463 void ServiceWorkerProviderHost::CountFeature(uint32_t feature) {
464 if (!dispatcher_host_)
465 return; // Could be nullptr in some tests.
466
467 // CountFeature message should be sent only for controllees.
468 DCHECK(IsProviderForClient());
469 Send(new ServiceWorkerMsg_CountFeature(render_thread_id_, provider_id(),
470 feature));
471 }
472
462 void ServiceWorkerProviderHost::AddScopedProcessReferenceToPattern( 473 void ServiceWorkerProviderHost::AddScopedProcessReferenceToPattern(
463 const GURL& pattern) { 474 const GURL& pattern) {
464 associated_patterns_.push_back(pattern); 475 associated_patterns_.push_back(pattern);
465 IncreaseProcessReference(pattern); 476 IncreaseProcessReference(pattern);
466 } 477 }
467 478
468 void ServiceWorkerProviderHost::ClaimedByRegistration( 479 void ServiceWorkerProviderHost::ClaimedByRegistration(
469 ServiceWorkerRegistration* registration) { 480 ServiceWorkerRegistration* registration) {
470 DCHECK(registration->active_version()); 481 DCHECK(registration->active_version());
471 if (registration == associated_registration_) { 482 if (registration == associated_registration_) {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 for (auto& key_registration : matching_registrations_) 735 for (auto& key_registration : matching_registrations_)
725 IncreaseProcessReference(key_registration.second->pattern()); 736 IncreaseProcessReference(key_registration.second->pattern());
726 737
727 if (associated_registration_.get()) { 738 if (associated_registration_.get()) {
728 SendAssociateRegistrationMessage(); 739 SendAssociateRegistrationMessage();
729 if (dispatcher_host_ && associated_registration_->active_version()) { 740 if (dispatcher_host_ && associated_registration_->active_version()) {
730 Send(new ServiceWorkerMsg_SetControllerServiceWorker( 741 Send(new ServiceWorkerMsg_SetControllerServiceWorker(
731 render_thread_id_, provider_id(), 742 render_thread_id_, provider_id(),
732 GetOrCreateServiceWorkerHandle( 743 GetOrCreateServiceWorkerHandle(
733 associated_registration_->active_version()), 744 associated_registration_->active_version()),
734 false /* shouldNotifyControllerChange */)); 745 false /* shouldNotifyControllerChange */,
746 associated_registration_->active_version()->used_features()));
735 } 747 }
736 } 748 }
737 } 749 }
738 750
739 } // namespace content 751 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698