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_SERVICE_MANAGER_H_ | 5 #ifndef COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ |
6 #define COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ | 6 #define COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/task_runner.h" | 13 #include "base/task_runner.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "components/signin/core/account_id/account_id.h" | 15 #include "components/signin/core/account_id/account_id.h" |
16 | 16 |
| 17 class PrefService; |
| 18 |
17 namespace arc { | 19 namespace arc { |
18 | 20 |
19 class ArcBridgeService; | 21 class ArcBridgeService; |
20 class ArcService; | 22 class ArcService; |
| 23 class ArcUserDataService; |
21 | 24 |
22 // Manages creation and destruction of services that communicate with the ARC | 25 // Manages creation and destruction of services that communicate with the ARC |
23 // instance via the ArcBridgeService. | 26 // instance via the ArcBridgeService. |
24 class ArcServiceManager { | 27 class ArcServiceManager { |
25 public: | 28 public: |
26 explicit ArcServiceManager( | 29 explicit ArcServiceManager( |
27 scoped_refptr<base::TaskRunner> blocking_task_runner); | 30 scoped_refptr<base::TaskRunner> blocking_task_runner); |
28 virtual ~ArcServiceManager(); | 31 virtual ~ArcServiceManager(); |
29 | 32 |
30 // |arc_bridge_service| can only be accessed on the thread that this | 33 // |arc_bridge_service| can only be accessed on the thread that this |
31 // class was created on. | 34 // class was created on. |
32 ArcBridgeService* arc_bridge_service(); | 35 ArcBridgeService* arc_bridge_service(); |
33 | 36 |
34 // Adds a service to the managed services list. | 37 // Adds a service to the managed services list. |
35 void AddService(std::unique_ptr<ArcService> service); | 38 void AddService(std::unique_ptr<ArcService> service); |
36 | 39 |
37 // Gets the global instance of the ARC Service Manager. This can only be | 40 // Gets the global instance of the ARC Service Manager. This can only be |
38 // called on the thread that this class was created on. | 41 // called on the thread that this class was created on. |
39 static ArcServiceManager* Get(); | 42 static ArcServiceManager* Get(); |
40 | 43 |
41 // Called when the main profile is initialized after user logs in. | 44 // Called when the main profile is initialized after user logs in. |
42 void OnPrimaryUserProfilePrepared(const AccountId& account_id); | 45 void OnPrimaryUserProfilePrepared(const AccountId& account_id, |
| 46 PrefService* user_prefs); |
43 | 47 |
44 // Called once the windowing system (ash) has been started. | 48 // Called once the windowing system (ash) has been started. |
45 void OnAshStarted(); | 49 void OnAshStarted(); |
46 | 50 |
47 // Called to shut down all ARC services. | 51 // Called to shut down all ARC services. |
48 void Shutdown(); | 52 void Shutdown(); |
49 | 53 |
50 scoped_refptr<base::TaskRunner> blocking_task_runner() const { | 54 scoped_refptr<base::TaskRunner> blocking_task_runner() const { |
51 return blocking_task_runner_; | 55 return blocking_task_runner_; |
52 } | 56 } |
53 | 57 |
54 // Set ArcBridgeService instance for testing. Call before ArcServiceManager | 58 // Set ArcBridgeService instance for testing. Call before ArcServiceManager |
55 // creation. ArcServiceManager owns |arc_bridge_service|. | 59 // creation. ArcServiceManager owns |arc_bridge_service|. |
56 static void SetArcBridgeServiceForTesting( | 60 static void SetArcBridgeServiceForTesting( |
57 std::unique_ptr<ArcBridgeService> arc_bridge_service); | 61 std::unique_ptr<ArcBridgeService> arc_bridge_service); |
58 | 62 |
59 private: | 63 private: |
60 base::ThreadChecker thread_checker_; | 64 base::ThreadChecker thread_checker_; |
61 scoped_refptr<base::TaskRunner> blocking_task_runner_; | 65 scoped_refptr<base::TaskRunner> blocking_task_runner_; |
62 | 66 |
63 std::unique_ptr<ArcBridgeService> arc_bridge_service_; | 67 std::unique_ptr<ArcBridgeService> arc_bridge_service_; |
64 std::vector<std::unique_ptr<ArcService>> services_; | 68 std::vector<std::unique_ptr<ArcService>> services_; |
| 69 std::unique_ptr<ArcUserDataService> arc_user_data_service_; |
65 | 70 |
66 // True once the window manager service got added, barring adding any more | 71 // True once the window manager service got added, barring adding any more |
67 // of those since OnAshStarted() might be called multiple times. | 72 // of those since OnAshStarted() might be called multiple times. |
68 bool on_ash_started_called_ = false; | 73 bool on_ash_started_called_ = false; |
69 | 74 |
70 DISALLOW_COPY_AND_ASSIGN(ArcServiceManager); | 75 DISALLOW_COPY_AND_ASSIGN(ArcServiceManager); |
71 }; | 76 }; |
72 | 77 |
73 } // namespace arc | 78 } // namespace arc |
74 | 79 |
75 #endif // COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ | 80 #endif // COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ |
OLD | NEW |