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

Unified Diff: ipc/mojo/ipc_channel_mojo_readers.h

Issue 559723002: Refactoring: Move MessagePipeReader subclasess out from ChannelMojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Landing Created 6 years, 3 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/mojo/ipc_channel_mojo.cc ('k') | ipc/mojo/ipc_channel_mojo_readers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/mojo/ipc_channel_mojo_readers.h
diff --git a/ipc/mojo/ipc_channel_mojo_readers.h b/ipc/mojo/ipc_channel_mojo_readers.h
new file mode 100644
index 0000000000000000000000000000000000000000..13ddeada45dabe40fb951c6c4951c9e311d54564
--- /dev/null
+++ b/ipc/mojo/ipc_channel_mojo_readers.h
@@ -0,0 +1,102 @@
+// 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_MOJO_IPC_CHANNEL_MOJO_READERS_H_
+#define IPC_MOJO_IPC_CHANNEL_MOJO_READERS_H_
+
+#include <vector>
+
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "ipc/mojo/ipc_message_pipe_reader.h"
+#include "mojo/public/cpp/system/core.h"
+
+namespace mojo {
+namespace embedder {
+struct ChannelInfo;
+}
+}
+
+namespace IPC {
+
+class ChannelMojo;
+class Message;
+
+namespace internal {
+
+// A MessagePipeReader implementation for IPC::Message communication.
+class MessageReader : public MessagePipeReader {
+ public:
+ MessageReader(mojo::ScopedMessagePipeHandle pipe, ChannelMojo* owner);
+
+ bool Send(scoped_ptr<Message> message);
+
+ // MessagePipeReader implementation
+ virtual void OnMessageReceived() OVERRIDE;
+ virtual void OnPipeClosed() OVERRIDE;
+ virtual void OnPipeError(MojoResult error) OVERRIDE;
+
+ private:
+ ChannelMojo* owner_;
+
+ DISALLOW_COPY_AND_ASSIGN(MessageReader);
+};
+
+// MessagePipeReader implementation for control messages.
+// Actual message handling is implemented by sublcasses.
+class ControlReader : public MessagePipeReader {
+ public:
+ ControlReader(mojo::ScopedMessagePipeHandle pipe, ChannelMojo* owner);
+
+ virtual bool Connect();
+
+ // MessagePipeReader implementation
+ virtual void OnPipeClosed() OVERRIDE;
+ virtual void OnPipeError(MojoResult error) OVERRIDE;
+
+ protected:
+ ChannelMojo* owner_;
+
+ DISALLOW_COPY_AND_ASSIGN(ControlReader);
+};
+
+// ControlReader for server-side ChannelMojo.
+class ServerControlReader : public ControlReader {
+ public:
+ ServerControlReader(mojo::ScopedMessagePipeHandle pipe, ChannelMojo* owner);
+ virtual ~ServerControlReader();
+
+ // ControlReader override
+ virtual bool Connect() OVERRIDE;
+
+ // MessagePipeReader implementation
+ virtual void OnMessageReceived() OVERRIDE;
+
+ private:
+ MojoResult SendHelloRequest();
+ MojoResult RespondHelloResponse();
+
+ mojo::ScopedMessagePipeHandle message_pipe_;
+
+ DISALLOW_COPY_AND_ASSIGN(ServerControlReader);
+};
+
+// ControlReader for client-side ChannelMojo.
+class ClientControlReader : public ControlReader {
+ public:
+ ClientControlReader(mojo::ScopedMessagePipeHandle pipe, ChannelMojo* owner);
+
+ // MessagePipeReader implementation
+ virtual void OnMessageReceived() OVERRIDE;
+
+ private:
+ MojoResult RespondHelloRequest(MojoHandle message_channel);
+
+ DISALLOW_COPY_AND_ASSIGN(ClientControlReader);
+};
+
+} // namespace internal
+} // namespace IPC
+
+#endif // IPC_MOJO_IPC_CHANNEL_MOJO_READERS_H_
« no previous file with comments | « ipc/mojo/ipc_channel_mojo.cc ('k') | ipc/mojo/ipc_channel_mojo_readers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698