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/browser/service_worker/service_worker_provider_host.h" | 5 #include "content/browser/service_worker/service_worker_provider_host.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "content/browser/message_port_message_filter.h" | |
14 #include "content/browser/service_worker/embedded_worker_status.h" | 13 #include "content/browser/service_worker/embedded_worker_status.h" |
15 #include "content/browser/service_worker/service_worker_context_core.h" | 14 #include "content/browser/service_worker/service_worker_context_core.h" |
16 #include "content/browser/service_worker/service_worker_context_request_handler.
h" | 15 #include "content/browser/service_worker/service_worker_context_request_handler.
h" |
17 #include "content/browser/service_worker/service_worker_controllee_request_handl
er.h" | 16 #include "content/browser/service_worker/service_worker_controllee_request_handl
er.h" |
18 #include "content/browser/service_worker/service_worker_dispatcher_host.h" | 17 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
19 #include "content/browser/service_worker/service_worker_handle.h" | 18 #include "content/browser/service_worker/service_worker_handle.h" |
20 #include "content/browser/service_worker/service_worker_registration_handle.h" | 19 #include "content/browser/service_worker/service_worker_registration_handle.h" |
21 #include "content/browser/service_worker/service_worker_version.h" | 20 #include "content/browser/service_worker/service_worker_version.h" |
22 #include "content/common/resource_request_body_impl.h" | 21 #include "content/common/resource_request_body_impl.h" |
23 #include "content/common/service_worker/service_worker_messages.h" | 22 #include "content/common/service_worker/service_worker_messages.h" |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 if (running_hosted_version_.get()) | 432 if (running_hosted_version_.get()) |
434 return false; | 433 return false; |
435 if (!registration || associated_registration_.get() || !allow_association_) | 434 if (!registration || associated_registration_.get() || !allow_association_) |
436 return false; | 435 return false; |
437 return true; | 436 return true; |
438 } | 437 } |
439 | 438 |
440 void ServiceWorkerProviderHost::PostMessageToClient( | 439 void ServiceWorkerProviderHost::PostMessageToClient( |
441 ServiceWorkerVersion* version, | 440 ServiceWorkerVersion* version, |
442 const base::string16& message, | 441 const base::string16& message, |
443 const std::vector<int>& sent_message_ports) { | 442 const std::vector<MessagePort>& sent_message_ports) { |
444 if (!dispatcher_host_) | 443 if (!dispatcher_host_) |
445 return; // Could be NULL in some tests. | 444 return; // Could be NULL in some tests. |
446 | 445 |
447 std::vector<int> new_routing_ids; | |
448 dispatcher_host_->message_port_message_filter()-> | |
449 UpdateMessagePortsWithNewRoutes(sent_message_ports, | |
450 &new_routing_ids); | |
451 | |
452 ServiceWorkerMsg_MessageToDocument_Params params; | 446 ServiceWorkerMsg_MessageToDocument_Params params; |
453 params.thread_id = kDocumentMainThreadId; | 447 params.thread_id = kDocumentMainThreadId; |
454 params.provider_id = provider_id(); | 448 params.provider_id = provider_id(); |
455 params.service_worker_info = GetOrCreateServiceWorkerHandle(version); | 449 params.service_worker_info = GetOrCreateServiceWorkerHandle(version); |
456 params.message = message; | 450 params.message = message; |
457 params.message_ports = sent_message_ports; | 451 params.message_ports = sent_message_ports; |
458 params.new_routing_ids = new_routing_ids; | |
459 Send(new ServiceWorkerMsg_MessageToDocument(params)); | 452 Send(new ServiceWorkerMsg_MessageToDocument(params)); |
460 } | 453 } |
461 | 454 |
462 void ServiceWorkerProviderHost::AddScopedProcessReferenceToPattern( | 455 void ServiceWorkerProviderHost::AddScopedProcessReferenceToPattern( |
463 const GURL& pattern) { | 456 const GURL& pattern) { |
464 associated_patterns_.push_back(pattern); | 457 associated_patterns_.push_back(pattern); |
465 IncreaseProcessReference(pattern); | 458 IncreaseProcessReference(pattern); |
466 } | 459 } |
467 | 460 |
468 void ServiceWorkerProviderHost::ClaimedByRegistration( | 461 void ServiceWorkerProviderHost::ClaimedByRegistration( |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 Send(new ServiceWorkerMsg_SetControllerServiceWorker( | 723 Send(new ServiceWorkerMsg_SetControllerServiceWorker( |
731 render_thread_id_, provider_id(), | 724 render_thread_id_, provider_id(), |
732 GetOrCreateServiceWorkerHandle( | 725 GetOrCreateServiceWorkerHandle( |
733 associated_registration_->active_version()), | 726 associated_registration_->active_version()), |
734 false /* shouldNotifyControllerChange */)); | 727 false /* shouldNotifyControllerChange */)); |
735 } | 728 } |
736 } | 729 } |
737 } | 730 } |
738 | 731 |
739 } // namespace content | 732 } // namespace content |
OLD | NEW |