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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 void ServiceWorkerContextClient::workerContextFailedToStart() { | 328 void ServiceWorkerContextClient::workerContextFailedToStart() { |
329 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | 329 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
330 DCHECK(!proxy_); | 330 DCHECK(!proxy_); |
331 | 331 |
332 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoadFailed(embedded_worker_id_)); | 332 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoadFailed(embedded_worker_id_)); |
333 | 333 |
334 RenderThreadImpl::current()->embedded_worker_dispatcher()-> | 334 RenderThreadImpl::current()->embedded_worker_dispatcher()-> |
335 WorkerContextDestroyed(embedded_worker_id_); | 335 WorkerContextDestroyed(embedded_worker_id_); |
336 } | 336 } |
337 | 337 |
| 338 void ServiceWorkerContextClient::workerScriptLoaded() { |
| 339 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
| 340 DCHECK(!proxy_); |
| 341 |
| 342 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoaded(embedded_worker_id_)); |
| 343 } |
| 344 |
338 void ServiceWorkerContextClient::workerContextStarted( | 345 void ServiceWorkerContextClient::workerContextStarted( |
339 blink::WebServiceWorkerContextProxy* proxy) { | 346 blink::WebServiceWorkerContextProxy* proxy) { |
340 DCHECK(!worker_task_runner_.get()); | 347 DCHECK(!worker_task_runner_.get()); |
341 DCHECK_NE(0, WorkerThread::GetCurrentId()); | 348 DCHECK_NE(0, WorkerThread::GetCurrentId()); |
342 worker_task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 349 worker_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
343 // g_worker_client_tls.Pointer()->Get() could return NULL if this context | 350 // g_worker_client_tls.Pointer()->Get() could return NULL if this context |
344 // gets deleted before workerContextStarted() is called. | 351 // gets deleted before workerContextStarted() is called. |
345 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); | 352 DCHECK(g_worker_client_tls.Pointer()->Get() == NULL); |
346 DCHECK(!proxy_); | 353 DCHECK(!proxy_); |
347 g_worker_client_tls.Pointer()->Set(this); | 354 g_worker_client_tls.Pointer()->Set(this); |
(...skipping 13 matching lines...) Expand all Loading... |
361 | 368 |
362 // Register Mojo services. | 369 // Register Mojo services. |
363 context_->service_registry.ServiceRegistry::AddService( | 370 context_->service_registry.ServiceRegistry::AddService( |
364 base::Bind(&ServicePortDispatcherImpl::Create, | 371 base::Bind(&ServicePortDispatcherImpl::Create, |
365 context_->proxy_weak_factory.GetWeakPtr())); | 372 context_->proxy_weak_factory.GetWeakPtr())); |
366 context_->service_registry.ServiceRegistry::AddService(base::Bind( | 373 context_->service_registry.ServiceRegistry::AddService(base::Bind( |
367 &BackgroundSyncClientImpl::Create, registration_info.registration_id)); | 374 &BackgroundSyncClientImpl::Create, registration_info.registration_id)); |
368 | 375 |
369 SetRegistrationInServiceWorkerGlobalScope(); | 376 SetRegistrationInServiceWorkerGlobalScope(); |
370 | 377 |
371 Send(new EmbeddedWorkerHostMsg_WorkerScriptLoaded( | 378 Send(new EmbeddedWorkerHostMsg_WorkerThreadStarted( |
372 embedded_worker_id_, WorkerThread::GetCurrentId(), | 379 embedded_worker_id_, WorkerThread::GetCurrentId(), |
373 provider_context_->provider_id())); | 380 provider_context_->provider_id())); |
374 | 381 |
375 TRACE_EVENT_ASYNC_STEP_INTO0( | 382 TRACE_EVENT_ASYNC_STEP_INTO0( |
376 "ServiceWorker", | 383 "ServiceWorker", |
377 "ServiceWorkerContextClient::StartingWorkerContext", | 384 "ServiceWorkerContextClient::StartingWorkerContext", |
378 this, | 385 this, |
379 "ExecuteScript"); | 386 "ExecuteScript"); |
380 } | 387 } |
381 | 388 |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 } | 985 } |
979 | 986 |
980 base::WeakPtr<ServiceWorkerContextClient> | 987 base::WeakPtr<ServiceWorkerContextClient> |
981 ServiceWorkerContextClient::GetWeakPtr() { | 988 ServiceWorkerContextClient::GetWeakPtr() { |
982 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 989 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
983 DCHECK(context_); | 990 DCHECK(context_); |
984 return context_->weak_factory.GetWeakPtr(); | 991 return context_->weak_factory.GetWeakPtr(); |
985 } | 992 } |
986 | 993 |
987 } // namespace content | 994 } // namespace content |
OLD | NEW |