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

Unified Diff: ipc/ipc_test_channel_listener.h

Issue 382333002: Introduce ChannelMojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
Index: ipc/ipc_test_channel_listener.h
diff --git a/ipc/ipc_test_channel_listener.h b/ipc/ipc_test_channel_listener.h
new file mode 100644
index 0000000000000000000000000000000000000000..047e15d08885e25ed33fcb55ccd7d0a6e133b693
--- /dev/null
+++ b/ipc/ipc_test_channel_listener.h
@@ -0,0 +1,44 @@
+// Copyright 2014 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.
+
+#ifndef IPC_IPC_TEST_CHANNEL_LISTENER_H_
+#define IPC_IPC_TEST_CHANNEL_LISTENER_H_
+
+#include "ipc/ipc_listener.h"
+
+namespace IPC {
+
+class Sender;
+
+// A generic listener that expects messages of a certain type (see
+// OnMessageReceived()), and either sends a generic response or quits after the
+// 50th message (or on channel error).
+class TestChannelListener : public Listener {
+ public:
+ static const size_t kLongMessageStringNumBytes = 50000;
+ static void SendOneMessage(Sender* sender, const char* text);
+
+ TestChannelListener() : sender_(NULL), messages_left_(50) {}
+ virtual ~TestChannelListener() {}
+
+ virtual bool OnMessageReceived(const Message& message) OVERRIDE;
+ virtual void OnChannelError() OVERRIDE;
+
+ void Init(Sender* s) {
+ sender_ = s;
+ }
+
+ bool HasSentAll() const { return 0 == messages_left_; }
+
+ protected:
+ void SendNextMessage();
+
+ private:
+ Sender* sender_;
+ int messages_left_;
+};
+
+}
+
+#endif // IPC_IPC_TEST_CHANNEL_LISTENER_H_
« ipc/ipc_channel.h ('K') | « ipc/ipc_test_base.cc ('k') | ipc/ipc_test_channel_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698