OLD | NEW |
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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 bool OnReadComplete(size_t bytes_read, size_t* next_read_size_hint); | 240 bool OnReadComplete(size_t bytes_read, size_t* next_read_size_hint); |
241 | 241 |
242 // Called by the implementation when something goes horribly wrong. It is NOT | 242 // Called by the implementation when something goes horribly wrong. It is NOT |
243 // OK to call this synchronously from any public interface methods. | 243 // OK to call this synchronously from any public interface methods. |
244 void OnError(); | 244 void OnError(); |
245 | 245 |
246 // Retrieves the set of platform handles read for a given message. | 246 // Retrieves the set of platform handles read for a given message. |
247 // |extra_header| and |extra_header_size| correspond to the extra header data. | 247 // |extra_header| and |extra_header_size| correspond to the extra header data. |
248 // Depending on the Channel implementation, this body may encode platform | 248 // Depending on the Channel implementation, this body may encode platform |
249 // handles, or handles may be stored and managed elsewhere by the | 249 // handles, or handles may be stored and managed elsewhere by the |
250 // implementation. If |num_handles| handles cannot be returned, this must | 250 // implementation. |
251 // return null. | 251 // |
252 virtual ScopedPlatformHandleVectorPtr GetReadPlatformHandles( | 252 // Returns |false| on unrecoverable error (i.e. the Channel should be closed). |
| 253 // Returns |true| otherwise. Note that it is possible on some platforms for an |
| 254 // insufficient number of handles to be available when this call is made, but |
| 255 // this is not necessarily an error condition. In such cases this returns |
| 256 // |true| but |*handles| will also be reset to null. |
| 257 virtual bool GetReadPlatformHandles( |
253 size_t num_handles, | 258 size_t num_handles, |
254 const void* extra_header, | 259 const void* extra_header, |
255 size_t extra_header_size) = 0; | 260 size_t extra_header_size, |
| 261 ScopedPlatformHandleVectorPtr* handles) = 0; |
256 | 262 |
257 virtual void OnControlMessage(Message::Header::MessageType message_type, | 263 // Handles a received control message. Returns |true| if the message is |
| 264 // accepted, or |false| otherwise. |
| 265 virtual bool OnControlMessage(Message::Header::MessageType message_type, |
258 const void* payload, | 266 const void* payload, |
259 size_t payload_size, | 267 size_t payload_size, |
260 ScopedPlatformHandleVectorPtr handles) {} | 268 ScopedPlatformHandleVectorPtr handles); |
261 | 269 |
262 private: | 270 private: |
263 friend class base::RefCountedThreadSafe<Channel>; | 271 friend class base::RefCountedThreadSafe<Channel>; |
264 | 272 |
265 class ReadBuffer; | 273 class ReadBuffer; |
266 | 274 |
267 Delegate* delegate_; | 275 Delegate* delegate_; |
268 const std::unique_ptr<ReadBuffer> read_buffer_; | 276 const std::unique_ptr<ReadBuffer> read_buffer_; |
269 | 277 |
270 DISALLOW_COPY_AND_ASSIGN(Channel); | 278 DISALLOW_COPY_AND_ASSIGN(Channel); |
271 }; | 279 }; |
272 | 280 |
273 } // namespace edk | 281 } // namespace edk |
274 } // namespace mojo | 282 } // namespace mojo |
275 | 283 |
276 #endif // MOJO_EDK_SYSTEM_CHANNEL_H_ | 284 #endif // MOJO_EDK_SYSTEM_CHANNEL_H_ |
OLD | NEW |