Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ | |
| 6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ | |
| 7 | |
| 8 #include "base/files/scoped_file.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "components/arc/arc_bridge_service.h" | |
| 11 #include "ipc/ipc_channel_proxy.h" | |
| 12 #include "ipc/ipc_listener.h" | |
| 13 #include "ipc/ipc_message.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class SequencedTaskRunner; | |
| 17 class SingleThreadTaskRunner; | |
| 18 } | |
|
hidehiko
2015/11/26 02:21:51
nit: // namespace base
khmel1
2015/11/26 05:46:43
Done.
| |
| 19 | |
| 20 namespace arc { | |
| 21 | |
| 22 // Real IPC based ArcBridgeService that is used in production. | |
| 23 class ArcBridgeServiceImpl : public ArcBridgeService, | |
| 24 public IPC::Listener { | |
| 25 public: | |
| 26 ArcBridgeServiceImpl( | |
| 27 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner, | |
| 28 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner); | |
| 29 ~ArcBridgeServiceImpl() override; | |
| 30 | |
| 31 void DetectAvailability() override; | |
| 32 | |
| 33 void HandleStartup() override; | |
| 34 | |
| 35 void Shutdown() override; | |
| 36 | |
| 37 bool RegisterInputDevice(const std::string& name, | |
| 38 const std::string& device_type, | |
| 39 base::ScopedFD fd) override; | |
| 40 | |
| 41 private: | |
| 42 friend class ArcBridgeTest; | |
| 43 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); | |
| 44 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); | |
| 45 | |
| 46 // If all pre-requisites are true (ARC is available, it has been enabled, and | |
| 47 // the session has started), and ARC is stopped, start ARC. If ARC is running | |
| 48 // and the pre-requisites stop being true, stop ARC. | |
| 49 void PrerequisitesChanged(); | |
| 50 | |
| 51 // Binds to the socket specified by |socket_path|. | |
| 52 void SocketConnect(const base::FilePath& socket_path); | |
| 53 | |
| 54 // Binds to the socket specified by |socket_path| after creating its parent | |
| 55 // directory is present. | |
| 56 void SocketConnectAfterEnsureParentDirectory( | |
| 57 const base::FilePath& socket_path, | |
| 58 bool directory_present); | |
| 59 | |
| 60 // Internal connection method. Separated to make testing easier. | |
| 61 bool Connect(const IPC::ChannelHandle& handle, IPC::Channel::Mode mode); | |
| 62 | |
| 63 // Finishes connecting after setting socket permissions. | |
| 64 void SocketConnectAfterSetSocketPermissions(const base::FilePath& socket_path, | |
| 65 bool socket_permissions_success); | |
| 66 | |
| 67 // Stops the running instance. | |
| 68 void StopInstance(); | |
| 69 | |
| 70 // Called when the instance has reached a boot phase | |
| 71 void OnInstanceBootPhase(InstanceBootPhase phase); | |
| 72 | |
| 73 // IPC::Listener: | |
| 74 bool OnMessageReceived(const IPC::Message& message) override; | |
| 75 | |
| 76 // DBus callbacks. | |
| 77 void OnArcAvailable(bool available); | |
| 78 void OnInstanceStarted(bool success); | |
| 79 void OnInstanceStopped(bool success); | |
| 80 | |
| 81 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; | |
| 82 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; | |
| 83 | |
| 84 scoped_ptr<IPC::ChannelProxy> ipc_channel_; | |
| 85 | |
| 86 // If the user's session has started. | |
| 87 bool session_started_; | |
| 88 | |
| 89 // WeakPtrFactory to use callbacks. | |
| 90 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_; | |
| 91 | |
| 92 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl); | |
| 93 }; | |
| 94 | |
| 95 } // namespace arc | |
| 96 | |
| 97 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ | |
| OLD | NEW |