Chromium Code Reviews| 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> | |
|
Tom Sepez
2015/09/03 19:53:09
nit: ditto
tfarina
2015/09/04 14:01:14
Done.
| |
| 8 #include <utility> | 9 #include <utility> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 12 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 13 #include "ipc/ipc_channel.h" | 14 #include "ipc/ipc_channel.h" |
| 14 | 15 |
| 15 namespace IPC { | 16 namespace IPC { |
| 16 | 17 |
| 17 class Message; | 18 class Message; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 void ClearMessages(); | 100 void ClearMessages(); |
| 100 | 101 |
| 101 // Returns the message at the given index in the queue. The index may be out | 102 // 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 | 103 // 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. | 104 // only be valid until another message is received or the list is cleared. |
| 104 const Message* GetMessageAt(size_t index) const; | 105 const Message* GetMessageAt(size_t index) const; |
| 105 | 106 |
| 106 // Returns the first message with the given ID in the queue. If there is no | 107 // 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 | 108 // 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. | 109 // valid until another message is received or the list is cleared. |
| 109 const Message* GetFirstMessageMatching(uint32 id) const; | 110 const Message* GetFirstMessageMatching(uint32_t id) const; |
| 110 | 111 |
| 111 // Returns the message with the given ID in the queue. If there is no such | 112 // 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 | 113 // 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). | 114 // (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 | 115 // The returned pointer will only be valid until another message is received |
| 115 // or the list is cleared. | 116 // or the list is cleared. |
| 116 const Message* GetUniqueMessageMatching(uint32 id) const; | 117 const Message* GetUniqueMessageMatching(uint32_t id) const; |
| 117 | 118 |
| 118 // Adds the given listener as a filter to the TestSink. | 119 // Adds the given listener as a filter to the TestSink. |
| 119 // When a message is received by the TestSink, it will be dispatched to | 120 // 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 | 121 // the filters, in the order they were added. If a filter returns true |
| 121 // from OnMessageReceived, subsequent filters will not receive the message | 122 // from OnMessageReceived, subsequent filters will not receive the message |
| 122 // and the TestSink will not store it. | 123 // and the TestSink will not store it. |
| 123 void AddFilter(Listener* filter); | 124 void AddFilter(Listener* filter); |
| 124 | 125 |
| 125 // Removes the given filter from the TestSink. | 126 // Removes the given filter from the TestSink. |
| 126 void RemoveFilter(Listener* filter); | 127 void RemoveFilter(Listener* filter); |
| 127 | 128 |
| 128 private: | 129 private: |
| 129 // The actual list of received messages. | 130 // The actual list of received messages. |
| 130 std::vector<Message> messages_; | 131 std::vector<Message> messages_; |
| 131 base::ObserverList<Listener> filter_list_; | 132 base::ObserverList<Listener> filter_list_; |
| 132 | 133 |
| 133 DISALLOW_COPY_AND_ASSIGN(TestSink); | 134 DISALLOW_COPY_AND_ASSIGN(TestSink); |
| 134 }; | 135 }; |
| 135 | 136 |
| 136 } // namespace IPC | 137 } // namespace IPC |
| 137 | 138 |
| 138 #endif // IPC_IPC_TEST_SINK_H_ | 139 #endif // IPC_IPC_TEST_SINK_H_ |
| OLD | NEW |