Index: chromeos/arc/libarcbridge/arc_bridge.h |
diff --git a/chromeos/arc/libarcbridge/arc_bridge.h b/chromeos/arc/libarcbridge/arc_bridge.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..32934740c71a1dd4fa250b7e7e6ee0f4298407b9 |
--- /dev/null |
+++ b/chromeos/arc/libarcbridge/arc_bridge.h |
@@ -0,0 +1,77 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
satorux1
2015/10/23 05:16:43
Can we drop 'lib' from the directory name? Directo
Luis Héctor Chávez
2015/10/23 17:09:24
The reason for the separation is that I need to ha
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
satorux1
2015/10/23 05:16:43
Because the concept of ARC Bridge is not obvious,
Luis Héctor Chávez
2015/10/23 17:09:24
Done.
|
+ |
+#ifndef CHROMEOS_ARC_LIBARCBRIDGE_ARC_ARC_BRIDGE_H_ |
+#define CHROMEOS_ARC_LIBARCBRIDGE_ARC_ARC_BRIDGE_H_ |
+ |
+#include "base/macros.h" |
+#include "ipc/ipc_channel_proxy.h" |
+#include "ipc/ipc_listener.h" |
+#include "ipc/ipc_message.h" |
+ |
+namespace arc { |
+ |
+// Abstract class that represents one of the ARC bridge endpoints. |
+class BridgeEndpoint : public IPC::Listener { |
+ public: |
+ BridgeEndpoint(); |
+ virtual ~BridgeEndpoint(); |
+ |
+ bool Connect(const IPC::ChannelHandle& handle, IPC::Channel::Mode mode); |
satorux1
2015/10/23 05:16:43
function comment is missing. Please fix other plac
Luis Héctor Chávez
2015/10/23 17:09:24
Done.
|
+ |
+ protected: |
+ scoped_ptr<IPC::ChannelProxy> channel_; |
+ |
+ private: |
+ base::Thread io_thread_; |
satorux1
2015/10/23 05:16:43
"IO thread" in Chrome usually means BrowserThread:
Luis Héctor Chávez
2015/10/23 17:09:24
Done.
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(BridgeEndpoint); |
+}; |
+ |
+// Instance side of the ARC bridge. |
+class BridgeInstanceEndpoint : public BridgeEndpoint { |
+ public: |
+ BridgeInstanceEndpoint(); |
+ virtual ~BridgeInstanceEndpoint(); |
+ |
+ bool SocketConnect(const char* socket_path); |
satorux1
2015/10/23 05:16:43
How about const std::string&? I guess NULL is not
Luis Héctor Chávez
2015/10/23 17:09:24
Done.
|
+ |
+ // Messages from the instance to the host. |
+ bool InstanceReady(); |
+ |
+ private: |
+ bool OnMessageReceived(const IPC::Message& message) override; |
+ void OnPing(); |
+ virtual void OnRegisterInputDevice(const std::string& name, |
+ const std::string& device_type, |
+ base::FileDescriptor fd) = 0; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BridgeInstanceEndpoint); |
+}; |
+ |
+// Host side of the ARC bridge. |
+class BridgeHostEndpoint : public BridgeEndpoint { |
+ public: |
+ BridgeHostEndpoint(); |
+ virtual ~BridgeHostEndpoint(); |
+ |
+ bool SocketConnect(const char* socket_path); |
+ |
+ // Messages from the host to the instance. |
+ bool Ping(); |
+ bool RegisterInputDevice(const std::string& name, |
+ const std::string& device_type, |
+ base::ScopedFD fd); |
+ |
+ private: |
+ bool OnMessageReceived(const IPC::Message& message) override; |
+ virtual void OnInstanceReady() = 0; |
+ virtual void OnPong() = 0; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BridgeHostEndpoint); |
+}; |
+ |
+} // namespace arc |
+ |
+#endif // CHROMEOS_ARC_LIBARCBRIDGE_ARC_ARC_BRIDGE_H_ |