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

Side by Side Diff: mojo/edk/system/channel.h

Issue 1890043002: [mojo-edk] Support transferring null Mach ports. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_EDK_SYSTEM_CHANNEL_H_ 5 #ifndef MOJO_EDK_SYSTEM_CHANNEL_H_
6 #define MOJO_EDK_SYSTEM_CHANNEL_H_ 6 #define MOJO_EDK_SYSTEM_CHANNEL_H_
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 #if defined(OS_MACOSX) && !defined(OS_IOS) 70 #if defined(OS_MACOSX) && !defined(OS_IOS)
71 struct MachPortsEntry { 71 struct MachPortsEntry {
72 uint16_t index; 72 uint16_t index;
73 uint32_t mach_port; 73 uint32_t mach_port;
74 static_assert(sizeof(mach_port_t) <= sizeof(uint32_t), 74 static_assert(sizeof(mach_port_t) <= sizeof(uint32_t),
75 "mach_port_t must be no larger than uint32_t"); 75 "mach_port_t must be no larger than uint32_t");
76 }; 76 };
77 static_assert(sizeof(MachPortsEntry) == 6, 77 static_assert(sizeof(MachPortsEntry) == 6,
78 "sizeof(MachPortsEntry) must be 6 bytes"); 78 "sizeof(MachPortsEntry) must be 6 bytes");
79
80 struct MachPortsExtraHeader {
81 uint16_t num_ports;
82 MachPortsEntry entries[0];
83 };
84 static_assert(sizeof(MachPortsExtraHeader) == 2,
85 "sizeof(MachPortsExtraHeader) must be 2 bytes");
79 #endif 86 #endif
80 #pragma pack(pop) 87 #pragma pack(pop)
81 88
82 // Allocates and owns a buffer for message data with enough capacity for 89 // Allocates and owns a buffer for message data with enough capacity for
83 // |payload_size| bytes plus a header, plus |max_handles| platform handles. 90 // |payload_size| bytes plus a header, plus |max_handles| platform handles.
84 Message(size_t payload_size, 91 Message(size_t payload_size,
85 size_t max_handles, 92 size_t max_handles,
86 Header::MessageType message_type = Header::MessageType::NORMAL); 93 Header::MessageType message_type = Header::MessageType::NORMAL);
87 94
88 ~Message(); 95 ~Message();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 155
149 #if defined(OS_WIN) 156 #if defined(OS_WIN)
150 // On Windows, handles are serialised into the extra header section. 157 // On Windows, handles are serialised into the extra header section.
151 PlatformHandle* handles_ = nullptr; 158 PlatformHandle* handles_ = nullptr;
152 #else 159 #else
153 ScopedPlatformHandleVectorPtr handle_vector_; 160 ScopedPlatformHandleVectorPtr handle_vector_;
154 #endif 161 #endif
155 162
156 #if defined(OS_MACOSX) && !defined(OS_IOS) 163 #if defined(OS_MACOSX) && !defined(OS_IOS)
157 // On OSX, handles are serialised into the extra header section. 164 // On OSX, handles are serialised into the extra header section.
158 MachPortsEntry* mach_ports_ = nullptr; 165 MachPortsExtraHeader* mach_ports_header_ = nullptr;
159 #endif 166 #endif
160 167
161 DISALLOW_COPY_AND_ASSIGN(Message); 168 DISALLOW_COPY_AND_ASSIGN(Message);
162 }; 169 };
163 170
164 // Delegate methods are called from the I/O task runner with which the Channel 171 // Delegate methods are called from the I/O task runner with which the Channel
165 // was created (see Channel::Create). 172 // was created (see Channel::Create).
166 class Delegate { 173 class Delegate {
167 public: 174 public:
168 virtual ~Delegate() {} 175 virtual ~Delegate() {}
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 Delegate* delegate_; 259 Delegate* delegate_;
253 const scoped_ptr<ReadBuffer> read_buffer_; 260 const scoped_ptr<ReadBuffer> read_buffer_;
254 261
255 DISALLOW_COPY_AND_ASSIGN(Channel); 262 DISALLOW_COPY_AND_ASSIGN(Channel);
256 }; 263 };
257 264
258 } // namespace edk 265 } // namespace edk
259 } // namespace mojo 266 } // namespace mojo
260 267
261 #endif // MOJO_EDK_SYSTEM_CHANNEL_H_ 268 #endif // MOJO_EDK_SYSTEM_CHANNEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698