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

Unified Diff: chrome/browser/extensions/api/messaging/native_message_port.cc

Issue 16226004: Replace JSON (de)serialization of extension messages with direct Value pickling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 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
Index: chrome/browser/extensions/api/messaging/native_message_port.cc
diff --git a/chrome/browser/extensions/api/messaging/native_message_port.cc b/chrome/browser/extensions/api/messaging/native_message_port.cc
index cc0a4cfef524c734e371fa6dda86ba46260197cc..c340e33e5307292e0aaf7fe2d26065d08c890dbb 100644
--- a/chrome/browser/extensions/api/messaging/native_message_port.cc
+++ b/chrome/browser/extensions/api/messaging/native_message_port.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/extensions/api/messaging/native_message_port.h"
+#include "base/bind.h"
+#include "base/json/json_writer.h"
#include "chrome/browser/extensions/api/messaging/native_message_process_host.h"
#include "content/public/browser/browser_thread.h"
@@ -18,12 +20,20 @@ NativeMessagePort::~NativeMessagePort() {
content::BrowserThread::IO, FROM_HERE, native_process_);
}
-void NativeMessagePort::DispatchOnMessage(const std::string& message,
+void NativeMessagePort::DispatchOnMessage(scoped_ptr<base::ListValue> message,
int target_port_id) {
+ std::string message_as_json;
+ if (!message->empty()) {
+ DCHECK_EQ(1u, message->GetSize());
+ base::Value* value = NULL;
+ message->Get(0, &value);
+ base::JSONWriter::Write(value, &message_as_json);
+ }
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::Bind(&NativeMessageProcessHost::Send,
- base::Unretained(native_process_), message));
+ base::Unretained(native_process_),
+ message_as_json));
}
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698