OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TEST_SINK_H_ | 5 #ifndef IPC_IPC_TEST_SINK_H_ |
6 #define IPC_IPC_TEST_SINK_H_ | 6 #define IPC_IPC_TEST_SINK_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <utility> | 10 #include <utility> |
9 #include <vector> | 11 #include <vector> |
10 | 12 |
11 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
12 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
13 #include "ipc/ipc_channel.h" | 15 #include "ipc/ipc_channel.h" |
14 | 16 |
15 namespace IPC { | 17 namespace IPC { |
16 | 18 |
17 class Message; | 19 class Message; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 void ClearMessages(); | 101 void ClearMessages(); |
100 | 102 |
101 // Returns the message at the given index in the queue. The index may be out | 103 // Returns the message at the given index in the queue. The index may be out |
102 // of range, in which case the return value is NULL. The returned pointer will | 104 // of range, in which case the return value is NULL. The returned pointer will |
103 // only be valid until another message is received or the list is cleared. | 105 // only be valid until another message is received or the list is cleared. |
104 const Message* GetMessageAt(size_t index) const; | 106 const Message* GetMessageAt(size_t index) const; |
105 | 107 |
106 // Returns the first message with the given ID in the queue. If there is no | 108 // Returns the first message with the given ID in the queue. If there is no |
107 // message with the given ID, returns NULL. The returned pointer will only be | 109 // message with the given ID, returns NULL. The returned pointer will only be |
108 // valid until another message is received or the list is cleared. | 110 // valid until another message is received or the list is cleared. |
109 const Message* GetFirstMessageMatching(uint32 id) const; | 111 const Message* GetFirstMessageMatching(uint32_t id) const; |
110 | 112 |
111 // Returns the message with the given ID in the queue. If there is no such | 113 // Returns the message with the given ID in the queue. If there is no such |
112 // message or there is more than one of that message, this will return NULL | 114 // message or there is more than one of that message, this will return NULL |
113 // (with the expectation that you'll do an ASSERT_TRUE() on the result). | 115 // (with the expectation that you'll do an ASSERT_TRUE() on the result). |
114 // The returned pointer will only be valid until another message is received | 116 // The returned pointer will only be valid until another message is received |
115 // or the list is cleared. | 117 // or the list is cleared. |
116 const Message* GetUniqueMessageMatching(uint32 id) const; | 118 const Message* GetUniqueMessageMatching(uint32_t id) const; |
117 | 119 |
118 // Adds the given listener as a filter to the TestSink. | 120 // Adds the given listener as a filter to the TestSink. |
119 // When a message is received by the TestSink, it will be dispatched to | 121 // When a message is received by the TestSink, it will be dispatched to |
120 // the filters, in the order they were added. If a filter returns true | 122 // the filters, in the order they were added. If a filter returns true |
121 // from OnMessageReceived, subsequent filters will not receive the message | 123 // from OnMessageReceived, subsequent filters will not receive the message |
122 // and the TestSink will not store it. | 124 // and the TestSink will not store it. |
123 void AddFilter(Listener* filter); | 125 void AddFilter(Listener* filter); |
124 | 126 |
125 // Removes the given filter from the TestSink. | 127 // Removes the given filter from the TestSink. |
126 void RemoveFilter(Listener* filter); | 128 void RemoveFilter(Listener* filter); |
127 | 129 |
128 private: | 130 private: |
129 // The actual list of received messages. | 131 // The actual list of received messages. |
130 std::vector<Message> messages_; | 132 std::vector<Message> messages_; |
131 base::ObserverList<Listener> filter_list_; | 133 base::ObserverList<Listener> filter_list_; |
132 | 134 |
133 DISALLOW_COPY_AND_ASSIGN(TestSink); | 135 DISALLOW_COPY_AND_ASSIGN(TestSink); |
134 }; | 136 }; |
135 | 137 |
136 } // namespace IPC | 138 } // namespace IPC |
137 | 139 |
138 #endif // IPC_IPC_TEST_SINK_H_ | 140 #endif // IPC_IPC_TEST_SINK_H_ |
OLD | NEW |