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

Unified Diff: mojo/system/message_in_transit.cc

Issue 173333002: Mojo: Make MessageInTransit more opaque still. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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/system/message_in_transit.h ('k') | mojo/system/raw_channel_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/message_in_transit.cc
diff --git a/mojo/system/message_in_transit.cc b/mojo/system/message_in_transit.cc
index b7c536ebeb1e380d773e044450cc32cdca5bd895..2eb9e26732253c1d93d6bdf58756e3ca1aa076ce 100644
--- a/mojo/system/message_in_transit.cc
+++ b/mojo/system/message_in_transit.cc
@@ -77,6 +77,33 @@ void MessageInTransit::Destroy() {
base::AlignedFree(this);
}
+// static
+bool MessageInTransit::GetNextMessageSize(const void* buffer,
+ size_t buffer_size,
+ size_t* next_message_size) {
+ DCHECK(buffer);
+ DCHECK_EQ(reinterpret_cast<uintptr_t>(buffer) %
+ MessageInTransit::kMessageAlignment, 0u);
+ DCHECK(next_message_size);
+
+ if (buffer_size < sizeof(Header))
+ return false;
+
+ const Header* header = static_cast<const Header*>(buffer);
+ *next_message_size =
+ RoundUpMessageAlignment(sizeof(MessageInTransit) + header->data_size);
+ return true;
+}
+
+// static
+const MessageInTransit* MessageInTransit::CreateReadOnlyFromBuffer(
+ const void* buffer) {
+ DCHECK(buffer);
+ DCHECK_EQ(reinterpret_cast<uintptr_t>(buffer) %
+ MessageInTransit::kMessageAlignment, 0u);
+ return static_cast<const MessageInTransit*>(buffer);
+}
+
MessageInTransit::MessageInTransit(uint32_t data_size,
Type type,
Subtype subtype,
« no previous file with comments | « mojo/system/message_in_transit.h ('k') | mojo/system/raw_channel_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698