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

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

Issue 2738853002: Connections now take a ConnectionParams instead of a pipe handle. (Closed)
Patch Set: Fix Win release build. 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 unified diff | Download patch
« no previous file with comments | « mojo/edk/system/broker_host.cc ('k') | mojo/edk/system/channel_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/process/process_handle.h" 11 #include "base/process/process_handle.h"
12 #include "base/task_runner.h" 12 #include "base/task_runner.h"
13 #include "mojo/edk/embedder/connection_params.h"
13 #include "mojo/edk/embedder/platform_handle_vector.h" 14 #include "mojo/edk/embedder/platform_handle_vector.h"
14 #include "mojo/edk/embedder/scoped_platform_handle.h" 15 #include "mojo/edk/embedder/scoped_platform_handle.h"
15 16
16 namespace mojo { 17 namespace mojo {
17 namespace edk { 18 namespace edk {
18 19
19 const size_t kChannelMessageAlignment = 8; 20 const size_t kChannelMessageAlignment = 8;
20 21
21 constexpr bool IsAlignedForChannelMessage(size_t n) { 22 constexpr bool IsAlignedForChannelMessage(size_t n) {
22 return n % kChannelMessageAlignment == 0; 23 return n % kChannelMessageAlignment == 0;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 "mach_port_t must be no larger than uint32_t"); 96 "mach_port_t must be no larger than uint32_t");
96 }; 97 };
97 static_assert(sizeof(MachPortsEntry) == 6, 98 static_assert(sizeof(MachPortsEntry) == 6,
98 "sizeof(MachPortsEntry) must be 6 bytes"); 99 "sizeof(MachPortsEntry) must be 6 bytes");
99 100
100 // Structure of the extra header field when present on OSX. 101 // Structure of the extra header field when present on OSX.
101 struct MachPortsExtraHeader { 102 struct MachPortsExtraHeader {
102 // Actual number of Mach ports encoded in the extra header. 103 // Actual number of Mach ports encoded in the extra header.
103 uint16_t num_ports; 104 uint16_t num_ports;
104 105
105 // Array of encoded Mach ports. If |num_ports| > 0, |entires[0]| through 106 // Array of encoded Mach ports. If |num_ports| > 0, |entries[0]| through
106 // to |entries[num_ports-1]| inclusive are valid. 107 // to |entries[num_ports-1]| inclusive are valid.
107 MachPortsEntry entries[0]; 108 MachPortsEntry entries[0];
108 }; 109 };
109 static_assert(sizeof(MachPortsExtraHeader) == 2, 110 static_assert(sizeof(MachPortsExtraHeader) == 2,
110 "sizeof(MachPortsExtraHeader) must be 2 bytes"); 111 "sizeof(MachPortsExtraHeader) must be 2 bytes");
111 #elif defined(OS_WIN) 112 #elif defined(OS_WIN)
112 struct HandleEntry { 113 struct HandleEntry {
113 // The windows HANDLE. HANDLEs are guaranteed to fit inside 32-bits. 114 // The windows HANDLE. HANDLEs are guaranteed to fit inside 32-bits.
114 // See: https://msdn.microsoft.com/en-us/library/aa384203(VS.85).aspx 115 // See: https://msdn.microsoft.com/en-us/library/aa384203(VS.85).aspx
115 uint32_t handle; 116 uint32_t handle;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // Notify that an error has occured and the Channel will cease operation. 207 // Notify that an error has occured and the Channel will cease operation.
207 virtual void OnChannelError() = 0; 208 virtual void OnChannelError() = 0;
208 }; 209 };
209 210
210 // Creates a new Channel around a |platform_handle|, taking ownership of the 211 // Creates a new Channel around a |platform_handle|, taking ownership of the
211 // handle. All I/O on the handle will be performed on |io_task_runner|. 212 // handle. All I/O on the handle will be performed on |io_task_runner|.
212 // Note that ShutDown() MUST be called on the Channel some time before 213 // Note that ShutDown() MUST be called on the Channel some time before
213 // |delegate| is destroyed. 214 // |delegate| is destroyed.
214 static scoped_refptr<Channel> Create( 215 static scoped_refptr<Channel> Create(
215 Delegate* delegate, 216 Delegate* delegate,
216 ScopedPlatformHandle platform_handle, 217 ConnectionParams connection_params,
217 scoped_refptr<base::TaskRunner> io_task_runner); 218 scoped_refptr<base::TaskRunner> io_task_runner);
218 219
219 // Request that the channel be shut down. This should always be called before 220 // Request that the channel be shut down. This should always be called before
220 // releasing the last reference to a Channel to ensure that it's cleaned up 221 // releasing the last reference to a Channel to ensure that it's cleaned up
221 // on its I/O task runner's thread. 222 // on its I/O task runner's thread.
222 // 223 //
223 // Delegate methods will no longer be invoked after this call. 224 // Delegate methods will no longer be invoked after this call.
224 void ShutDown(); 225 void ShutDown();
225 226
226 // Begin processing I/O events. Delegate methods must only be invoked after 227 // Begin processing I/O events. Delegate methods must only be invoked after
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 Delegate* delegate_; 294 Delegate* delegate_;
294 const std::unique_ptr<ReadBuffer> read_buffer_; 295 const std::unique_ptr<ReadBuffer> read_buffer_;
295 296
296 DISALLOW_COPY_AND_ASSIGN(Channel); 297 DISALLOW_COPY_AND_ASSIGN(Channel);
297 }; 298 };
298 299
299 } // namespace edk 300 } // namespace edk
300 } // namespace mojo 301 } // namespace mojo
301 302
302 #endif // MOJO_EDK_SYSTEM_CHANNEL_H_ 303 #endif // MOJO_EDK_SYSTEM_CHANNEL_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/broker_host.cc ('k') | mojo/edk/system/channel_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698