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

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

Issue 2487623002: Notify Files App when ARC++ app is installed/removed (Closed)
Patch Set: Fixed BrowserTest.Title. 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/observer_list.h"
13 #include "base/task_runner.h" 14 #include "base/task_runner.h"
14 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
15 #include "components/arc/intent_helper/activity_icon_loader.h" 16 #include "components/arc/intent_helper/activity_icon_loader.h"
17 #include "components/arc/intent_helper/arc_intent_helper_observer.h"
16 #include "components/arc/intent_helper/local_activity_resolver.h" 18 #include "components/arc/intent_helper/local_activity_resolver.h"
17 19
18 namespace arc { 20 namespace arc {
19 21
20 class ArcBridgeService; 22 class ArcBridgeService;
21 class ArcService; 23 class ArcService;
22 24
23 // Manages creation and destruction of services that communicate with the ARC 25 // Manages creation and destruction of services that communicate with the ARC
24 // instance via the ArcBridgeService. 26 // instance via the ArcBridgeService.
25 class ArcServiceManager { 27 class ArcServiceManager : public arc::ArcIntentHelperObserver {
26 public: 28 public:
29 class Observer {
30 public:
31 // Called when app's intent filter is updated.
32 virtual void OnAppsUpdated() = 0;
33
34 protected:
35 virtual ~Observer() = default;
36 };
37
27 explicit ArcServiceManager( 38 explicit ArcServiceManager(
28 scoped_refptr<base::TaskRunner> blocking_task_runner); 39 scoped_refptr<base::TaskRunner> blocking_task_runner);
29 virtual ~ArcServiceManager(); 40 ~ArcServiceManager() override;
30 41
31 // |arc_bridge_service| can only be accessed on the thread that this 42 // |arc_bridge_service| can only be accessed on the thread that this
32 // class was created on. 43 // class was created on.
33 ArcBridgeService* arc_bridge_service(); 44 ArcBridgeService* arc_bridge_service();
34 45
35 // Adds a service to the managed services list. 46 // Adds a service to the managed services list.
36 void AddService(std::unique_ptr<ArcService> service); 47 void AddService(std::unique_ptr<ArcService> service);
37 48
38 // Gets the global instance of the ARC Service Manager. This can only be 49 // Gets the global instance of the ARC Service Manager. This can only be
39 // called on the thread that this class was created on. 50 // called on the thread that this class was created on.
40 static ArcServiceManager* Get(); 51 static ArcServiceManager* Get();
41 52
53 void AddObserver(Observer* observer);
54 void RemoveObserver(Observer* observer);
55
56 // arc::ArcIntentHelperObserver overrides.
57 void OnAppsUpdated() override;
58
42 // Called to shut down all ARC services. 59 // Called to shut down all ARC services.
43 void Shutdown(); 60 void Shutdown();
44 61
45 scoped_refptr<base::TaskRunner> blocking_task_runner() const { 62 scoped_refptr<base::TaskRunner> blocking_task_runner() const {
46 return blocking_task_runner_; 63 return blocking_task_runner_;
47 } 64 }
48 65
49 // Set ArcBridgeService instance for testing. Call before ArcServiceManager 66 // Set ArcBridgeService instance for testing. Call before ArcServiceManager
50 // creation. ArcServiceManager owns |arc_bridge_service|. 67 // creation. ArcServiceManager owns |arc_bridge_service|.
51 static void SetArcBridgeServiceForTesting( 68 static void SetArcBridgeServiceForTesting(
52 std::unique_ptr<ArcBridgeService> arc_bridge_service); 69 std::unique_ptr<ArcBridgeService> arc_bridge_service);
53 70
54 // Returns the icon loader owned by ArcServiceManager and shared by services. 71 // Returns the icon loader owned by ArcServiceManager and shared by services.
55 scoped_refptr<ActivityIconLoader> icon_loader() { return icon_loader_; } 72 scoped_refptr<ActivityIconLoader> icon_loader() { return icon_loader_; }
56 73
57 // Returns the activity resolver owned by ArcServiceManager. 74 // Returns the activity resolver owned by ArcServiceManager.
58 scoped_refptr<LocalActivityResolver> activity_resolver() { 75 scoped_refptr<LocalActivityResolver> activity_resolver() {
59 return activity_resolver_; 76 return activity_resolver_;
60 } 77 }
61 78
62 private: 79 private:
63 base::ThreadChecker thread_checker_; 80 base::ThreadChecker thread_checker_;
64 scoped_refptr<base::TaskRunner> blocking_task_runner_; 81 scoped_refptr<base::TaskRunner> blocking_task_runner_;
65 82
66 std::unique_ptr<ArcBridgeService> arc_bridge_service_; 83 std::unique_ptr<ArcBridgeService> arc_bridge_service_;
67 std::vector<std::unique_ptr<ArcService>> services_; 84 std::vector<std::unique_ptr<ArcService>> services_;
68 scoped_refptr<ActivityIconLoader> icon_loader_; 85 scoped_refptr<ActivityIconLoader> icon_loader_;
69 scoped_refptr<LocalActivityResolver> activity_resolver_; 86 scoped_refptr<LocalActivityResolver> activity_resolver_;
70 87
88 base::ObserverList<Observer> observer_list_;
89
71 DISALLOW_COPY_AND_ASSIGN(ArcServiceManager); 90 DISALLOW_COPY_AND_ASSIGN(ArcServiceManager);
72 }; 91 };
73 92
74 } // namespace arc 93 } // namespace arc
75 94
76 #endif // COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ 95 #endif // COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698