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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/files/scoped_file.h" | 11 #include "base/files/scoped_file.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "components/arc/arc_bridge_bootstrap.h" | 14 #include "components/arc/arc_bridge_bootstrap.h" |
15 #include "components/arc/arc_bridge_service.h" | 15 #include "components/arc/arc_bridge_service.h" |
16 #include "mojo/public/cpp/bindings/binding.h" | 16 #include "mojo/public/cpp/bindings/binding.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class SequencedTaskRunner; | 19 class SequencedTaskRunner; |
20 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
21 } // namespace base | 21 } // namespace base |
22 | 22 |
23 namespace arc { | 23 namespace arc { |
24 | 24 |
25 // Real IPC based ArcBridgeService that is used in production. | 25 // Real IPC based ArcBridgeService that is used in production. |
26 class ArcBridgeServiceImpl : public ArcBridgeService, | 26 class ArcBridgeServiceImpl : public ArcBridgeService, |
| 27 public ArcBridgeHost, |
27 public ArcBridgeBootstrap::Delegate { | 28 public ArcBridgeBootstrap::Delegate { |
28 public: | 29 public: |
29 explicit ArcBridgeServiceImpl(scoped_ptr<ArcBridgeBootstrap> bootstrap); | 30 explicit ArcBridgeServiceImpl(scoped_ptr<ArcBridgeBootstrap> bootstrap); |
30 ~ArcBridgeServiceImpl() override; | 31 ~ArcBridgeServiceImpl() override; |
31 | 32 |
32 void DetectAvailability() override; | 33 void DetectAvailability() override; |
33 | 34 |
34 void HandleStartup() override; | 35 void HandleStartup() override; |
35 | 36 |
36 void Shutdown() override; | 37 void Shutdown() override; |
37 | 38 |
| 39 bool RegisterInputDevice(const std::string& name, |
| 40 const std::string& device_type, |
| 41 base::ScopedFD fd) override; |
| 42 |
| 43 bool SendBroadcast(const std::string& action, |
| 44 const std::string& package, |
| 45 const std::string& clazz, |
| 46 const base::DictionaryValue& extras) override; |
| 47 |
| 48 bool SendNotificationEventToAndroid(const std::string& key, |
| 49 ArcNotificationEvent event) override; |
| 50 |
| 51 // Requests to refresh an app list. |
| 52 bool RefreshAppList() override; |
| 53 |
| 54 // Requests to launch an app. |
| 55 bool LaunchApp(const std::string& package, |
| 56 const std::string& activity) override; |
| 57 |
| 58 // Requests to load an icon of specific scale_factor. |
| 59 bool RequestAppIcon(const std::string& package, |
| 60 const std::string& activity, |
| 61 ScaleFactor scale_factor) override; |
| 62 |
| 63 // Requests ARC process list. |
| 64 bool RequestProcessList() override; |
| 65 |
38 private: | 66 private: |
39 friend class ArcBridgeTest; | 67 friend class ArcBridgeTest; |
40 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); | 68 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); |
41 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); | 69 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); |
42 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); | 70 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); |
43 | 71 |
44 // If all pre-requisites are true (ARC is available, it has been enabled, and | 72 // If all pre-requisites are true (ARC is available, it has been enabled, and |
45 // the session has started), and ARC is stopped, start ARC. If ARC is running | 73 // the session has started), and ARC is stopped, start ARC. If ARC is running |
46 // and the pre-requisites stop being true, stop ARC. | 74 // and the pre-requisites stop being true, stop ARC. |
47 void PrerequisitesChanged(); | 75 void PrerequisitesChanged(); |
48 | 76 |
49 // Stops the running instance. | 77 // Stops the running instance. |
50 void StopInstance(); | 78 void StopInstance(); |
51 | 79 |
| 80 // Called when the instance has reached a boot phase |
| 81 void OnInstanceBootPhase(InstanceBootPhase phase) override; |
| 82 // Handler for ArcInstanceHostMsg_NotificationPosted message. |
| 83 void OnNotificationPosted(ArcNotificationDataPtr data) override; |
| 84 // Handler for ArcInstanceHostMsg_NotificationRemoved message. |
| 85 void OnNotificationRemoved(const mojo::String& key) override; |
| 86 |
| 87 // Called whenever ARC sends information about available apps. |
| 88 void OnAppListRefreshed(mojo::Array<arc::AppInfoPtr> apps) override; |
| 89 |
| 90 // Called whenever ARC sends app icon data for specific scale factor. |
| 91 void OnAppIcon(const mojo::String& package, |
| 92 const mojo::String& activity, |
| 93 ScaleFactor scale_factor, |
| 94 mojo::Array<uint8_t> icon_png_data) override; |
| 95 |
| 96 // Called when the latest process list is reported from ARC. |
| 97 void OnUpdateProcessList( |
| 98 mojo::Array<RunningAppProcessInfoPtr> processes_ptr) override; |
| 99 |
| 100 // Called when the instance requests wake lock services |
| 101 void OnAcquireDisplayWakeLock(DisplayWakeLockType type) override; |
| 102 void OnReleaseDisplayWakeLock(DisplayWakeLockType type) override; |
| 103 |
52 // ArcBridgeBootstrap::Delegate: | 104 // ArcBridgeBootstrap::Delegate: |
53 void OnConnectionEstablished(ArcBridgeInstancePtr instance) override; | 105 void OnConnectionEstablished(ArcBridgeInstancePtr instance) override; |
54 void OnStopped() override; | 106 void OnStopped() override; |
55 | 107 |
56 // DBus callbacks. | 108 // DBus callbacks. |
57 void OnArcAvailable(bool available); | 109 void OnArcAvailable(bool available); |
58 | 110 |
59 scoped_ptr<ArcBridgeBootstrap> bootstrap_; | 111 scoped_ptr<ArcBridgeBootstrap> bootstrap_; |
60 | 112 |
61 // Mojo endpoints. | 113 // Mojo endpoints. |
62 mojo::Binding<ArcBridgeHost> binding_; | 114 mojo::Binding<ArcBridgeHost> binding_; |
63 ArcBridgeInstancePtr instance_ptr_; | 115 ArcBridgeInstancePtr instance_ptr_; |
64 | 116 |
65 // If the user's session has started. | 117 // If the user's session has started. |
66 bool session_started_; | 118 bool session_started_; |
67 | 119 |
68 // WeakPtrFactory to use callbacks. | 120 // WeakPtrFactory to use callbacks. |
69 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_; | 121 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_; |
70 | 122 |
71 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl); | 123 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl); |
72 }; | 124 }; |
73 | 125 |
74 } // namespace arc | 126 } // namespace arc |
75 | 127 |
76 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ | 128 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ |
OLD | NEW |