summaryrefslogtreecommitdiffstats
path: root/ipc/ipc_test_sink.cc
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-03 02:19:49 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-03 02:19:49 +0000
commit8cf3f1dae79db8cfbf9dc6b75c140eabad918a6e (patch)
tree89e93505cc275c0a22b5ca7d95c5f03cfacff6a1 /ipc/ipc_test_sink.cc
parent343b7211ff31670cded0f85fa8a056fa6cf7a9f3 (diff)
downloadchromium_src-8cf3f1dae79db8cfbf9dc6b75c140eabad918a6e.zip
chromium_src-8cf3f1dae79db8cfbf9dc6b75c140eabad918a6e.tar.gz
chromium_src-8cf3f1dae79db8cfbf9dc6b75c140eabad918a6e.tar.bz2
Move IPC code to ipc/
(No review URL: Rietvelt couldn't cope) git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13062 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_test_sink.cc')
-rw-r--r--ipc/ipc_test_sink.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/ipc/ipc_test_sink.cc b/ipc/ipc_test_sink.cc
new file mode 100644
index 0000000..1f1ce3f
--- /dev/null
+++ b/ipc/ipc_test_sink.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ipc/ipc_test_sink.h"
+
+namespace IPC {
+
+TestSink::TestSink() {
+}
+
+TestSink::~TestSink() {
+}
+
+void TestSink::OnMessageReceived(const Message& msg) {
+ messages_.push_back(Message(msg));
+}
+
+void TestSink::ClearMessages() {
+ messages_.clear();
+}
+
+const Message* TestSink::GetMessageAt(size_t index) const {
+ if (index >= messages_.size())
+ return NULL;
+ return &messages_[index];
+}
+
+const Message* TestSink::GetFirstMessageMatching(uint16 id) const {
+ for (size_t i = 0; i < messages_.size(); i++) {
+ if (messages_[i].type() == id)
+ return &messages_[i];
+ }
+ return NULL;
+}
+
+const Message* TestSink::GetUniqueMessageMatching(uint16 id) const {
+ size_t found_index = 0;
+ size_t found_count = 0;
+ for (size_t i = 0; i < messages_.size(); i++) {
+ if (messages_[i].type() == id) {
+ found_count++;
+ found_index = i;
+ }
+ }
+ if (found_count != 1)
+ return NULL; // Didn't find a unique one.
+ return &messages_[found_index];
+}
+
+} // namespace IPC