Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: components/arc/arc_service_manager.h

Issue 2487623002: Notify Files App when ARC++ app is installed/removed (Closed)
Patch Set: Bug fix: I forgot to add intent_helper to arc_service_manager. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
hidehiko 2016/11/25 15:38:00 #include "base/observer_list.h" looks missing.
oka 2016/11/28 07:15:43 Done.
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "components/arc/intent_helper/activity_icon_loader.h" 15 #include "components/arc/intent_helper/activity_icon_loader.h"
16 #include "components/arc/intent_helper/arc_intent_helper_observer.h"
16 #include "components/arc/intent_helper/local_activity_resolver.h" 17 #include "components/arc/intent_helper/local_activity_resolver.h"
17 #include "components/prefs/pref_member.h" 18 #include "components/prefs/pref_member.h"
18 #include "components/signin/core/account_id/account_id.h" 19 #include "components/signin/core/account_id/account_id.h"
19 20
20 namespace arc { 21 namespace arc {
21 22
22 class ArcBridgeService; 23 class ArcBridgeService;
23 class ArcService; 24 class ArcService;
24 25
25 // Manages creation and destruction of services that communicate with the ARC 26 // Manages creation and destruction of services that communicate with the ARC
26 // instance via the ArcBridgeService. 27 // instance via the ArcBridgeService.
27 class ArcServiceManager { 28 class ArcServiceManager
29 : public arc::ArcIntentHelperObserver {
hidehiko 2016/11/25 15:38:00 I think this line can be merged with above one. Co
oka 2016/11/28 07:15:43 Done.
28 public: 30 public:
31 class Observer {
32 public:
33 // Called when app's intent filter is updated.
34 virtual void OnAppsUpdated() = 0;
35 protected:
36 virtual ~Observer() {}
hidehiko 2016/11/25 15:38:00 s/{}/= default;
oka 2016/11/28 07:15:43 Done.
37 };
38
29 explicit ArcServiceManager( 39 explicit ArcServiceManager(
30 scoped_refptr<base::TaskRunner> blocking_task_runner); 40 scoped_refptr<base::TaskRunner> blocking_task_runner);
31 virtual ~ArcServiceManager(); 41 ~ArcServiceManager() override;
32 42
33 // |arc_bridge_service| can only be accessed on the thread that this 43 // |arc_bridge_service| can only be accessed on the thread that this
34 // class was created on. 44 // class was created on.
35 ArcBridgeService* arc_bridge_service(); 45 ArcBridgeService* arc_bridge_service();
36 46
37 // Adds a service to the managed services list. 47 // Adds a service to the managed services list.
38 void AddService(std::unique_ptr<ArcService> service); 48 void AddService(std::unique_ptr<ArcService> service);
39 49
40 // Gets the global instance of the ARC Service Manager. This can only be 50 // Gets the global instance of the ARC Service Manager. This can only be
41 // called on the thread that this class was created on. 51 // called on the thread that this class was created on.
42 static ArcServiceManager* Get(); 52 static ArcServiceManager* Get();
43 53
44 // Called when the main profile is initialized after user logs in. 54 // Called when the main profile is initialized after user logs in.
45 void OnPrimaryUserProfilePrepared( 55 void OnPrimaryUserProfilePrepared(
46 const AccountId& account_id, 56 const AccountId& account_id,
47 std::unique_ptr<BooleanPrefMember> arc_enabled_pref); 57 std::unique_ptr<BooleanPrefMember> arc_enabled_pref);
48 58
59 void AddObserver(Observer* observer);
60 void RemoveObserver(Observer* observer);
61
62 // arc::ArcIntentHelperBridge::Observer overrides.
63 void OnAppsUpdated() override;
64
49 // Called to shut down all ARC services. 65 // Called to shut down all ARC services.
50 void Shutdown(); 66 void Shutdown();
51 67
52 scoped_refptr<base::TaskRunner> blocking_task_runner() const { 68 scoped_refptr<base::TaskRunner> blocking_task_runner() const {
53 return blocking_task_runner_; 69 return blocking_task_runner_;
54 } 70 }
55 71
56 // Set ArcBridgeService instance for testing. Call before ArcServiceManager 72 // Set ArcBridgeService instance for testing. Call before ArcServiceManager
57 // creation. ArcServiceManager owns |arc_bridge_service|. 73 // creation. ArcServiceManager owns |arc_bridge_service|.
58 static void SetArcBridgeServiceForTesting( 74 static void SetArcBridgeServiceForTesting(
59 std::unique_ptr<ArcBridgeService> arc_bridge_service); 75 std::unique_ptr<ArcBridgeService> arc_bridge_service);
60 76
61 // Returns the icon loader owned by ArcServiceManager and shared by services. 77 // Returns the icon loader owned by ArcServiceManager and shared by services.
62 scoped_refptr<ActivityIconLoader> icon_loader() { return icon_loader_; } 78 scoped_refptr<ActivityIconLoader> icon_loader() { return icon_loader_; }
63 79
64 // Returns the activity resolver owned by ArcServiceManager. 80 // Returns the activity resolver owned by ArcServiceManager.
65 scoped_refptr<LocalActivityResolver> activity_resolver() { 81 scoped_refptr<LocalActivityResolver> activity_resolver() {
66 return activity_resolver_; 82 return activity_resolver_;
67 } 83 }
68 84
69 private: 85 private:
70 base::ThreadChecker thread_checker_; 86 base::ThreadChecker thread_checker_;
71 scoped_refptr<base::TaskRunner> blocking_task_runner_; 87 scoped_refptr<base::TaskRunner> blocking_task_runner_;
72 88
73 std::unique_ptr<ArcBridgeService> arc_bridge_service_; 89 std::unique_ptr<ArcBridgeService> arc_bridge_service_;
74 std::vector<std::unique_ptr<ArcService>> services_; 90 std::vector<std::unique_ptr<ArcService>> services_;
75 scoped_refptr<ActivityIconLoader> icon_loader_; 91 scoped_refptr<ActivityIconLoader> icon_loader_;
76 scoped_refptr<LocalActivityResolver> activity_resolver_; 92 scoped_refptr<LocalActivityResolver> activity_resolver_;
77 93
94 base::ObserverList<Observer> observer_list_;
95
78 DISALLOW_COPY_AND_ASSIGN(ArcServiceManager); 96 DISALLOW_COPY_AND_ASSIGN(ArcServiceManager);
79 }; 97 };
80 98
81 } // namespace arc 99 } // namespace arc
82 100
83 #endif // COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ 101 #endif // COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698