OLD | NEW |
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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); | 345 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); |
346 DCHECK(!proxy_); | 346 DCHECK(!proxy_); |
347 g_worker_client_tls.Pointer()->Set(this); | 347 g_worker_client_tls.Pointer()->Set(this); |
348 proxy_ = proxy; | 348 proxy_ = proxy; |
349 | 349 |
350 // Initialize pending callback maps. This needs to be freed on the | 350 // Initialize pending callback maps. This needs to be freed on the |
351 // same thread before the worker context goes away in | 351 // same thread before the worker context goes away in |
352 // willDestroyWorkerContext. | 352 // willDestroyWorkerContext. |
353 context_.reset(new WorkerContextData(this)); | 353 context_.reset(new WorkerContextData(this)); |
354 | 354 |
| 355 ServiceWorkerRegistrationObjectInfo registration_info; |
| 356 ServiceWorkerVersionAttributes version_attrs; |
| 357 provider_context_->GetRegistrationInfoAndVersionAttributes(®istration_info, |
| 358 &version_attrs); |
| 359 DCHECK_NE(registration_info.registration_id, |
| 360 kInvalidServiceWorkerRegistrationId); |
| 361 |
355 // Register Mojo services. | 362 // Register Mojo services. |
356 context_->service_registry.ServiceRegistry::AddService( | 363 context_->service_registry.ServiceRegistry::AddService( |
357 base::Bind(&ServicePortDispatcherImpl::Create, | 364 base::Bind(&ServicePortDispatcherImpl::Create, |
358 context_->proxy_weak_factory.GetWeakPtr())); | 365 context_->proxy_weak_factory.GetWeakPtr())); |
359 context_->service_registry.ServiceRegistry::AddService( | 366 context_->service_registry.ServiceRegistry::AddService(base::Bind( |
360 base::Bind(&BackgroundSyncClientImpl::Create)); | 367 &BackgroundSyncClientImpl::Create, registration_info.registration_id)); |
361 | 368 |
362 SetRegistrationInServiceWorkerGlobalScope(); | 369 SetRegistrationInServiceWorkerGlobalScope(); |
363 | 370 |
364 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoaded( | 371 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoaded( |
365 embedded_worker_id_, WorkerThread::GetCurrentId(), | 372 embedded_worker_id_, WorkerThread::GetCurrentId(), |
366 provider_context_->provider_id())); | 373 provider_context_->provider_id())); |
367 | 374 |
368 TRACE_EVENT_ASYNC_STEP_INTO0( | 375 TRACE_EVENT_ASYNC_STEP_INTO0( |
369 "ServiceWorker", | 376 "ServiceWorker", |
370 "ServiceWorkerContextClient::StartingWorkerContext", | 377 "ServiceWorkerContextClient::StartingWorkerContext", |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 } | 972 } |
966 | 973 |
967 base::WeakPtr<ServiceWorkerContextClient> | 974 base::WeakPtr<ServiceWorkerContextClient> |
968 ServiceWorkerContextClient::GetWeakPtr() { | 975 ServiceWorkerContextClient::GetWeakPtr() { |
969 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 976 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
970 DCHECK(context_); | 977 DCHECK(context_); |
971 return context_->weak_factory.GetWeakPtr(); | 978 return context_->weak_factory.GetWeakPtr(); |
972 } | 979 } |
973 | 980 |
974 } // namespace content | 981 } // namespace content |
OLD | NEW |