OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 IPC_IPC_CHANNEL_H_ | 5 #ifndef IPC_IPC_CHANNEL_H_ |
6 #define IPC_IPC_CHANNEL_H_ | 6 #define IPC_IPC_CHANNEL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/files/scoped_file.h" | 15 #include "base/files/scoped_file.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/process/process.h" | 17 #include "base/process/process.h" |
18 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
19 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
21 #include "ipc/ipc_channel_handle.h" | 21 #include "ipc/ipc_channel_handle.h" |
22 #include "ipc/ipc_endpoint.h" | |
23 #include "ipc/ipc_message.h" | 22 #include "ipc/ipc_message.h" |
| 23 #include "ipc/ipc_sender.h" |
24 #include "mojo/public/cpp/bindings/associated_group.h" | 24 #include "mojo/public/cpp/bindings/associated_group.h" |
25 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" | 25 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" |
26 #include "mojo/public/cpp/bindings/associated_interface_request.h" | 26 #include "mojo/public/cpp/bindings/associated_interface_request.h" |
27 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" | 27 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" |
28 | 28 |
29 #if defined(OS_POSIX) | 29 #if defined(OS_POSIX) |
30 #include <sys/types.h> | 30 #include <sys/types.h> |
31 #endif | 31 #endif |
32 | 32 |
33 namespace IPC { | 33 namespace IPC { |
34 | 34 |
35 class Listener; | 35 class Listener; |
36 | 36 |
37 //------------------------------------------------------------------------------ | 37 //------------------------------------------------------------------------------ |
38 // See | 38 // See |
39 // http://www.chromium.org/developers/design-documents/inter-process-communicati
on | 39 // http://www.chromium.org/developers/design-documents/inter-process-communicati
on |
40 // for overview of IPC in Chromium. | 40 // for overview of IPC in Chromium. |
41 | 41 |
42 // Channels are implemented using mojo message pipes on all platforms other | 42 // Channels are implemented using mojo message pipes on all platforms other |
43 // than NaCl. | 43 // than NaCl. |
44 | 44 |
45 class IPC_EXPORT Channel : public Endpoint { | 45 class IPC_EXPORT Channel : public Sender { |
46 // Security tests need access to the pipe handle. | 46 // Security tests need access to the pipe handle. |
47 friend class ChannelTest; | 47 friend class ChannelTest; |
48 | 48 |
49 public: | 49 public: |
50 // Flags to test modes | 50 // Flags to test modes |
51 enum ModeFlags { | 51 enum ModeFlags { |
52 MODE_NO_FLAG = 0x0, | 52 MODE_NO_FLAG = 0x0, |
53 MODE_SERVER_FLAG = 0x1, | 53 MODE_SERVER_FLAG = 0x1, |
54 MODE_CLIENT_FLAG = 0x2, | 54 MODE_CLIENT_FLAG = 0x2, |
55 }; | 55 }; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 size_t size() const { return message_ ? message_->size() : length_; } | 277 size_t size() const { return message_ ? message_->size() : length_; } |
278 const void* data() const { return message_ ? message_->data() : buffer_; } | 278 const void* data() const { return message_ ? message_->data() : buffer_; } |
279 Message* get_message() const { return message_.get(); } | 279 Message* get_message() const { return message_.get(); } |
280 | 280 |
281 private: | 281 private: |
282 std::unique_ptr<Message> message_; | 282 std::unique_ptr<Message> message_; |
283 void* buffer_; | 283 void* buffer_; |
284 size_t length_; | 284 size_t length_; |
285 }; | 285 }; |
286 | 286 |
287 // Endpoint overrides. | |
288 void OnSetAttachmentBrokerEndpoint() override; | |
289 | |
290 // Subclasses must call this method at the beginning of their implementation | 287 // Subclasses must call this method at the beginning of their implementation |
291 // of Connect(). | 288 // of Connect(). |
292 void WillConnect(); | 289 void WillConnect(); |
293 | 290 |
294 private: | 291 private: |
295 bool did_start_connect_ = false; | 292 bool did_start_connect_ = false; |
296 }; | 293 }; |
297 | 294 |
298 } // namespace IPC | 295 } // namespace IPC |
299 | 296 |
300 #endif // IPC_IPC_CHANNEL_H_ | 297 #endif // IPC_IPC_CHANNEL_H_ |
OLD | NEW |