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

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

Issue 1753723003: Revert of [mojo-edk] Serialise windows handles into an "extra header" section. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « no previous file | mojo/edk/system/channel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/channel.h
diff --git a/mojo/edk/system/channel.h b/mojo/edk/system/channel.h
index 43ed579fe1019e13cca1e518c977baba4c4ef005..bfc1232be2053f525fd28fc5069cbabc2b84951b 100644
--- a/mojo/edk/system/channel.h
+++ b/mojo/edk/system/channel.h
@@ -29,7 +29,6 @@
// A message to be written to a channel.
struct Message {
-#pragma pack(push, 1)
struct Header {
enum class MessageType : uint16_t {
// A normal message.
@@ -45,25 +44,17 @@
// Message size in bytes, including the header.
uint32_t num_bytes;
- // Total size of header, including extra header data (i.e. HANDLEs on
- // windows).
- uint16_t num_header_bytes;
-
- // Number of attached handles. May be less than the reserved handle
- // storage size in this message on platforms that serialise handles as
- // data (i.e. HANDLEs on Windows, Mach ports on OSX).
+ // Number of attached handles.
uint16_t num_handles;
MessageType message_type;
-
- char padding[6];
};
-#pragma pack(pop)
// Allocates and owns a buffer for message data with enough capacity for
- // |payload_size| bytes plus a header, plus |max_handles| platform handles.
+ // |payload_size| bytes plus a header. Takes ownership of |handles|, which
+ // may be null.
Message(size_t payload_size,
- size_t max_handles,
+ size_t num_handles,
Header::MessageType message_type = Header::MessageType::NORMAL);
~Message();
@@ -74,22 +65,15 @@
const void* data() const { return data_; }
size_t data_num_bytes() const { return size_; }
- const void* extra_header() const { return data_ + sizeof(Header); }
- void* mutable_extra_header() { return data_ + sizeof(Header); }
- size_t extra_header_size() const {
- return header_->num_header_bytes - sizeof(Header);
+ void* mutable_payload() { return static_cast<void*>(header_ + 1); }
+ const void* payload() const {
+ return static_cast<const void*>(header_ + 1);
}
-
- void* mutable_payload() { return data_ + header_->num_header_bytes; }
- const void* payload() const { return data_ + header_->num_header_bytes; }
size_t payload_size() const;
size_t num_handles() const { return header_->num_handles; }
bool has_handles() const { return header_->num_handles > 0; }
PlatformHandle* handles();
-#if defined(OS_MACOSX) && !defined(OS_IOS)
- bool has_mach_ports() const;
-#endif
// Note: SetHandles() and TakeHandles() invalidate any previous value of
// handles().
@@ -110,7 +94,6 @@
private:
size_t size_;
- size_t max_handles_;
char* data_;
Header* header_;
@@ -192,16 +175,17 @@
// OK to call this synchronously from any public interface methods.
void OnError();
- // Retrieves the set of platform handles read for a given message.
- // |extra_header| and |extra_header_size| correspond to the extra header data.
- // Depending on the Channel implementation, this body may encode platform
- // handles, or handles may be stored and managed elsewhere by the
- // implementation. If |num_handles| handles cannot be returned, this must
- // return null.
+ // Retrieves the set of platform handles read for a given message. |payload|
+ // and |payload_size| correspond to the full message body. Depending on
+ // the Channel implementation, this body may encode platform handles, or
+ // handles may be stored and managed elsewhere by the implementation.
+ // If |num_handles| handles cannot be returned, this must return null.
+ // The implementation may also adjust the values of |*payload| and/or
+ // |*payload_size| to hide handle data from the user.
virtual ScopedPlatformHandleVectorPtr GetReadPlatformHandles(
size_t num_handles,
- const void* extra_header,
- size_t extra_header_size) = 0;
+ void** payload,
+ size_t* payload_size) = 0;
virtual void OnControlMessage(Message::Header::MessageType message_type,
const void* payload,
« no previous file with comments | « no previous file | mojo/edk/system/channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698