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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // StartSomeAsynchronousProcess(&test_sink); | 66 // StartSomeAsynchronousProcess(&test_sink); |
67 // MessageLoop::current()->Run(); | 67 // MessageLoop::current()->Run(); |
68 // <inspect the results> | 68 // <inspect the results> |
69 // ... | 69 // ... |
70 // | 70 // |
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 ~TestSink() override; |
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 bool Send(IPC::Message* message) override; |
81 virtual bool Connect() override WARN_UNUSED_RESULT; | 81 bool Connect() override WARN_UNUSED_RESULT; |
82 virtual void Close() override; | 82 void Close() override; |
83 virtual base::ProcessId GetPeerPID() const override; | 83 base::ProcessId GetPeerPID() const override; |
84 virtual base::ProcessId GetSelfPID() const override; | 84 base::ProcessId GetSelfPID() const override; |
85 | 85 |
86 #if defined(OS_POSIX) && !defined(OS_NACL) | 86 #if defined(OS_POSIX) && !defined(OS_NACL) |
87 virtual int GetClientFileDescriptor() const override; | 87 int GetClientFileDescriptor() const override; |
88 virtual base::ScopedFD TakeClientFileDescriptor() override; | 88 base::ScopedFD TakeClientFileDescriptor() override; |
89 #endif // defined(OS_POSIX) && !defined(OS_NACL) | 89 #endif // defined(OS_POSIX) && !defined(OS_NACL) |
90 | 90 |
91 // Used by the source of the messages to send the message to the sink. This | 91 // Used by the source of the messages to send the message to the sink. This |
92 // will make a copy of the message and store it in the list. | 92 // will make a copy of the message and store it in the list. |
93 bool OnMessageReceived(const Message& msg); | 93 bool OnMessageReceived(const Message& msg); |
94 | 94 |
95 // Returns the number of messages in the queue. | 95 // Returns the number of messages in the queue. |
96 size_t message_count() const { return messages_.size(); } | 96 size_t message_count() const { return messages_.size(); } |
97 | 97 |
98 // Clears the message queue of saved messages. | 98 // Clears the message queue of saved messages. |
(...skipping 30 matching lines...) Expand all Loading... |
129 // The actual list of received messages. | 129 // The actual list of received messages. |
130 std::vector<Message> messages_; | 130 std::vector<Message> messages_; |
131 ObserverList<Listener> filter_list_; | 131 ObserverList<Listener> filter_list_; |
132 | 132 |
133 DISALLOW_COPY_AND_ASSIGN(TestSink); | 133 DISALLOW_COPY_AND_ASSIGN(TestSink); |
134 }; | 134 }; |
135 | 135 |
136 } // namespace IPC | 136 } // namespace IPC |
137 | 137 |
138 #endif // IPC_IPC_TEST_SINK_H_ | 138 #endif // IPC_IPC_TEST_SINK_H_ |
OLD | NEW |