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

Unified Diff: mojo/public/bindings/sample/sample_test.cc

Issue 63033010: Mojo's C++ and JavaScript bindings should produce identical messages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 | « mojo/public/bindings/sample/mojom/sample_service.js ('k') | mojo/public/bindings/sample/sample_test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/bindings/sample/sample_test.cc
diff --git a/mojo/public/bindings/sample/sample_test.cc b/mojo/public/bindings/sample/sample_test.cc
index fac60182e032838b94a8cf8b4a83e35ce9c49c96..00a99eee4285622d77010f8bd4b34b24fc1b3c20 100644
--- a/mojo/public/bindings/sample/sample_test.cc
+++ b/mojo/public/bindings/sample/sample_test.cc
@@ -13,6 +13,9 @@
namespace sample {
+// Set this variable to true to print the binary message in hex.
+bool g_dump_message_as_hex = true;
+
// Make a sample |Foo| in the given |ScratchBuffer|.
Foo* MakeFoo(mojo::ScratchBuffer* buf) {
const std::string kName("foopy");
@@ -174,6 +177,22 @@ static void Print(int depth, const char* name, const Foo* foo) {
}
}
+static void DumpHex(const uint8_t* bytes, uint32_t num_bytes) {
+ for (uint32_t i = 0; i < num_bytes; ++i) {
+ printf("%02x", bytes[i]);
+
+ if (i % 16 == 15) {
+ printf("\n");
+ continue;
+ }
+
+ if (i % 2 == 1)
+ printf(" ");
+ if (i % 8 == 7)
+ printf(" ");
+ }
+}
+
class ServiceImpl : public ServiceStub {
public:
virtual void Frobinate(const Foo* foo, bool baz, mojo::Handle port)
@@ -200,6 +219,11 @@ class SimpleMessageReceiver : public mojo::MessageReceiver {
virtual bool Accept(mojo::Message* message) MOJO_OVERRIDE {
// Imagine some IPC happened here.
+ if (g_dump_message_as_hex) {
+ DumpHex(reinterpret_cast<const uint8_t*>(message->data),
+ message->data->header.num_bytes);
+ }
+
// In the receiving process, an implementation of ServiceStub is known to
// the system. It receives the incoming message.
ServiceImpl impl;
« no previous file with comments | « mojo/public/bindings/sample/mojom/sample_service.js ('k') | mojo/public/bindings/sample/sample_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698