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

Unified Diff: content/child/webmessageportchannel_impl.cc

Issue 189253002: Implement ServiceWorker::postMessage() [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename message handler per review feedback Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/webmessageportchannel_impl.h ('k') | content/common/service_worker/service_worker_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webmessageportchannel_impl.cc
diff --git a/content/child/webmessageportchannel_impl.cc b/content/child/webmessageportchannel_impl.cc
index cf439cc0742851de8270d70f228bf20b1e86f20c..17b7b16f30802421874f56db24ecf1c901921241 100644
--- a/content/child/webmessageportchannel_impl.cc
+++ b/content/child/webmessageportchannel_impl.cc
@@ -59,6 +59,25 @@ WebMessagePortChannelImpl::~WebMessagePortChannelImpl() {
ChildThread::current()->GetRouter()->RemoveRoute(route_id_);
}
+// static
+std::vector<int> WebMessagePortChannelImpl::ExtractMessagePortIDs(
+ WebMessagePortChannelArray* channels) {
+ std::vector<int> message_port_ids;
+ if (channels) {
+ message_port_ids.resize(channels->size());
+ // Extract the port IDs from the source array, then free it.
+ for (size_t i = 0; i < channels->size(); ++i) {
+ WebMessagePortChannelImpl* webchannel =
+ static_cast<WebMessagePortChannelImpl*>((*channels)[i]);
+ message_port_ids[i] = webchannel->message_port_id();
+ webchannel->QueueMessages();
+ DCHECK(message_port_ids[i] != MSG_ROUTING_NONE);
+ }
+ delete channels;
+ }
+ return message_port_ids;
+}
+
void WebMessagePortChannelImpl::setClient(WebMessagePortChannelClient* client) {
// Must lock here since client_ is called on the main thread.
base::AutoLock auto_lock(lock_);
@@ -98,21 +117,8 @@ void WebMessagePortChannelImpl::postMessage(
void WebMessagePortChannelImpl::PostMessage(
const base::string16& message,
WebMessagePortChannelArray* channels) {
- std::vector<int> message_port_ids(channels ? channels->size() : 0);
- if (channels) {
- // Extract the port IDs from the source array, then free it.
- for (size_t i = 0; i < channels->size(); ++i) {
- WebMessagePortChannelImpl* webchannel =
- static_cast<WebMessagePortChannelImpl*>((*channels)[i]);
- message_port_ids[i] = webchannel->message_port_id();
- webchannel->QueueMessages();
- DCHECK(message_port_ids[i] != MSG_ROUTING_NONE);
- }
- delete channels;
- }
-
IPC::Message* msg = new MessagePortHostMsg_PostMessage(
- message_port_id_, message, message_port_ids);
+ message_port_id_, message, ExtractMessagePortIDs(channels));
Send(msg);
}
« no previous file with comments | « content/child/webmessageportchannel_impl.h ('k') | content/common/service_worker/service_worker_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698