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_READER_H_ | 5 #ifndef IPC_IPC_CHANNEL_READER_H_ |
6 #define IPC_IPC_CHANNEL_READER_H_ | 6 #define IPC_IPC_CHANNEL_READER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "ipc/ipc_channel.h" | 9 #include "ipc/ipc_channel.h" |
| 10 #include "ipc/ipc_export.h" |
10 | 11 |
11 namespace IPC { | 12 namespace IPC { |
12 namespace internal { | 13 namespace internal { |
13 | 14 |
14 // This class provides common pipe reading functionality for the | 15 // This class provides common pipe reading functionality for the |
15 // platform-specific IPC channel implementations. | 16 // platform-specific IPC channel implementations. |
16 // | 17 // |
17 // It does the common input buffer management and message dispatch, while the | 18 // It does the common input buffer management and message dispatch, while the |
18 // platform-specific parts provide the pipe management through a virtual | 19 // platform-specific parts provide the pipe management through a virtual |
19 // interface implemented on a per-platform basis. | 20 // interface implemented on a per-platform basis. |
(...skipping 17 matching lines...) Expand all Loading... |
37 | 38 |
38 // Handles asynchronously read data. | 39 // Handles asynchronously read data. |
39 // | 40 // |
40 // Optionally call this after returning READ_PENDING from ReadData to | 41 // Optionally call this after returning READ_PENDING from ReadData to |
41 // indicate that buffer was filled with the given number of bytes of | 42 // indicate that buffer was filled with the given number of bytes of |
42 // data. See ReadData for more. | 43 // data. See ReadData for more. |
43 bool AsyncReadComplete(int bytes_read); | 44 bool AsyncReadComplete(int bytes_read); |
44 | 45 |
45 // Returns true if the given message is internal to the IPC implementation, | 46 // Returns true if the given message is internal to the IPC implementation, |
46 // like the "hello" message sent on channel set-up. | 47 // like the "hello" message sent on channel set-up. |
47 bool IsInternalMessage(const Message& m) const; | 48 bool IsInternalMessage(const Message& m); |
48 | 49 |
49 // Returns true if the given message is an Hello message | 50 // Returns true if the given message is an Hello message |
50 // sent on channel set-up. | 51 // sent on channel set-up. |
51 bool IsHelloMessage(const Message& m) const; | 52 bool IsHelloMessage(const Message& m); |
52 | 53 |
53 protected: | 54 protected: |
54 enum ReadState { READ_SUCCEEDED, READ_FAILED, READ_PENDING }; | 55 enum ReadState { READ_SUCCEEDED, READ_FAILED, READ_PENDING }; |
55 | 56 |
56 Listener* listener() const { return listener_; } | 57 Listener* listener() const { return listener_; } |
57 | 58 |
58 // Populates the given buffer with data from the pipe. | 59 // Populates the given buffer with data from the pipe. |
59 // | 60 // |
60 // Returns the state of the read. On READ_SUCCESS, the number of bytes | 61 // Returns the state of the read. On READ_SUCCESS, the number of bytes |
61 // read will be placed into |*bytes_read| (which can be less than the | 62 // read will be placed into |*bytes_read| (which can be less than the |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // this buffer. | 101 // this buffer. |
101 std::string input_overflow_buf_; | 102 std::string input_overflow_buf_; |
102 | 103 |
103 DISALLOW_COPY_AND_ASSIGN(ChannelReader); | 104 DISALLOW_COPY_AND_ASSIGN(ChannelReader); |
104 }; | 105 }; |
105 | 106 |
106 } // namespace internal | 107 } // namespace internal |
107 } // namespace IPC | 108 } // namespace IPC |
108 | 109 |
109 #endif // IPC_IPC_CHANNEL_READER_H_ | 110 #endif // IPC_IPC_CHANNEL_READER_H_ |
OLD | NEW |