| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ | 5 #ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ |
| 6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ | 6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/files/scoped_file.h" | 8 #include "base/files/scoped_file.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "components/arc/arc_bridge_service.h" | 10 #include "components/arc/arc_bridge_service.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 void DetectAvailability() override; | 31 void DetectAvailability() override; |
| 32 | 32 |
| 33 void HandleStartup() override; | 33 void HandleStartup() override; |
| 34 | 34 |
| 35 void Shutdown() override; | 35 void Shutdown() override; |
| 36 | 36 |
| 37 bool RegisterInputDevice(const std::string& name, | 37 bool RegisterInputDevice(const std::string& name, |
| 38 const std::string& device_type, | 38 const std::string& device_type, |
| 39 base::ScopedFD fd) override; | 39 base::ScopedFD fd) override; |
| 40 | 40 |
| 41 bool SendNotificationEventToAndroid(const std::string& key, |
| 42 ArcNotificationEvent event) override; |
| 43 |
| 41 private: | 44 private: |
| 42 friend class ArcBridgeTest; | 45 friend class ArcBridgeTest; |
| 43 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); | 46 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); |
| 44 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); | 47 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); |
| 45 | 48 |
| 46 // If all pre-requisites are true (ARC is available, it has been enabled, and | 49 // 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 | 50 // the session has started), and ARC is stopped, start ARC. If ARC is running |
| 48 // and the pre-requisites stop being true, stop ARC. | 51 // and the pre-requisites stop being true, stop ARC. |
| 49 void PrerequisitesChanged(); | 52 void PrerequisitesChanged(); |
| 50 | 53 |
| 51 // Binds to the socket specified by |socket_path|. | 54 // Binds to the socket specified by |socket_path|. |
| 52 void SocketConnect(const base::FilePath& socket_path); | 55 void SocketConnect(const base::FilePath& socket_path); |
| 53 | 56 |
| 54 // Binds to the socket specified by |socket_path| after creating its parent | 57 // Binds to the socket specified by |socket_path| after creating its parent |
| 55 // directory is present. | 58 // directory is present. |
| 56 void SocketConnectAfterEnsureParentDirectory( | 59 void SocketConnectAfterEnsureParentDirectory( |
| 57 const base::FilePath& socket_path, | 60 const base::FilePath& socket_path, |
| 58 bool directory_present); | 61 bool directory_present); |
| 59 | 62 |
| 63 // Checks if the IPC channel is ready to send messages to Android. |
| 64 bool SendMessageIfReady(IPC::Message* message); |
| 65 |
| 60 // Internal connection method. Separated to make testing easier. | 66 // Internal connection method. Separated to make testing easier. |
| 61 bool Connect(const IPC::ChannelHandle& handle, IPC::Channel::Mode mode); | 67 bool Connect(const IPC::ChannelHandle& handle, IPC::Channel::Mode mode); |
| 62 | 68 |
| 63 // Finishes connecting after setting socket permissions. | 69 // Finishes connecting after setting socket permissions. |
| 64 void SocketConnectAfterSetSocketPermissions(const base::FilePath& socket_path, | 70 void SocketConnectAfterSetSocketPermissions(const base::FilePath& socket_path, |
| 65 bool socket_permissions_success); | 71 bool socket_permissions_success); |
| 66 | 72 |
| 67 // Stops the running instance. | 73 // Stops the running instance. |
| 68 void StopInstance(); | 74 void StopInstance(); |
| 69 | 75 |
| 70 // Called when the instance has reached a boot phase | 76 // Called when the instance has reached a boot phase |
| 71 void OnInstanceBootPhase(InstanceBootPhase phase); | 77 void OnInstanceBootPhase(InstanceBootPhase phase); |
| 78 // Handler for ArcInstanceHostMsg_NotificationPosted message. |
| 79 void OnNotificationPostedFromAndroid(const ArcNotificationData& data); |
| 80 // Handler for ArcInstanceHostMsg_NotificationRemoved message. |
| 81 void OnNotificationRemovedFromAndroid(const std::string& key); |
| 72 | 82 |
| 73 // IPC::Listener: | 83 // IPC::Listener: |
| 74 bool OnMessageReceived(const IPC::Message& message) override; | 84 bool OnMessageReceived(const IPC::Message& message) override; |
| 75 | 85 |
| 76 // DBus callbacks. | 86 // DBus callbacks. |
| 77 void OnArcAvailable(bool available); | 87 void OnArcAvailable(bool available); |
| 78 void OnInstanceStarted(bool success); | 88 void OnInstanceStarted(bool success); |
| 79 void OnInstanceStopped(bool success); | 89 void OnInstanceStopped(bool success); |
| 80 | 90 |
| 81 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; | 91 scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_; |
| 82 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; | 92 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
| 83 | 93 |
| 84 scoped_ptr<IPC::ChannelProxy> ipc_channel_; | 94 scoped_ptr<IPC::ChannelProxy> ipc_channel_; |
| 85 | 95 |
| 86 // If the user's session has started. | 96 // If the user's session has started. |
| 87 bool session_started_; | 97 bool session_started_; |
| 88 | 98 |
| 89 // WeakPtrFactory to use callbacks. | 99 // WeakPtrFactory to use callbacks. |
| 90 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_; | 100 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_; |
| 91 | 101 |
| 92 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl); | 102 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl); |
| 93 }; | 103 }; |
| 94 | 104 |
| 95 } // namespace arc | 105 } // namespace arc |
| 96 | 106 |
| 97 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ | 107 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ |
| OLD | NEW |