| OLD | NEW |
| 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/renderer/service_worker/embedded_worker_context_client.h" | 5 #include "content/renderer/service_worker/embedded_worker_context_client.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
| 12 #include "base/pickle.h" | 12 #include "base/pickle.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/threading/thread_local.h" | 15 #include "base/threading/thread_local.h" |
| 16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 17 #include "content/child/request_extra_data.h" | 17 #include "content/child/request_extra_data.h" |
| 18 #include "content/child/service_worker/service_worker_dispatcher.h" | 18 #include "content/child/service_worker/service_worker_dispatcher.h" |
| 19 #include "content/child/service_worker/service_worker_network_provider.h" | 19 #include "content/child/service_worker/service_worker_network_provider.h" |
| 20 #include "content/child/service_worker/service_worker_provider_context.h" | 20 #include "content/child/service_worker/service_worker_provider_context.h" |
| 21 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" | 21 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" |
| 22 #include "content/child/service_worker/web_service_worker_impl.h" | 22 #include "content/child/service_worker/web_service_worker_impl.h" |
| 23 #include "content/child/service_worker/web_service_worker_provider_impl.h" |
| 23 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 24 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
| 24 #include "content/child/thread_safe_sender.h" | 25 #include "content/child/thread_safe_sender.h" |
| 25 #include "content/child/worker_task_runner.h" | 26 #include "content/child/worker_task_runner.h" |
| 26 #include "content/child/worker_thread_task_runner.h" | 27 #include "content/child/worker_thread_task_runner.h" |
| 27 #include "content/common/devtools_messages.h" | 28 #include "content/common/devtools_messages.h" |
| 28 #include "content/common/service_worker/embedded_worker_messages.h" | 29 #include "content/common/service_worker/embedded_worker_messages.h" |
| 29 #include "content/common/service_worker/service_worker_types.h" | 30 #include "content/common/service_worker/service_worker_types.h" |
| 30 #include "content/public/renderer/document_state.h" | 31 #include "content/public/renderer/document_state.h" |
| 31 #include "content/renderer/devtools/devtools_agent.h" | 32 #include "content/renderer/devtools/devtools_agent.h" |
| 32 #include "content/renderer/render_thread_impl.h" | 33 #include "content/renderer/render_thread_impl.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 // and ownership is transferred to the DataSource. | 356 // and ownership is transferred to the DataSource. |
| 356 DataSourceExtraData* extra_data = new DataSourceExtraData(); | 357 DataSourceExtraData* extra_data = new DataSourceExtraData(); |
| 357 data_source->setExtraData(extra_data); | 358 data_source->setExtraData(extra_data); |
| 358 ServiceWorkerNetworkProvider::AttachToDocumentState( | 359 ServiceWorkerNetworkProvider::AttachToDocumentState( |
| 359 extra_data, provider.Pass()); | 360 extra_data, provider.Pass()); |
| 360 | 361 |
| 361 // Blink is responsible for deleting the returned object. | 362 // Blink is responsible for deleting the returned object. |
| 362 return new WebServiceWorkerNetworkProviderImpl(); | 363 return new WebServiceWorkerNetworkProviderImpl(); |
| 363 } | 364 } |
| 364 | 365 |
| 366 blink::WebServiceWorkerProvider* |
| 367 EmbeddedWorkerContextClient::createServiceWorkerProvider() { |
| 368 DCHECK(main_thread_proxy_->RunsTasksOnCurrentThread()); |
| 369 DCHECK(provider_context_); |
| 370 |
| 371 // Blink is responsible for deleting the returned object. |
| 372 return new WebServiceWorkerProviderImpl( |
| 373 thread_safe_sender(), provider_context_.get()); |
| 374 } |
| 375 |
| 365 void EmbeddedWorkerContextClient::postMessageToClient( | 376 void EmbeddedWorkerContextClient::postMessageToClient( |
| 366 int client_id, | 377 int client_id, |
| 367 const blink::WebString& message, | 378 const blink::WebString& message, |
| 368 blink::WebMessagePortChannelArray* channels) { | 379 blink::WebMessagePortChannelArray* channels) { |
| 369 DCHECK(script_context_); | 380 DCHECK(script_context_); |
| 370 script_context_->PostMessageToDocument(client_id, message, | 381 script_context_->PostMessageToDocument(client_id, message, |
| 371 make_scoped_ptr(channels)); | 382 make_scoped_ptr(channels)); |
| 372 } | 383 } |
| 373 | 384 |
| 374 void EmbeddedWorkerContextClient::postMessageToCrossOriginClient( | 385 void EmbeddedWorkerContextClient::postMessageToCrossOriginClient( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 registration->SetWaiting( | 446 registration->SetWaiting( |
| 436 dispatcher->GetServiceWorker(attrs.waiting, false)); | 447 dispatcher->GetServiceWorker(attrs.waiting, false)); |
| 437 registration->SetActive( | 448 registration->SetActive( |
| 438 dispatcher->GetServiceWorker(attrs.active, false)); | 449 dispatcher->GetServiceWorker(attrs.active, false)); |
| 439 | 450 |
| 440 script_context_->SetRegistrationInServiceWorkerGlobalScope( | 451 script_context_->SetRegistrationInServiceWorkerGlobalScope( |
| 441 registration.Pass()); | 452 registration.Pass()); |
| 442 } | 453 } |
| 443 | 454 |
| 444 } // namespace content | 455 } // namespace content |
| OLD | NEW |