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

Unified Diff: mojo/edk/system/channel.cc

Issue 2749853003: Making the Mojo Channel Messages legacy mode dynamic. (Closed)
Patch Set: Fixed NaCl browser test failures. Created 3 years, 9 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 | « mojo/edk/system/channel.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/channel.cc
diff --git a/mojo/edk/system/channel.cc b/mojo/edk/system/channel.cc
index 8a44d36024e2346b3eab90a48f1eb77a35adcd63..9fc8cfcc884b94b4590c88c31db7c9790ffe0f0d 100644
--- a/mojo/edk/system/channel.cc
+++ b/mojo/edk/system/channel.cc
@@ -14,6 +14,7 @@
#include "base/macros.h"
#include "base/memory/aligned_memory.h"
#include "base/process/process_handle.h"
+#include "mojo/edk/embedder/embedder_internal.h"
#include "mojo/edk/embedder/platform_handle.h"
#if defined(OS_MACOSX) && !defined(OS_IOS)
@@ -45,6 +46,8 @@ static_assert(offsetof(Channel::Message::LegacyHeader, message_type) ==
"message_type should be at the same offset in both Header "
"structs.");
+bool g_use_legacy_protocol = false;
+
} // namespace
const size_t kReadBufferSize = 4096;
@@ -53,13 +56,10 @@ const size_t kMaxChannelMessageSize = 256 * 1024 * 1024;
const size_t kMaxAttachedHandles = 128;
Channel::Message::Message(size_t payload_size, size_t max_handles)
-#if defined(MOJO_EDK_LEGACY_PROTOCOL)
- : Message(payload_size, max_handles, MessageType::NORMAL_LEGACY) {
-}
-#else
- : Message(payload_size, max_handles, MessageType::NORMAL) {
-}
-#endif
+ : Message(payload_size,
+ max_handles,
+ g_use_legacy_protocol ? MessageType::NORMAL_LEGACY
+ : MessageType::NORMAL) {}
Channel::Message::Message(size_t payload_size,
size_t max_handles,
@@ -395,6 +395,13 @@ ScopedPlatformHandleVectorPtr Channel::Message::TakeHandlesForTransport() {
#endif
}
+// static
+void Channel::Message::SetUseLegacyTransportProtocol(bool use_legacy_protocol) {
+ // Make sure this is called before mojo::edk::Init() is called.
+ DCHECK(!internal::g_core);
+ g_use_legacy_protocol = use_legacy_protocol;
+}
+
#if defined(OS_WIN)
// static
bool Channel::Message::RewriteHandles(base::ProcessHandle from_process,
« no previous file with comments | « mojo/edk/system/channel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698