Optionally have MessagePort pass data as base::Value, part 1.
Various efforts (android webview, navigator.connect) are experimenting
with using MessagePort as a way to communicate with native code. This is
a start at refactoring MessagePort code to make this possible.
This CL changes the IPCs for MessagePort messages to pass the data as
a MessagePortMessage struct, adding support to the renderer side
MessagePort code to support both base::Value and blink::WebSerializedScriptValue
messages. Additionally a (currently unset) flag is added that determines
how MessagePort sends messages back to the browser process.
This is part of a series of changes:
[1/5] Blink side changes in https://codereview.chromium.org/924983002/ that expose a needed v8 context
[2/5] This CL
[3/5] https://codereview.chromium.org/944443003/ which causes the send_messages_as_values flag to be propagated
[4/5] https://codereview.chromium.org/938403005/ which uses this for navigator.connect services and adds infrastructure for layout tests
[5/5] https://codereview.chromium.org/940423004/ adds layout tests to blink to test these new features
BUG=426458
Review URL: https://codereview.chromium.org/921013002
Cr-Commit-Position: refs/heads/master@{#318492}
diff --git a/content/browser/message_port_service.h b/content/browser/message_port_service.h
index 5623e94..1e561b2 100644
--- a/content/browser/message_port_service.h
+++ b/content/browser/message_port_service.h
@@ -13,6 +13,7 @@
#include "base/memory/singleton.h"
#include "base/strings/string16.h"
#include "content/common/content_export.h"
+#include "content/public/common/message_port_types.h"
#include "ipc/ipc_message.h"
namespace content {
@@ -20,7 +21,7 @@
class CONTENT_EXPORT MessagePortService {
public:
- typedef std::vector<std::pair<base::string16, std::vector<int> > >
+ typedef std::vector<std::pair<content::MessagePortMessage, std::vector<int>>>
QueuedMessages;
// Returns the MessagePortService singleton.
@@ -33,7 +34,7 @@
void Destroy(int message_port_id);
void Entangle(int local_message_port_id, int remote_message_port_id);
void PostMessage(int sender_message_port_id,
- const base::string16& message,
+ const MessagePortMessage& message,
const std::vector<int>& sent_message_port_ids);
void QueueMessages(int message_port_id);
void SendQueuedMessages(int message_port_id,
@@ -72,7 +73,7 @@
~MessagePortService();
void PostMessageTo(int message_port_id,
- const base::string16& message,
+ const MessagePortMessage& message,
const std::vector<int>& sent_message_port_ids);
// Handles the details of removing a message port id. Before calling this,