Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: ipc/ipc_test_sink.h

Issue 10698057: Remove Message::Sender and Channel::Listener typedefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ipc/ipc_sync_channel.cc ('k') | ipc/ipc_test_sink.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // 46 //
47 // IPC::Message* msg = test_sink.GetUniqueMessageMatching(IPC_REPLY_ID); 47 // IPC::Message* msg = test_sink.GetUniqueMessageMatching(IPC_REPLY_ID);
48 // ASSERT_TRUE(msg); 48 // ASSERT_TRUE(msg);
49 // TupleTypes<ViewHostMsg_Foo::ReplyParam>::ValueTuple reply_data; 49 // TupleTypes<ViewHostMsg_Foo::ReplyParam>::ValueTuple reply_data;
50 // EXPECT_TRUE(ViewHostMsg_Foo::ReadReplyParam(msg, &reply_data)); 50 // EXPECT_TRUE(ViewHostMsg_Foo::ReadReplyParam(msg, &reply_data));
51 // 51 //
52 // You can also register to be notified when messages are posted to the sink. 52 // You can also register to be notified when messages are posted to the sink.
53 // This can be useful if you need to wait for a particular message that will 53 // This can be useful if you need to wait for a particular message that will
54 // be posted asynchronously. Example usage: 54 // be posted asynchronously. Example usage:
55 // 55 //
56 // class MyListener : public IPC::Channel::Listener { 56 // class MyListener : public IPC::Listener {
57 // public: 57 // public:
58 // virtual bool OnMessageReceived(const IPC::Message& msg) { 58 // virtual bool OnMessageReceived(const IPC::Message& msg) {
59 // <do something with the message> 59 // <do something with the message>
60 // MessageLoop::current()->Quit(); 60 // MessageLoop::current()->Quit();
61 // return false; // to store the message in the sink, or true to drop it 61 // return false; // to store the message in the sink, or true to drop it
62 // } 62 // }
63 // }; 63 // };
64 // 64 //
65 // MyListener listener; 65 // MyListener listener;
66 // test_sink.AddFilter(&listener); 66 // test_sink.AddFilter(&listener);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // (with the expectation that you'll do an ASSERT_TRUE() on the result). 105 // (with the expectation that you'll do an ASSERT_TRUE() on the result).
106 // The returned pointer will only be valid until another message is received 106 // The returned pointer will only be valid until another message is received
107 // or the list is cleared. 107 // or the list is cleared.
108 const Message* GetUniqueMessageMatching(uint32 id) const; 108 const Message* GetUniqueMessageMatching(uint32 id) const;
109 109
110 // Adds the given listener as a filter to the TestSink. 110 // Adds the given listener as a filter to the TestSink.
111 // When a message is received by the TestSink, it will be dispatched to 111 // When a message is received by the TestSink, it will be dispatched to
112 // the filters, in the order they were added. If a filter returns true 112 // the filters, in the order they were added. If a filter returns true
113 // from OnMessageReceived, subsequent filters will not receive the message 113 // from OnMessageReceived, subsequent filters will not receive the message
114 // and the TestSink will not store it. 114 // and the TestSink will not store it.
115 void AddFilter(Channel::Listener* filter); 115 void AddFilter(Listener* filter);
116 116
117 // Removes the given filter from the TestSink. 117 // Removes the given filter from the TestSink.
118 void RemoveFilter(Channel::Listener* filter); 118 void RemoveFilter(Listener* filter);
119 119
120 private: 120 private:
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<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_
OLDNEW
« no previous file with comments | « ipc/ipc_sync_channel.cc ('k') | ipc/ipc_test_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698