summaryrefslogtreecommitdiffstats
path: root/ipc/ipc_test_channel_listener.h
diff options
context:
space:
mode:
authormorrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-04 23:44:17 +0000
committermorrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-04 23:44:17 +0000
commit6486088e8bb6dc810157503edfa3c75a58e9e49d (patch)
treeeda9fabacac5b6796c142ec4cc402b47bdf97dd8 /ipc/ipc_test_channel_listener.h
parentd93dbd1248f4e556c9c1c1005f5d051e3fe1efc8 (diff)
downloadchromium_src-6486088e8bb6dc810157503edfa3c75a58e9e49d.zip
chromium_src-6486088e8bb6dc810157503edfa3c75a58e9e49d.tar.gz
chromium_src-6486088e8bb6dc810157503edfa3c75a58e9e49d.tar.bz2
Introduce ChannelMojo
This CL introduces ChannelMojo IPC::Channel implementation and optionally applies it for renderer-browser IPC channel. Current stability is like 5-seconds browser and There are rough edges. It often closes the channel so needs to be more robust. Even though the level of stability, having it in the tree will helps team to try and improve it. BUG=377980 R=darin@chromium.org,jam@chromium.org,viettrungluu@chromium.org TEST=ipc_channel_mojo_unittest.cc Review URL: https://codereview.chromium.org/382333002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287402 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_test_channel_listener.h')
-rw-r--r--ipc/ipc_test_channel_listener.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/ipc/ipc_test_channel_listener.h b/ipc/ipc_test_channel_listener.h
new file mode 100644
index 0000000..047e15d
--- /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_