OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "ipc/ipc_channel_handle.h" | |
10 #include "ipc/ipc_message.h" | 11 #include "ipc/ipc_message.h" |
11 | 12 |
12 namespace IPC { | 13 namespace IPC { |
13 | 14 |
14 //------------------------------------------------------------------------------ | 15 //------------------------------------------------------------------------------ |
15 | 16 |
16 class Channel : public Message::Sender { | 17 class Channel : public Message::Sender { |
17 // Security tests need access to the pipe handle. | 18 // Security tests need access to the pipe handle. |
18 friend class ChannelTest; | 19 friend class ChannelTest; |
19 | 20 |
(...skipping 27 matching lines...) Expand all Loading... | |
47 // The maximum message size in bytes. Attempting to receive a | 48 // The maximum message size in bytes. Attempting to receive a |
48 // message of this size or bigger results in a channel error. | 49 // message of this size or bigger results in a channel error. |
49 kMaximumMessageSize = 128 * 1024 * 1024, | 50 kMaximumMessageSize = 128 * 1024 * 1024, |
50 | 51 |
51 // Ammount of data to read at once from the pipe. | 52 // Ammount of data to read at once from the pipe. |
52 kReadBufferSize = 4 * 1024 | 53 kReadBufferSize = 4 * 1024 |
53 }; | 54 }; |
54 | 55 |
55 // Initialize a Channel. | 56 // Initialize a Channel. |
56 // | 57 // |
57 // |channel_id| identifies the communication Channel. | 58 // |channel_handle| identifies the communication Channel. For POSIX, if |
59 // the file descriptor in the channel handle is != -1, the channel takes | |
60 // ownership of the file descriptor and will close it appropriately, otherwise | |
61 // it will create a new descriptor internally. | |
58 // |mode| specifies whether this Channel is to operate in server mode or | 62 // |mode| specifies whether this Channel is to operate in server mode or |
59 // client mode. In server mode, the Channel is responsible for setting up the | 63 // client mode. In server mode, the Channel is responsible for setting up the |
60 // IPC object, whereas in client mode, the Channel merely connects to the | 64 // IPC object, whereas in client mode, the Channel merely connects to the |
61 // already established IPC object. | 65 // already established IPC object. |
62 // |listener| receives a callback on the current thread for each newly | 66 // |listener| receives a callback on the current thread for each newly |
63 // received message. | 67 // received message. |
64 // | 68 // |
65 Channel(const std::string& channel_id, Mode mode, Listener* listener); | 69 Channel(const IPC::ChannelHandle &channel_handle, Mode mode, |
brettw
2010/12/08 22:49:27
The & should be next to the type name.
| |
70 Listener* listener); | |
66 | 71 |
67 ~Channel(); | 72 ~Channel(); |
68 | 73 |
69 // Connect the pipe. On the server side, this will initiate | 74 // Connect the pipe. On the server side, this will initiate |
70 // waiting for connections. On the client, it attempts to | 75 // waiting for connections. On the client, it attempts to |
71 // connect to a pre-existing pipe. Note, calling Connect() | 76 // connect to a pre-existing pipe. Note, calling Connect() |
72 // will not block the calling thread and may complete | 77 // will not block the calling thread and may complete |
73 // asynchronously. | 78 // asynchronously. |
74 bool Connect() WARN_UNUSED_RESULT; | 79 bool Connect() WARN_UNUSED_RESULT; |
75 | 80 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 HELLO_MESSAGE_TYPE = kuint16max // Maximum value of message type (uint16), | 121 HELLO_MESSAGE_TYPE = kuint16max // Maximum value of message type (uint16), |
117 // to avoid conflicting with normal | 122 // to avoid conflicting with normal |
118 // message types, which are enumeration | 123 // message types, which are enumeration |
119 // constants starting from 0. | 124 // constants starting from 0. |
120 }; | 125 }; |
121 }; | 126 }; |
122 | 127 |
123 } // namespace IPC | 128 } // namespace IPC |
124 | 129 |
125 #endif // IPC_IPC_CHANNEL_H_ | 130 #endif // IPC_IPC_CHANNEL_H_ |
OLD | NEW |