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

Side by Side Diff: content/renderer/service_worker/service_worker_context_client.cc

Issue 1344783002: ServiceWorker: Carve out methods of ServiceWorkerProviderContext to delegate classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add class comments more Created 5 years, 2 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
« no previous file with comments | « content/renderer/service_worker/service_worker_context_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/renderer/service_worker/service_worker_context_client.h" 5 #include "content/renderer/service_worker/service_worker_context_client.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 g_worker_client_tls.Pointer()->Set(this); 353 g_worker_client_tls.Pointer()->Set(this);
354 proxy_ = proxy; 354 proxy_ = proxy;
355 355
356 // Initialize pending callback maps. This needs to be freed on the 356 // Initialize pending callback maps. This needs to be freed on the
357 // same thread before the worker context goes away in 357 // same thread before the worker context goes away in
358 // willDestroyWorkerContext. 358 // willDestroyWorkerContext.
359 context_.reset(new WorkerContextData(this)); 359 context_.reset(new WorkerContextData(this));
360 360
361 ServiceWorkerRegistrationObjectInfo registration_info; 361 ServiceWorkerRegistrationObjectInfo registration_info;
362 ServiceWorkerVersionAttributes version_attrs; 362 ServiceWorkerVersionAttributes version_attrs;
363 provider_context_->GetRegistrationInfoAndVersionAttributes(&registration_info, 363 provider_context_->GetAssociatedRegistration(&registration_info,
364 &version_attrs); 364 &version_attrs);
365 DCHECK_NE(registration_info.registration_id, 365 DCHECK_NE(registration_info.registration_id,
366 kInvalidServiceWorkerRegistrationId); 366 kInvalidServiceWorkerRegistrationId);
367 367
368 // Register Mojo services. 368 // Register Mojo services.
369 context_->service_registry.ServiceRegistry::AddService( 369 context_->service_registry.ServiceRegistry::AddService(
370 base::Bind(&ServicePortDispatcherImpl::Create, 370 base::Bind(&ServicePortDispatcherImpl::Create,
371 context_->proxy_weak_factory.GetWeakPtr())); 371 context_->proxy_weak_factory.GetWeakPtr()));
372 context_->service_registry.ServiceRegistry::AddService(base::Bind( 372 context_->service_registry.ServiceRegistry::AddService(base::Bind(
373 &BackgroundSyncClientImpl::Create, registration_info.registration_id)); 373 &BackgroundSyncClientImpl::Create, registration_info.registration_id));
374 374
375 SetRegistrationInServiceWorkerGlobalScope(); 375 SetRegistrationInServiceWorkerGlobalScope(registration_info, version_attrs);
376 376
377 Send(new EmbeddedWorkerHostMsg_WorkerThreadStarted( 377 Send(new EmbeddedWorkerHostMsg_WorkerThreadStarted(
378 embedded_worker_id_, WorkerThread::GetCurrentId(), 378 embedded_worker_id_, WorkerThread::GetCurrentId(),
379 provider_context_->provider_id())); 379 provider_context_->provider_id()));
380 380
381 TRACE_EVENT_ASYNC_STEP_INTO0( 381 TRACE_EVENT_ASYNC_STEP_INTO0(
382 "ServiceWorker", 382 "ServiceWorker",
383 "ServiceWorkerContextClient::StartingWorkerContext", 383 "ServiceWorkerContextClient::StartingWorkerContext",
384 this, 384 this,
385 "ExecuteScript"); 385 "ExecuteScript");
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 } 664 }
665 665
666 void ServiceWorkerContextClient::SendWorkerStarted() { 666 void ServiceWorkerContextClient::SendWorkerStarted() {
667 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 667 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
668 TRACE_EVENT_ASYNC_END0("ServiceWorker", 668 TRACE_EVENT_ASYNC_END0("ServiceWorker",
669 "ServiceWorkerContextClient::StartingWorkerContext", 669 "ServiceWorkerContextClient::StartingWorkerContext",
670 this); 670 this);
671 Send(new EmbeddedWorkerHostMsg_WorkerStarted(embedded_worker_id_)); 671 Send(new EmbeddedWorkerHostMsg_WorkerStarted(embedded_worker_id_));
672 } 672 }
673 673
674 void ServiceWorkerContextClient::SetRegistrationInServiceWorkerGlobalScope() { 674 void ServiceWorkerContextClient::SetRegistrationInServiceWorkerGlobalScope(
675 const ServiceWorkerRegistrationObjectInfo& info,
676 const ServiceWorkerVersionAttributes& attrs) {
675 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 677 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
676 DCHECK(provider_context_);
677
678 ServiceWorkerRegistrationObjectInfo info;
679 ServiceWorkerVersionAttributes attrs;
680 bool found =
681 provider_context_->GetRegistrationInfoAndVersionAttributes(&info, &attrs);
682 if (!found)
683 return; // Cannot be associated with a registration in some tests.
684
685 ServiceWorkerDispatcher* dispatcher = 678 ServiceWorkerDispatcher* dispatcher =
686 ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance( 679 ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance(
687 sender_.get(), main_thread_task_runner_.get()); 680 sender_.get(), main_thread_task_runner_.get());
688 681
689 // Register a registration and its version attributes with the dispatcher 682 // Register a registration and its version attributes with the dispatcher
690 // living on the worker thread. 683 // living on the worker thread.
691 scoped_refptr<WebServiceWorkerRegistrationImpl> registration( 684 scoped_refptr<WebServiceWorkerRegistrationImpl> registration(
692 dispatcher->GetOrCreateRegistration(info, attrs)); 685 dispatcher->GetOrCreateRegistration(info, attrs));
693 686
694 proxy_->setRegistration(registration->CreateHandle()); 687 proxy_->setRegistration(registration->CreateHandle());
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 } 972 }
980 973
981 base::WeakPtr<ServiceWorkerContextClient> 974 base::WeakPtr<ServiceWorkerContextClient>
982 ServiceWorkerContextClient::GetWeakPtr() { 975 ServiceWorkerContextClient::GetWeakPtr() {
983 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 976 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
984 DCHECK(context_); 977 DCHECK(context_);
985 return context_->weak_factory.GetWeakPtr(); 978 return context_->weak_factory.GetWeakPtr();
986 } 979 }
987 980
988 } // namespace content 981 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/service_worker/service_worker_context_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698