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/child/service_worker/service_worker_dispatcher.h" | 5 #include "content/child/service_worker/service_worker_dispatcher.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/threading/thread_local.h" | 9 #include "base/threading/thread_local.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 // Populate the .controller field with the new worker object. | 625 // Populate the .controller field with the new worker object. |
626 found->second->setController(GetServiceWorker(info, false), | 626 found->second->setController(GetServiceWorker(info, false), |
627 should_notify_controllerchange); | 627 should_notify_controllerchange); |
628 } | 628 } |
629 } | 629 } |
630 | 630 |
631 void ServiceWorkerDispatcher::OnPostMessage( | 631 void ServiceWorkerDispatcher::OnPostMessage( |
632 int thread_id, | 632 int thread_id, |
633 int provider_id, | 633 int provider_id, |
634 const base::string16& message, | 634 const base::string16& message, |
635 const std::vector<int>& sent_message_port_ids, | 635 const std::vector<TransferredMessagePort>& sent_message_ports, |
636 const std::vector<int>& new_routing_ids) { | 636 const std::vector<int>& new_routing_ids) { |
637 // Make sure we're on the main document thread. (That must be the only | 637 // Make sure we're on the main document thread. (That must be the only |
638 // thread we get this message) | 638 // thread we get this message) |
639 DCHECK(ChildThreadImpl::current()); | 639 DCHECK(ChildThreadImpl::current()); |
640 TRACE_EVENT1("ServiceWorker", | 640 TRACE_EVENT1("ServiceWorker", |
641 "ServiceWorkerDispatcher::OnPostMessage", | 641 "ServiceWorkerDispatcher::OnPostMessage", |
642 "Thread ID", thread_id); | 642 "Thread ID", thread_id); |
643 | 643 |
644 ProviderClientMap::iterator found = provider_clients_.find(provider_id); | 644 ProviderClientMap::iterator found = provider_clients_.find(provider_id); |
645 if (found == provider_clients_.end()) { | 645 if (found == provider_clients_.end()) { |
646 // For now we do no queueing for messages sent to nonexistent / unattached | 646 // For now we do no queueing for messages sent to nonexistent / unattached |
647 // client. | 647 // client. |
648 return; | 648 return; |
649 } | 649 } |
650 | 650 |
651 std::vector<WebMessagePortChannelImpl*> ports; | 651 blink::WebMessagePortChannelArray ports = |
652 if (!sent_message_port_ids.empty()) { | 652 WebMessagePortChannelImpl::CreatePorts(sent_message_ports, |
653 ports.resize(sent_message_port_ids.size()); | 653 new_routing_ids, |
654 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) { | 654 base::MessageLoopProxy::current()); |
655 ports[i] = new WebMessagePortChannelImpl( | |
656 new_routing_ids[i], sent_message_port_ids[i], | |
657 base::MessageLoopProxy::current()); | |
658 } | |
659 } | |
660 | 655 |
661 found->second->dispatchMessageEvent(message, ports); | 656 found->second->dispatchMessageEvent(message, ports); |
662 } | 657 } |
663 | 658 |
664 void ServiceWorkerDispatcher::AddServiceWorker( | 659 void ServiceWorkerDispatcher::AddServiceWorker( |
665 int handle_id, WebServiceWorkerImpl* worker) { | 660 int handle_id, WebServiceWorkerImpl* worker) { |
666 DCHECK(!ContainsKey(service_workers_, handle_id)); | 661 DCHECK(!ContainsKey(service_workers_, handle_id)); |
667 service_workers_[handle_id] = worker; | 662 service_workers_[handle_id] = worker; |
668 } | 663 } |
669 | 664 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 attrs.installing, thread_safe_sender_.get()); | 698 attrs.installing, thread_safe_sender_.get()); |
704 ServiceWorkerHandleReference::Adopt( | 699 ServiceWorkerHandleReference::Adopt( |
705 attrs.waiting, thread_safe_sender_.get()); | 700 attrs.waiting, thread_safe_sender_.get()); |
706 ServiceWorkerHandleReference::Adopt( | 701 ServiceWorkerHandleReference::Adopt( |
707 attrs.active, thread_safe_sender_.get()); | 702 attrs.active, thread_safe_sender_.get()); |
708 } | 703 } |
709 return registration; | 704 return registration; |
710 } | 705 } |
711 | 706 |
712 } // namespace content | 707 } // namespace content |
OLD | NEW |