Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // 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
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // 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.
| |
| 4 | |
| 5 #ifndef CHROMEOS_ARC_LIBARCBRIDGE_ARC_ARC_BRIDGE_H_ | |
| 6 #define CHROMEOS_ARC_LIBARCBRIDGE_ARC_ARC_BRIDGE_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "ipc/ipc_channel_proxy.h" | |
| 10 #include "ipc/ipc_listener.h" | |
| 11 #include "ipc/ipc_message.h" | |
| 12 | |
| 13 namespace arc { | |
| 14 | |
| 15 // Abstract class that represents one of the ARC bridge endpoints. | |
| 16 class BridgeEndpoint : public IPC::Listener { | |
| 17 public: | |
| 18 BridgeEndpoint(); | |
| 19 virtual ~BridgeEndpoint(); | |
| 20 | |
| 21 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.
| |
| 22 | |
| 23 protected: | |
| 24 scoped_ptr<IPC::ChannelProxy> channel_; | |
| 25 | |
| 26 private: | |
| 27 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.
| |
| 28 | |
| 29 DISALLOW_COPY_AND_ASSIGN(BridgeEndpoint); | |
| 30 }; | |
| 31 | |
| 32 // Instance side of the ARC bridge. | |
| 33 class BridgeInstanceEndpoint : public BridgeEndpoint { | |
| 34 public: | |
| 35 BridgeInstanceEndpoint(); | |
| 36 virtual ~BridgeInstanceEndpoint(); | |
| 37 | |
| 38 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.
| |
| 39 | |
| 40 // Messages from the instance to the host. | |
| 41 bool InstanceReady(); | |
| 42 | |
| 43 private: | |
| 44 bool OnMessageReceived(const IPC::Message& message) override; | |
| 45 void OnPing(); | |
| 46 virtual void OnRegisterInputDevice(const std::string& name, | |
| 47 const std::string& device_type, | |
| 48 base::FileDescriptor fd) = 0; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(BridgeInstanceEndpoint); | |
| 51 }; | |
| 52 | |
| 53 // Host side of the ARC bridge. | |
| 54 class BridgeHostEndpoint : public BridgeEndpoint { | |
| 55 public: | |
| 56 BridgeHostEndpoint(); | |
| 57 virtual ~BridgeHostEndpoint(); | |
| 58 | |
| 59 bool SocketConnect(const char* socket_path); | |
| 60 | |
| 61 // Messages from the host to the instance. | |
| 62 bool Ping(); | |
| 63 bool RegisterInputDevice(const std::string& name, | |
| 64 const std::string& device_type, | |
| 65 base::ScopedFD fd); | |
| 66 | |
| 67 private: | |
| 68 bool OnMessageReceived(const IPC::Message& message) override; | |
| 69 virtual void OnInstanceReady() = 0; | |
| 70 virtual void OnPong() = 0; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(BridgeHostEndpoint); | |
| 73 }; | |
| 74 | |
| 75 } // namespace arc | |
| 76 | |
| 77 #endif // CHROMEOS_ARC_LIBARCBRIDGE_ARC_ARC_BRIDGE_H_ | |
| OLD | NEW |