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 13 matching lines...) Expand all Loading... |
24 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 24 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
25 #include "content/child/thread_safe_sender.h" | 25 #include "content/child/thread_safe_sender.h" |
26 #include "content/child/webmessageportchannel_impl.h" | 26 #include "content/child/webmessageportchannel_impl.h" |
27 #include "content/child/worker_task_runner.h" | 27 #include "content/child/worker_task_runner.h" |
28 #include "content/common/devtools_messages.h" | 28 #include "content/common/devtools_messages.h" |
29 #include "content/common/message_port_messages.h" | 29 #include "content/common/message_port_messages.h" |
30 #include "content/common/mojo/service_registry_impl.h" | 30 #include "content/common/mojo/service_registry_impl.h" |
31 #include "content/common/service_worker/embedded_worker_messages.h" | 31 #include "content/common/service_worker/embedded_worker_messages.h" |
32 #include "content/common/service_worker/service_worker_messages.h" | 32 #include "content/common/service_worker/service_worker_messages.h" |
33 #include "content/public/common/referrer.h" | 33 #include "content/public/common/referrer.h" |
| 34 #include "content/public/renderer/content_renderer_client.h" |
34 #include "content/public/renderer/document_state.h" | 35 #include "content/public/renderer/document_state.h" |
35 #include "content/renderer/background_sync/background_sync_client_impl.h" | 36 #include "content/renderer/background_sync/background_sync_client_impl.h" |
36 #include "content/renderer/devtools/devtools_agent.h" | 37 #include "content/renderer/devtools/devtools_agent.h" |
37 #include "content/renderer/render_thread_impl.h" | 38 #include "content/renderer/render_thread_impl.h" |
38 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" | 39 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
39 #include "content/renderer/service_worker/service_worker_type_util.h" | 40 #include "content/renderer/service_worker/service_worker_type_util.h" |
40 #include "ipc/ipc_message.h" | 41 #include "ipc/ipc_message.h" |
41 #include "ipc/ipc_message_macros.h" | 42 #include "ipc/ipc_message_macros.h" |
42 #include "third_party/WebKit/public/platform/WebCrossOriginServiceWorkerClient.h
" | 43 #include "third_party/WebKit/public/platform/WebCrossOriginServiceWorkerClient.h
" |
43 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" | 44 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 embedded_worker_id_, success)); | 373 embedded_worker_id_, success)); |
373 | 374 |
374 // Schedule a task to send back WorkerStarted asynchronously, | 375 // Schedule a task to send back WorkerStarted asynchronously, |
375 // so that at the time we send it we can be sure that the | 376 // so that at the time we send it we can be sure that the |
376 // worker run loop has been started. | 377 // worker run loop has been started. |
377 worker_task_runner_->PostTask( | 378 worker_task_runner_->PostTask( |
378 FROM_HERE, base::Bind(&ServiceWorkerContextClient::SendWorkerStarted, | 379 FROM_HERE, base::Bind(&ServiceWorkerContextClient::SendWorkerStarted, |
379 GetWeakPtr())); | 380 GetWeakPtr())); |
380 } | 381 } |
381 | 382 |
| 383 void ServiceWorkerContextClient::didInitializeWorkerContext( |
| 384 v8::Local<v8::Context> context, |
| 385 const blink::WebURL& url) { |
| 386 GetContentClient() |
| 387 ->renderer() |
| 388 ->DidInitializeServiceWorkerContextOnWorkerThread(context, GURL(url)); |
| 389 } |
| 390 |
382 void ServiceWorkerContextClient::willDestroyWorkerContext() { | 391 void ServiceWorkerContextClient::willDestroyWorkerContext() { |
383 // At this point OnWorkerRunLoopStopped is already called, so | 392 // At this point OnWorkerRunLoopStopped is already called, so |
384 // worker_task_runner_->RunsTasksOnCurrentThread() returns false | 393 // worker_task_runner_->RunsTasksOnCurrentThread() returns false |
385 // (while we're still on the worker thread). | 394 // (while we're still on the worker thread). |
386 proxy_ = NULL; | 395 proxy_ = NULL; |
387 | 396 |
388 // We have to clear callbacks now, as they need to be freed on the | 397 // We have to clear callbacks now, as they need to be freed on the |
389 // same thread. | 398 // same thread. |
390 context_.reset(); | 399 context_.reset(); |
391 | 400 |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 } | 967 } |
959 | 968 |
960 base::WeakPtr<ServiceWorkerContextClient> | 969 base::WeakPtr<ServiceWorkerContextClient> |
961 ServiceWorkerContextClient::GetWeakPtr() { | 970 ServiceWorkerContextClient::GetWeakPtr() { |
962 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 971 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
963 DCHECK(context_); | 972 DCHECK(context_); |
964 return context_->weak_factory.GetWeakPtr(); | 973 return context_->weak_factory.GetWeakPtr(); |
965 } | 974 } |
966 | 975 |
967 } // namespace content | 976 } // namespace content |
OLD | NEW |