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

Unified Diff: mojo/system/message_in_transit.h

Issue 172953003: Mojo: Make MessageInTransit more opaque. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments 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/channel.cc ('k') | mojo/system/message_in_transit.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/message_in_transit.h
diff --git a/mojo/system/message_in_transit.h b/mojo/system/message_in_transit.h
index c2cfed4b0f73f629c75347422e0d957976f39d15..ecc480840696830918a1204d29b22d5b3f3a77f0 100644
--- a/mojo/system/message_in_transit.h
+++ b/mojo/system/message_in_transit.h
@@ -48,9 +48,25 @@ class MOJO_SYSTEM_IMPL_EXPORT MessageInTransit {
uint32_t num_bytes,
uint32_t num_handles);
- // Destroys a |MessageInTransit| created using |Create()|.
+ MessageInTransit* Clone() const;
+
+ // Destroys a |MessageInTransit| created using |Create()| or |Clone()|.
void Destroy();
+ // Gets the "main" buffer for a |MessageInTransit|. A |MessageInTransit| can
+ // be serialized by writing the main buffer. The returned pointer will be
+ // aligned to a multiple of |kMessageAlignment| bytes, and the size of the
+ // buffer (see below) will also be a multiple of |kMessageAlignment|.
+ // TODO(vtl): Add a "secondary" buffer, so that this makes more sense.
+ const void* main_buffer() const {
+ return static_cast<const void*>(this);
+ }
+
+ // Gets the size of the main buffer (in number of bytes).
+ size_t main_buffer_size() const {
+ return RoundUpMessageAlignment(sizeof(*this) + header()->data_size);
+ }
+
// Gets the size of the data (in number of bytes). This is the full size of
// the data that follows the header, and may include data other than the
// message data. (See also |num_bytes()|.)
@@ -77,10 +93,6 @@ class MOJO_SYSTEM_IMPL_EXPORT MessageInTransit {
return header()->num_handles;
}
- size_t size_with_header_and_padding() const {
- return RoundUpMessageAlignment(sizeof(*this) + header()->data_size);
- }
-
Type type() const { return header()->type; }
Subtype subtype() const { return header()->subtype; }
EndpointId source_id() const { return header()->source_id; }
« no previous file with comments | « mojo/system/channel.cc ('k') | mojo/system/message_in_transit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698