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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
11 #include "content/child/child_thread.h" | 11 #include "content/child/child_thread.h" |
12 #include "content/child/service_worker/service_worker_handle_reference.h" | 12 #include "content/child/service_worker/service_worker_handle_reference.h" |
13 #include "content/child/service_worker/service_worker_provider_context.h" | 13 #include "content/child/service_worker/service_worker_provider_context.h" |
14 #include "content/child/service_worker/service_worker_registration_handle_refere nce.h" | 14 #include "content/child/service_worker/service_worker_registration_handle_refere nce.h" |
15 #include "content/child/service_worker/web_service_worker_impl.h" | 15 #include "content/child/service_worker/web_service_worker_impl.h" |
16 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 16 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
17 #include "content/child/thread_safe_sender.h" | 17 #include "content/child/thread_safe_sender.h" |
18 #include "content/child/webmessageportchannel_impl.h" | 18 #include "content/child/webmessageportchannel_impl.h" |
19 #include "content/common/service_worker/service_worker_messages.h" | 19 #include "content/common/service_worker/service_worker_messages.h" |
20 #include "content/public/common/url_utils.h" | 20 #include "content/public/common/url_utils.h" |
21 #include "third_party/WebKit/public/platform/WebServiceWorkerClientsInfo.h" | |
21 #include "third_party/WebKit/public/platform/WebServiceWorkerProviderClient.h" | 22 #include "third_party/WebKit/public/platform/WebServiceWorkerProviderClient.h" |
22 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 23 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
23 | 24 |
24 using blink::WebServiceWorkerError; | 25 using blink::WebServiceWorkerError; |
25 using blink::WebServiceWorkerProvider; | 26 using blink::WebServiceWorkerProvider; |
26 using base::ThreadLocalPointer; | 27 using base::ThreadLocalPointer; |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 | 30 |
30 namespace { | 31 namespace { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerStateChanged, | 73 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerStateChanged, |
73 OnServiceWorkerStateChanged) | 74 OnServiceWorkerStateChanged) |
74 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetVersionAttributes, | 75 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetVersionAttributes, |
75 OnSetVersionAttributes) | 76 OnSetVersionAttributes) |
76 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_UpdateFound, | 77 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_UpdateFound, |
77 OnUpdateFound) | 78 OnUpdateFound) |
78 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetControllerServiceWorker, | 79 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetControllerServiceWorker, |
79 OnSetControllerServiceWorker) | 80 OnSetControllerServiceWorker) |
80 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_MessageToDocument, | 81 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_MessageToDocument, |
81 OnPostMessage) | 82 OnPostMessage) |
83 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_GetClientInfo, | |
84 OnGetClientInfo) | |
82 IPC_MESSAGE_UNHANDLED(handled = false) | 85 IPC_MESSAGE_UNHANDLED(handled = false) |
83 IPC_END_MESSAGE_MAP() | 86 IPC_END_MESSAGE_MAP() |
84 DCHECK(handled) << "Unhandled message:" << msg.type(); | 87 DCHECK(handled) << "Unhandled message:" << msg.type(); |
85 } | 88 } |
86 | 89 |
87 bool ServiceWorkerDispatcher::Send(IPC::Message* msg) { | 90 bool ServiceWorkerDispatcher::Send(IPC::Message* msg) { |
88 return thread_safe_sender_->Send(msg); | 91 return thread_safe_sender_->Send(msg); |
89 } | 92 } |
90 | 93 |
91 void ServiceWorkerDispatcher::RegisterServiceWorker( | 94 void ServiceWorkerDispatcher::RegisterServiceWorker( |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
681 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) { | 684 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) { |
682 ports[i] = new WebMessagePortChannelImpl( | 685 ports[i] = new WebMessagePortChannelImpl( |
683 new_routing_ids[i], sent_message_port_ids[i], | 686 new_routing_ids[i], sent_message_port_ids[i], |
684 base::MessageLoopProxy::current()); | 687 base::MessageLoopProxy::current()); |
685 } | 688 } |
686 } | 689 } |
687 | 690 |
688 found->second->dispatchMessageEvent(message, ports); | 691 found->second->dispatchMessageEvent(message, ports); |
689 } | 692 } |
690 | 693 |
694 void ServiceWorkerDispatcher::OnGetClientInfo(int thread_id, | |
695 int embedded_worker_id, | |
696 int request_id, | |
697 int provider_id) { | |
698 blink::WebServiceWorkerClientInfo info; | |
699 ScriptClientMap::iterator found = script_clients_.find(provider_id); | |
700 if (found != script_clients_.end() && found->second->getClientInfo(&info)) { | |
701 ServiceWorkerClientInfo result; | |
702 result.client_id = info.clientID; | |
703 result.visibility_state = info.visibilityState.utf8(); | |
704 result.is_focused = info.isFocused; | |
705 result.url = info.url; | |
706 result.frame_type = static_cast<RequestContextFrameType>(info.frameType); | |
mlamouri (slow - plz ping)
2014/12/08 10:56:28
Now that ServiceWorkerProviderHost is aware of the
Kunihiko Sakamoto
2014/12/09 02:05:43
We have URL in browser process, and it'd be easy t
dcheng
2014/12/10 06:37:52
re focused:
We definitely don't have enough browse
Kunihiko Sakamoto
2014/12/10 09:10:47
Thanks for the info. Added a TODO comment so that
| |
707 | |
708 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetClientInfoSuccess( | |
709 embedded_worker_id, request_id, result)); | |
710 } else { | |
711 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetClientInfoError( | |
712 embedded_worker_id, request_id)); | |
713 } | |
714 } | |
715 | |
691 void ServiceWorkerDispatcher::AddServiceWorker( | 716 void ServiceWorkerDispatcher::AddServiceWorker( |
692 int handle_id, WebServiceWorkerImpl* worker) { | 717 int handle_id, WebServiceWorkerImpl* worker) { |
693 DCHECK(!ContainsKey(service_workers_, handle_id)); | 718 DCHECK(!ContainsKey(service_workers_, handle_id)); |
694 service_workers_[handle_id] = worker; | 719 service_workers_[handle_id] = worker; |
695 } | 720 } |
696 | 721 |
697 void ServiceWorkerDispatcher::RemoveServiceWorker(int handle_id) { | 722 void ServiceWorkerDispatcher::RemoveServiceWorker(int handle_id) { |
698 DCHECK(ContainsKey(service_workers_, handle_id)); | 723 DCHECK(ContainsKey(service_workers_, handle_id)); |
699 service_workers_.erase(handle_id); | 724 service_workers_.erase(handle_id); |
700 } | 725 } |
(...skipping 29 matching lines...) Expand all Loading... | |
730 attrs.installing, thread_safe_sender_.get()); | 755 attrs.installing, thread_safe_sender_.get()); |
731 ServiceWorkerHandleReference::Adopt( | 756 ServiceWorkerHandleReference::Adopt( |
732 attrs.waiting, thread_safe_sender_.get()); | 757 attrs.waiting, thread_safe_sender_.get()); |
733 ServiceWorkerHandleReference::Adopt( | 758 ServiceWorkerHandleReference::Adopt( |
734 attrs.active, thread_safe_sender_.get()); | 759 attrs.active, thread_safe_sender_.get()); |
735 } | 760 } |
736 return registration; | 761 return registration; |
737 } | 762 } |
738 | 763 |
739 } // namespace content | 764 } // namespace content |
OLD | NEW |