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

Unified Diff: content/renderer/webworker_proxy.cc

Issue 7477027: Support Transferable objects (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebase. Created 9 years, 4 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/renderer/webworker_proxy.h ('k') | content/worker/webworker_stub.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/webworker_proxy.cc
diff --git a/content/renderer/webworker_proxy.cc b/content/renderer/webworker_proxy.cc
index 1457be7f8d3a953116aa5edc5a064116cfe88f5c..0dd897e6b8ac27f5d18f5705973fd52f905d1311 100644
--- a/content/renderer/webworker_proxy.cc
+++ b/content/renderer/webworker_proxy.cc
@@ -10,12 +10,14 @@
#include "content/common/webmessageportchannel_impl.h"
#include "content/common/worker_messages.h"
#include "content/renderer/worker_devtools_agent_proxy.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptValue.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerClient.h"
using WebKit::WebCommonWorkerClient;
using WebKit::WebMessagePortChannel;
-using WebKit::WebMessagePortChannelArray;
+using WebKit::WebTransferableReceiptArray;
+using WebKit::WebSerializedScriptValue;
using WebKit::WebString;
using WebKit::WebURL;
using WebKit::WebWorkerClient;
@@ -67,18 +69,37 @@ void WebWorkerProxy::terminateWorkerContext() {
}
void WebWorkerProxy::postMessageToWorkerContext(
- const WebString& message, const WebMessagePortChannelArray& channels) {
- std::vector<int> message_port_ids(channels.size());
- std::vector<int> routing_ids(channels.size());
- 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();
- routing_ids[i] = MSG_ROUTING_NONE;
- DCHECK(message_port_ids[i] != MSG_ROUTING_NONE);
+ const WebString& raw_message,
+ const WebTransferableReceiptArray& receipts) {
+ size_t unflattenable_count;
+#ifndef WebTransferableReceipt_h
+ WebString message = raw_message;
+ unflattenable_count = receipts.size();
+#else
+ WebString message = WebSerializedScriptValue::flattenReceiptList(
+ raw_message, receipts, &unflattenable_count);
+#endif
+ std::vector<int> message_port_ids(unflattenable_count);
+ std::vector<int> routing_ids(unflattenable_count);
+ size_t next_unflattenable = 0;
+ for (size_t i = 0; i < receipts.size(); ++i) {
+#ifndef WebTransferableReceipt_h
+ {
+#else
+ if (!receipts[i]->isFlattenable()) {
+ DCHECK(receipts[i]->asWebMessagePortChannel());
+#endif
+ DCHECK(next_unflattenable < unflattenable_count);
+ WebMessagePortChannelImpl* webchannel =
+ static_cast<WebMessagePortChannelImpl*>(receipts[i]);
+ message_port_ids[next_unflattenable] = webchannel->message_port_id();
+ webchannel->QueueMessages();
+ routing_ids[next_unflattenable] = MSG_ROUTING_NONE;
+ DCHECK(message_port_ids[next_unflattenable] != MSG_ROUTING_NONE);
+ ++next_unflattenable;
+ }
}
-
+ DCHECK(next_unflattenable == unflattenable_count);
Send(new WorkerMsg_PostMessage(
route_id_, message, message_port_ids, routing_ids));
}
@@ -144,13 +165,13 @@ void WebWorkerProxy::OnPostMessage(
const std::vector<int>& sent_message_port_ids,
const std::vector<int>& new_routing_ids) {
DCHECK(new_routing_ids.size() == sent_message_port_ids.size());
- WebMessagePortChannelArray channels(sent_message_port_ids.size());
+ WebTransferableReceiptArray receipts(sent_message_port_ids.size());
for (size_t i = 0; i < sent_message_port_ids.size(); ++i) {
- channels[i] = new WebMessagePortChannelImpl(
+ receipts[i] = new WebMessagePortChannelImpl(
new_routing_ids[i], sent_message_port_ids[i]);
}
- client_->postMessageToWorkerObject(message, channels);
+ client_->postMessageToWorkerObject(message, receipts);
}
void WebWorkerProxy::OnPostConsoleMessageToWorkerObject(
« no previous file with comments | « content/renderer/webworker_proxy.h ('k') | content/worker/webworker_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698