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

Unified Diff: content/worker/webworkerclient_proxy.cc

Issue 7477027: Support Transferable objects (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Update for interface changes. 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/worker/webworkerclient_proxy.h ('k') | webkit/tools/test_shell/test_web_worker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/worker/webworkerclient_proxy.cc
diff --git a/content/worker/webworkerclient_proxy.cc b/content/worker/webworkerclient_proxy.cc
index 3493b32f2ce4694d6e93716564afa85b60f41234..fa0ad1dd641191001b834aeeed3700c09ce93459 100644
--- a/content/worker/webworkerclient_proxy.cc
+++ b/content/worker/webworkerclient_proxy.cc
@@ -24,6 +24,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallbacks.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptValue.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebWorker.h"
@@ -31,7 +32,11 @@
using WebKit::WebApplicationCacheHost;
using WebKit::WebFrame;
using WebKit::WebMessagePortChannel;
-using WebKit::WebMessagePortChannelArray;
+#ifdef WebTransferableReceipt_h
+using WebKit::WebMessagePortReceipt;
+#endif
+using WebKit::WebTransferableReceiptArray;
+using WebKit::WebSerializedScriptValue;
using WebKit::WebSecurityOrigin;
using WebKit::WebString;
using WebKit::WebWorker;
@@ -53,18 +58,42 @@ WebWorkerClientProxy::~WebWorkerClientProxy() {
}
void WebWorkerClientProxy::postMessageToWorkerObject(
- 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();
- DCHECK(message_port_ids[i] != MSG_ROUTING_NONE);
- routing_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 (!WebSerializedScriptValue::isFlattenable(receipts[i])) {
+ DCHECK(toWebMessagePortReceipt(receipts[i]));
+#endif
+ DCHECK(next_unflattenable < unflattenable_count);
+ WebMessagePortChannelImpl* webchannel =
+#ifndef WebTransferableReceipt_h
+ static_cast<WebMessagePortChannelImpl*>(receipts[i]);
+#else
+ static_cast<WebMessagePortChannelImpl*>(
+ static_cast<WebMessagePortReceipt*>(receipts[i])->channel());
+#endif
+ message_port_ids[next_unflattenable] = webchannel->message_port_id();
+ webchannel->QueueMessages();
+ CHECK(message_port_ids[next_unflattenable] != MSG_ROUTING_NONE);
+ routing_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));
« no previous file with comments | « content/worker/webworkerclient_proxy.h ('k') | webkit/tools/test_shell/test_web_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698