Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: content/child/service_worker/service_worker_dispatcher.cc

Issue 893783002: Revert of Gather the ServiceWorker client information in the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rfh_getvisibilitystate
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerStateChanged, 77 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerStateChanged,
78 OnServiceWorkerStateChanged) 78 OnServiceWorkerStateChanged)
79 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetVersionAttributes, 79 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetVersionAttributes,
80 OnSetVersionAttributes) 80 OnSetVersionAttributes)
81 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_UpdateFound, 81 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_UpdateFound,
82 OnUpdateFound) 82 OnUpdateFound)
83 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetControllerServiceWorker, 83 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetControllerServiceWorker,
84 OnSetControllerServiceWorker) 84 OnSetControllerServiceWorker)
85 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_MessageToDocument, 85 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_MessageToDocument,
86 OnPostMessage) 86 OnPostMessage)
87 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_GetClientInfo,
88 OnGetClientInfo)
87 IPC_MESSAGE_UNHANDLED(handled = false) 89 IPC_MESSAGE_UNHANDLED(handled = false)
88 IPC_END_MESSAGE_MAP() 90 IPC_END_MESSAGE_MAP()
89 DCHECK(handled) << "Unhandled message:" << msg.type(); 91 DCHECK(handled) << "Unhandled message:" << msg.type();
90 } 92 }
91 93
92 bool ServiceWorkerDispatcher::Send(IPC::Message* msg) { 94 bool ServiceWorkerDispatcher::Send(IPC::Message* msg) {
93 return thread_safe_sender_->Send(msg); 95 return thread_safe_sender_->Send(msg);
94 } 96 }
95 97
96 void ServiceWorkerDispatcher::RegisterServiceWorker( 98 void ServiceWorkerDispatcher::RegisterServiceWorker(
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) { 656 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) {
655 ports[i] = new WebMessagePortChannelImpl( 657 ports[i] = new WebMessagePortChannelImpl(
656 new_routing_ids[i], sent_message_port_ids[i], 658 new_routing_ids[i], sent_message_port_ids[i],
657 base::MessageLoopProxy::current()); 659 base::MessageLoopProxy::current());
658 } 660 }
659 } 661 }
660 662
661 found->second->dispatchMessageEvent(message, ports); 663 found->second->dispatchMessageEvent(message, ports);
662 } 664 }
663 665
666 void ServiceWorkerDispatcher::OnGetClientInfo(int thread_id,
667 int embedded_worker_id,
668 int request_id,
669 int provider_id) {
670 blink::WebServiceWorkerClientInfo info;
671 ProviderClientMap::iterator found = provider_clients_.find(provider_id);
672 // TODO(ksakamoto): Could we track these values in the browser side? Except
673 // for |isFocused|, it would be pretty easy.
674 if (found != provider_clients_.end() && found->second->getClientInfo(&info)) {
675 ServiceWorkerClientInfo result;
676 result.client_id = info.clientID;
677 result.page_visibility_state = info.pageVisibilityState;
678 result.is_focused = info.isFocused;
679 result.url = info.url;
680 result.frame_type = static_cast<RequestContextFrameType>(info.frameType);
681
682 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetClientInfoSuccess(
683 embedded_worker_id, request_id, result));
684 } else {
685 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetClientInfoError(
686 embedded_worker_id, request_id));
687 }
688 }
689
664 void ServiceWorkerDispatcher::AddServiceWorker( 690 void ServiceWorkerDispatcher::AddServiceWorker(
665 int handle_id, WebServiceWorkerImpl* worker) { 691 int handle_id, WebServiceWorkerImpl* worker) {
666 DCHECK(!ContainsKey(service_workers_, handle_id)); 692 DCHECK(!ContainsKey(service_workers_, handle_id));
667 service_workers_[handle_id] = worker; 693 service_workers_[handle_id] = worker;
668 } 694 }
669 695
670 void ServiceWorkerDispatcher::RemoveServiceWorker(int handle_id) { 696 void ServiceWorkerDispatcher::RemoveServiceWorker(int handle_id) {
671 DCHECK(ContainsKey(service_workers_, handle_id)); 697 DCHECK(ContainsKey(service_workers_, handle_id));
672 service_workers_.erase(handle_id); 698 service_workers_.erase(handle_id);
673 } 699 }
(...skipping 29 matching lines...) Expand all
703 attrs.installing, thread_safe_sender_.get()); 729 attrs.installing, thread_safe_sender_.get());
704 ServiceWorkerHandleReference::Adopt( 730 ServiceWorkerHandleReference::Adopt(
705 attrs.waiting, thread_safe_sender_.get()); 731 attrs.waiting, thread_safe_sender_.get());
706 ServiceWorkerHandleReference::Adopt( 732 ServiceWorkerHandleReference::Adopt(
707 attrs.active, thread_safe_sender_.get()); 733 attrs.active, thread_safe_sender_.get());
708 } 734 }
709 return registration; 735 return registration;
710 } 736 }
711 737
712 } // namespace content 738 } // namespace content
OLDNEW
« no previous file with comments | « content/child/service_worker/service_worker_dispatcher.h ('k') | content/common/service_worker/service_worker_client_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698