| 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 <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // To hook up the sink, all you need to do is call OnMessageReceived when a | 71 // To hook up the sink, all you need to do is call OnMessageReceived when a |
| 72 // message is received. | 72 // message is received. |
| 73 class TestSink : public Channel { | 73 class TestSink : public Channel { |
| 74 public: | 74 public: |
| 75 TestSink(); | 75 TestSink(); |
| 76 virtual ~TestSink(); | 76 virtual ~TestSink(); |
| 77 | 77 |
| 78 // Interface in IPC::Channel. This copies the message to the sink and then | 78 // Interface in IPC::Channel. This copies the message to the sink and then |
| 79 // deletes it. | 79 // deletes it. |
| 80 virtual bool Send(IPC::Message* message) OVERRIDE; | 80 virtual bool Send(IPC::Message* message) OVERRIDE; |
| 81 virtual bool Connect() WARN_UNUSED_RESULT OVERRIDE; |
| 82 virtual void Close() OVERRIDE; |
| 83 virtual base::ProcessId GetPeerPID() const OVERRIDE; |
| 84 |
| 85 #if defined(OS_POSIX) && !defined(OS_NACL) |
| 86 virtual int GetClientFileDescriptor() const OVERRIDE; |
| 87 virtual int TakeClientFileDescriptor() OVERRIDE; |
| 88 virtual bool AcceptsConnections() const OVERRIDE; |
| 89 virtual bool HasAcceptedConnection() const OVERRIDE; |
| 90 virtual bool GetPeerEuid(uid_t* peer_euid) const OVERRIDE; |
| 91 virtual void ResetToAcceptingConnectionState() OVERRIDE; |
| 92 #endif // defined(OS_POSIX) && !defined(OS_NACL) |
| 81 | 93 |
| 82 // Used by the source of the messages to send the message to the sink. This | 94 // Used by the source of the messages to send the message to the sink. This |
| 83 // will make a copy of the message and store it in the list. | 95 // will make a copy of the message and store it in the list. |
| 84 bool OnMessageReceived(const Message& msg); | 96 bool OnMessageReceived(const Message& msg); |
| 85 | 97 |
| 86 // Returns the number of messages in the queue. | 98 // Returns the number of messages in the queue. |
| 87 size_t message_count() const { return messages_.size(); } | 99 size_t message_count() const { return messages_.size(); } |
| 88 | 100 |
| 89 // Clears the message queue of saved messages. | 101 // Clears the message queue of saved messages. |
| 90 void ClearMessages(); | 102 void ClearMessages(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 120 // The actual list of received messages. | 132 // The actual list of received messages. |
| 121 std::vector<Message> messages_; | 133 std::vector<Message> messages_; |
| 122 ObserverList<Listener> filter_list_; | 134 ObserverList<Listener> filter_list_; |
| 123 | 135 |
| 124 DISALLOW_COPY_AND_ASSIGN(TestSink); | 136 DISALLOW_COPY_AND_ASSIGN(TestSink); |
| 125 }; | 137 }; |
| 126 | 138 |
| 127 } // namespace IPC | 139 } // namespace IPC |
| 128 | 140 |
| 129 #endif // IPC_IPC_TEST_SINK_H_ | 141 #endif // IPC_IPC_TEST_SINK_H_ |
| OLD | NEW |