| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "ipc/brokerable_attachment.h" |
| 15 #include "ipc/ipc_channel.h" | 16 #include "ipc/ipc_channel.h" |
| 16 #include "ipc/ipc_export.h" | 17 #include "ipc/ipc_export.h" |
| 17 | 18 |
| 18 namespace IPC { | 19 namespace IPC { |
| 19 namespace internal { | 20 namespace internal { |
| 20 | 21 |
| 21 // This class provides common pipe reading functionality for the | 22 // This class provides common pipe reading functionality for the |
| 22 // platform-specific IPC channel implementations. | 23 // platform-specific IPC channel implementations. |
| 23 // | 24 // |
| 24 // It does the common input buffer management and message dispatch, while the | 25 // It does the common input buffer management and message dispatch, while the |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 virtual ReadState ReadData(char* buffer, int buffer_len, int* bytes_read) = 0; | 94 virtual ReadState ReadData(char* buffer, int buffer_len, int* bytes_read) = 0; |
| 94 | 95 |
| 95 // Loads the required file desciptors into the given message. Returns true | 96 // Loads the required file desciptors into the given message. Returns true |
| 96 // on success. False means a fatal channel error. | 97 // on success. False means a fatal channel error. |
| 97 // | 98 // |
| 98 // This will read from the input_fds_ and read more handles from the FD | 99 // This will read from the input_fds_ and read more handles from the FD |
| 99 // pipe if necessary. | 100 // pipe if necessary. |
| 100 virtual bool ShouldDispatchInputMessage(Message* msg) = 0; | 101 virtual bool ShouldDispatchInputMessage(Message* msg) = 0; |
| 101 | 102 |
| 102 // Overridden by subclasses to get attachments that are sent alongside the IPC | 103 // Overridden by subclasses to get attachments that are sent alongside the IPC |
| 103 // channel. | 104 // channel (as opposed to through a broker). |
| 104 // Returns true on success. False means a fatal channel error. | 105 // Returns true on success. False means a fatal channel error. |
| 105 virtual bool GetAttachments(Message* msg) = 0; | 106 virtual bool GetNonBrokeredAttachments(Message* msg) = 0; |
| 106 | 107 |
| 107 // Performs post-dispatch checks. Called when all input buffers are empty, | 108 // Performs post-dispatch checks. Called when all input buffers are empty, |
| 108 // though there could be more data ready to be read from the OS. | 109 // though there could be more data ready to be read from the OS. |
| 109 virtual bool DidEmptyInputBuffers() = 0; | 110 virtual bool DidEmptyInputBuffers() = 0; |
| 110 | 111 |
| 111 // Handles internal messages, like the hello message sent on channel startup. | 112 // Handles internal messages, like the hello message sent on channel startup. |
| 112 virtual void HandleInternalMessage(const Message& msg) = 0; | 113 virtual void HandleInternalMessage(const Message& msg) = 0; |
| 113 | 114 |
| 114 // Exposed for testing purposes only. | 115 // Exposed for testing purposes only. |
| 115 virtual void DispatchMessage(Message* m); | 116 virtual void DispatchMessage(Message* m); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // of std::string::reserve() implementation. | 160 // of std::string::reserve() implementation. |
| 160 size_t max_input_buffer_size_; | 161 size_t max_input_buffer_size_; |
| 161 | 162 |
| 162 DISALLOW_COPY_AND_ASSIGN(ChannelReader); | 163 DISALLOW_COPY_AND_ASSIGN(ChannelReader); |
| 163 }; | 164 }; |
| 164 | 165 |
| 165 } // namespace internal | 166 } // namespace internal |
| 166 } // namespace IPC | 167 } // namespace IPC |
| 167 | 168 |
| 168 #endif // IPC_IPC_CHANNEL_READER_H_ | 169 #endif // IPC_IPC_CHANNEL_READER_H_ |
| OLD | NEW |