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

Side by Side Diff: content/renderer/service_worker/service_worker_script_context.cc

Issue 246023007: Chromium-side plumbing for ServiceWorker -> Document postMessage (2/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added browser -> document code Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/service_worker_script_context.h" 5 #include "content/renderer/service_worker/service_worker_script_context.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/child/webmessageportchannel_impl.h" 8 #include "content/child/webmessageportchannel_impl.h"
9 #include "content/common/service_worker/service_worker_messages.h" 9 #include "content/common/service_worker/service_worker_messages.h"
10 #include "content/renderer/service_worker/embedded_worker_context_client.h" 10 #include "content/renderer/service_worker/embedded_worker_context_client.h"
(...skipping 13 matching lines...) Expand all
24 ServiceWorkerScriptContext::~ServiceWorkerScriptContext() {} 24 ServiceWorkerScriptContext::~ServiceWorkerScriptContext() {}
25 25
26 void ServiceWorkerScriptContext::OnMessageReceived( 26 void ServiceWorkerScriptContext::OnMessageReceived(
27 const IPC::Message& message) { 27 const IPC::Message& message) {
28 bool handled = true; 28 bool handled = true;
29 IPC_BEGIN_MESSAGE_MAP(ServiceWorkerScriptContext, message) 29 IPC_BEGIN_MESSAGE_MAP(ServiceWorkerScriptContext, message)
30 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ActivateEvent, OnActivateEvent) 30 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ActivateEvent, OnActivateEvent)
31 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FetchEvent, OnFetchEvent) 31 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_FetchEvent, OnFetchEvent)
32 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_InstallEvent, OnInstallEvent) 32 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_InstallEvent, OnInstallEvent)
33 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SyncEvent, OnSyncEvent) 33 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SyncEvent, OnSyncEvent)
34 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_Message, OnPostMessage) 34 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_MessageToWorker, OnPostMessage)
35 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClientDocuments, 35 IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetClientDocuments,
36 OnDidGetClientDocuments) 36 OnDidGetClientDocuments)
37 IPC_MESSAGE_UNHANDLED(handled = false) 37 IPC_MESSAGE_UNHANDLED(handled = false)
38 IPC_END_MESSAGE_MAP() 38 IPC_END_MESSAGE_MAP()
39 DCHECK(handled); 39 DCHECK(handled);
40 } 40 }
41 41
42 void ServiceWorkerScriptContext::DidHandleActivateEvent( 42 void ServiceWorkerScriptContext::DidHandleActivateEvent(
43 int request_id, 43 int request_id,
44 blink::WebServiceWorkerEventResult result) { 44 blink::WebServiceWorkerEventResult result) {
(...skipping 22 matching lines...) Expand all
67 } 67 }
68 68
69 void ServiceWorkerScriptContext::GetClientDocuments( 69 void ServiceWorkerScriptContext::GetClientDocuments(
70 blink::WebServiceWorkerClientsCallbacks* callbacks) { 70 blink::WebServiceWorkerClientsCallbacks* callbacks) {
71 DCHECK(callbacks); 71 DCHECK(callbacks);
72 int request_id = pending_clients_callbacks_.Add(callbacks); 72 int request_id = pending_clients_callbacks_.Add(callbacks);
73 Send(new ServiceWorkerHostMsg_GetClientDocuments( 73 Send(new ServiceWorkerHostMsg_GetClientDocuments(
74 GetRoutingID(), request_id)); 74 GetRoutingID(), request_id));
75 } 75 }
76 76
77 void ServiceWorkerScriptContext::PostMessageToDocument(
78 int client_id,
79 const base::string16& message,
80 const std::vector<int>& message_port_ids) {
81 Send(new ServiceWorkerHostMsg_PostMessageToDocument(
82 GetRoutingID(), client_id, message, message_port_ids));
83 }
84
77 void ServiceWorkerScriptContext::Send(IPC::Message* message) { 85 void ServiceWorkerScriptContext::Send(IPC::Message* message) {
78 embedded_context_->Send(message); 86 embedded_context_->Send(message);
79 } 87 }
80 88
81 void ServiceWorkerScriptContext::OnActivateEvent(int request_id) { 89 void ServiceWorkerScriptContext::OnActivateEvent(int request_id) {
82 proxy_->dispatchActivateEvent(request_id); 90 proxy_->dispatchActivateEvent(request_id);
83 } 91 }
84 92
85 void ServiceWorkerScriptContext::OnInstallEvent(int request_id, 93 void ServiceWorkerScriptContext::OnInstallEvent(int request_id,
86 int active_version_id) { 94 int active_version_id) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 info->clientIDs = client_ids; 136 info->clientIDs = client_ids;
129 callbacks->onSuccess(info.release()); 137 callbacks->onSuccess(info.release());
130 pending_clients_callbacks_.Remove(request_id); 138 pending_clients_callbacks_.Remove(request_id);
131 } 139 }
132 140
133 int ServiceWorkerScriptContext::GetRoutingID() const { 141 int ServiceWorkerScriptContext::GetRoutingID() const {
134 return embedded_context_->embedded_worker_id(); 142 return embedded_context_->embedded_worker_id();
135 } 143 }
136 144
137 } // namespace content 145 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698