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

Unified Diff: ipc/ipc_test_sink.cc

Issue 6387007: Add support for attaching filters to an IPC TestSink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix brace style issue Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_test_sink.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_test_sink.cc
diff --git a/ipc/ipc_test_sink.cc b/ipc/ipc_test_sink.cc
index 95900b6ca5074a164b45491431ffc7e86e5e9b66..44042390727c75455a5758e16cb55c1be521610a 100644
--- a/ipc/ipc_test_sink.cc
+++ b/ipc/ipc_test_sink.cc
@@ -21,6 +21,14 @@ bool TestSink::Send(Message* message) {
}
bool TestSink::OnMessageReceived(const Message& msg) {
+ ObserverListBase<Channel::Listener>::Iterator it(filter_list_);
+ Channel::Listener* observer;
+ while ((observer = it.GetNext()) != NULL) {
+ if (observer->OnMessageReceived(msg))
+ return true;
+ }
+
+ // No filter handled the message, so store it.
messages_.push_back(Message(msg));
return true;
}
@@ -57,4 +65,12 @@ const Message* TestSink::GetUniqueMessageMatching(uint32 id) const {
return &messages_[found_index];
}
+void TestSink::AddFilter(Channel::Listener* filter) {
+ filter_list_.AddObserver(filter);
+}
+
+void TestSink::RemoveFilter(Channel::Listener* filter) {
+ filter_list_.RemoveObserver(filter);
+}
+
} // namespace IPC
« no previous file with comments | « ipc/ipc_test_sink.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698