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, | |
28 public ArcBridgeBootstrap::Delegate { | 27 public ArcBridgeBootstrap::Delegate { |
29 public: | 28 public: |
30 explicit ArcBridgeServiceImpl(scoped_ptr<ArcBridgeBootstrap> bootstrap); | 29 explicit ArcBridgeServiceImpl(scoped_ptr<ArcBridgeBootstrap> bootstrap); |
31 ~ArcBridgeServiceImpl() override; | 30 ~ArcBridgeServiceImpl() override; |
32 | 31 |
33 void DetectAvailability() override; | 32 void DetectAvailability() override; |
34 | 33 |
35 void HandleStartup() override; | 34 void HandleStartup() override; |
36 | 35 |
37 void Shutdown() override; | 36 void Shutdown() override; |
38 | 37 |
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 | |
66 private: | 38 private: |
67 friend class ArcBridgeTest; | 39 friend class ArcBridgeTest; |
68 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); | 40 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); |
69 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); | 41 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); |
70 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); | 42 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); |
71 | 43 |
72 // If all pre-requisites are true (ARC is available, it has been enabled, and | 44 // If all pre-requisites are true (ARC is available, it has been enabled, and |
73 // the session has started), and ARC is stopped, start ARC. If ARC is running | 45 // the session has started), and ARC is stopped, start ARC. If ARC is running |
74 // and the pre-requisites stop being true, stop ARC. | 46 // and the pre-requisites stop being true, stop ARC. |
75 void PrerequisitesChanged(); | 47 void PrerequisitesChanged(); |
76 | 48 |
77 // Stops the running instance. | 49 // Stops the running instance. |
78 void StopInstance(); | 50 void StopInstance(); |
79 | 51 |
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 | |
104 // ArcBridgeBootstrap::Delegate: | 52 // ArcBridgeBootstrap::Delegate: |
105 void OnConnectionEstablished(ArcBridgeInstancePtr instance) override; | 53 void OnConnectionEstablished(ArcBridgeInstancePtr instance) override; |
106 void OnStopped() override; | 54 void OnStopped() override; |
107 | 55 |
108 // DBus callbacks. | 56 // DBus callbacks. |
109 void OnArcAvailable(bool available); | 57 void OnArcAvailable(bool available); |
110 | 58 |
111 scoped_ptr<ArcBridgeBootstrap> bootstrap_; | 59 scoped_ptr<ArcBridgeBootstrap> bootstrap_; |
112 | 60 |
113 // Mojo endpoints. | 61 // Mojo endpoints. |
114 mojo::Binding<ArcBridgeHost> binding_; | 62 mojo::Binding<ArcBridgeHost> binding_; |
115 ArcBridgeInstancePtr instance_ptr_; | 63 ArcBridgeInstancePtr instance_ptr_; |
116 | 64 |
117 // If the user's session has started. | 65 // If the user's session has started. |
118 bool session_started_; | 66 bool session_started_; |
119 | 67 |
120 // WeakPtrFactory to use callbacks. | 68 // WeakPtrFactory to use callbacks. |
121 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_; | 69 base::WeakPtrFactory<ArcBridgeServiceImpl> weak_factory_; |
122 | 70 |
123 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl); | 71 DISALLOW_COPY_AND_ASSIGN(ArcBridgeServiceImpl); |
124 }; | 72 }; |
125 | 73 |
126 } // namespace arc | 74 } // namespace arc |
127 | 75 |
128 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ | 76 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_IMPL_H_ |
OLD | NEW |