| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // | 71 // |
| 72 // To hook up the sink, all you need to do is call OnMessageReceived when a | 72 // To hook up the sink, all you need to do is call OnMessageReceived when a |
| 73 // message is received. | 73 // message is received. |
| 74 class TestSink : public Channel { | 74 class TestSink : public Channel { |
| 75 public: | 75 public: |
| 76 TestSink(); | 76 TestSink(); |
| 77 virtual ~TestSink(); | 77 virtual ~TestSink(); |
| 78 | 78 |
| 79 // Interface in IPC::Channel. This copies the message to the sink and then | 79 // Interface in IPC::Channel. This copies the message to the sink and then |
| 80 // deletes it. | 80 // deletes it. |
| 81 virtual bool Send(IPC::Message* message); | 81 virtual bool Send(IPC::Message* message) OVERRIDE; |
| 82 | 82 |
| 83 // Used by the source of the messages to send the message to the sink. This | 83 // Used by the source of the messages to send the message to the sink. This |
| 84 // will make a copy of the message and store it in the list. | 84 // will make a copy of the message and store it in the list. |
| 85 bool OnMessageReceived(const Message& msg); | 85 bool OnMessageReceived(const Message& msg); |
| 86 | 86 |
| 87 // Returns the number of messages in the queue. | 87 // Returns the number of messages in the queue. |
| 88 size_t message_count() const { return messages_.size(); } | 88 size_t message_count() const { return messages_.size(); } |
| 89 | 89 |
| 90 // Clears the message queue of saved messages. | 90 // Clears the message queue of saved messages. |
| 91 void ClearMessages(); | 91 void ClearMessages(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 121 // The actual list of received messages. | 121 // The actual list of received messages. |
| 122 std::vector<Message> messages_; | 122 std::vector<Message> messages_; |
| 123 ObserverList<Channel::Listener> filter_list_; | 123 ObserverList<Channel::Listener> filter_list_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(TestSink); | 125 DISALLOW_COPY_AND_ASSIGN(TestSink); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 } // namespace IPC | 128 } // namespace IPC |
| 129 | 129 |
| 130 #endif // IPC_IPC_TEST_SINK_H_ | 130 #endif // IPC_IPC_TEST_SINK_H_ |
| OLD | NEW |