Chromium Code Reviews| 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/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "base/task_runner.h" | 14 #include "base/task_runner.h" |
| 15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 16 #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/local_activity_resolver.h" | 17 #include "components/arc/intent_helper/local_activity_resolver.h" |
| 18 | 18 |
| 19 namespace arc { | 19 namespace arc { |
| 20 | 20 |
| 21 class ArcBridgeService; | 21 class ArcBridgeService; |
| 22 class ArcFileSystemService; | |
| 22 class ArcIntentHelperObserver; | 23 class ArcIntentHelperObserver; |
| 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 { |
| 28 public: | 29 public: |
| 29 class Observer { | 30 class Observer { |
| 30 public: | 31 public: |
| 31 // Called when ArcServiceManager is being shut down. Observer | 32 // Called when ArcServiceManager is being shut down. Observer |
| 32 // implementation should clean up ARC related stuff here. One of the | 33 // implementation should clean up ARC related stuff here. One of the |
| 33 // typical use cases is calling ArcServiceManager::RemoveObserver(). | 34 // typical use cases is calling ArcServiceManager::RemoveObserver(). |
| 34 virtual void OnArcShutdown() = 0; | 35 virtual void OnArcShutdown() {} |
|
Luis Héctor Chávez
2017/01/10 18:51:35
nit: can you leave them as they were before? we wa
Shuhei Takahashi
2017/01/11 15:20:43
Done.
| |
| 35 | 36 |
| 36 // Called when intent filters are added or removed. | 37 // Called when intent filters are added or removed. |
| 37 virtual void OnIntentFiltersUpdated() = 0; | 38 virtual void OnIntentFiltersUpdated() {} |
| 38 | 39 |
| 39 protected: | 40 protected: |
| 40 virtual ~Observer() = default; | 41 virtual ~Observer() = default; |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 explicit ArcServiceManager( | 44 explicit ArcServiceManager( |
| 44 scoped_refptr<base::TaskRunner> blocking_task_runner); | 45 scoped_refptr<base::TaskRunner> blocking_task_runner); |
| 45 ~ArcServiceManager(); | 46 ~ArcServiceManager(); |
| 46 | 47 |
| 47 // |arc_bridge_service| can only be accessed on the thread that this | 48 // |arc_bridge_service| can only be accessed on the thread that this |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 66 } | 67 } |
| 67 | 68 |
| 68 // Returns the icon loader owned by ArcServiceManager and shared by services. | 69 // Returns the icon loader owned by ArcServiceManager and shared by services. |
| 69 scoped_refptr<ActivityIconLoader> icon_loader() { return icon_loader_; } | 70 scoped_refptr<ActivityIconLoader> icon_loader() { return icon_loader_; } |
| 70 | 71 |
| 71 // Returns the activity resolver owned by ArcServiceManager. | 72 // Returns the activity resolver owned by ArcServiceManager. |
| 72 scoped_refptr<LocalActivityResolver> activity_resolver() { | 73 scoped_refptr<LocalActivityResolver> activity_resolver() { |
| 73 return activity_resolver_; | 74 return activity_resolver_; |
| 74 } | 75 } |
| 75 | 76 |
| 76 // Returns the IntentHelperObserver instance owned by ArcServiceManager. | 77 // Returns the ArcIntentHelperObserver instance owned by ArcServiceManager. |
| 77 ArcIntentHelperObserver* intent_helper_observer() { | 78 ArcIntentHelperObserver* intent_helper_observer() { |
| 78 return intent_helper_observer_.get(); | 79 return intent_helper_observer_.get(); |
| 79 } | 80 } |
| 80 | 81 |
| 82 // TODO(crbug.com/672840): Implement a generic getter to avoid boilerplates. | |
| 83 void set_file_system_service(ArcFileSystemService* file_system_service) { | |
| 84 file_system_service_ = file_system_service; | |
| 85 } | |
| 86 ArcFileSystemService* file_system_service() const { | |
| 87 return file_system_service_; | |
| 88 } | |
| 89 | |
| 81 private: | 90 private: |
| 82 class IntentHelperObserverImpl; // implemented in arc_service_manager.cc. | 91 class IntentHelperObserverImpl; // implemented in arc_service_manager.cc. |
| 83 | 92 |
| 84 base::ThreadChecker thread_checker_; | 93 base::ThreadChecker thread_checker_; |
| 85 scoped_refptr<base::TaskRunner> blocking_task_runner_; | 94 scoped_refptr<base::TaskRunner> blocking_task_runner_; |
| 86 | 95 |
| 87 // An object for observing the ArcIntentHelper instance in |services_|. | 96 // An object for observing the ArcIntentHelper instance in |services_|. |
| 88 std::unique_ptr<ArcIntentHelperObserver> intent_helper_observer_; | 97 std::unique_ptr<ArcIntentHelperObserver> intent_helper_observer_; |
| 89 | 98 |
| 90 std::unique_ptr<ArcBridgeService> arc_bridge_service_; | 99 std::unique_ptr<ArcBridgeService> arc_bridge_service_; |
| 91 std::vector<std::unique_ptr<ArcService>> services_; | 100 std::vector<std::unique_ptr<ArcService>> services_; |
| 92 scoped_refptr<ActivityIconLoader> icon_loader_; | 101 scoped_refptr<ActivityIconLoader> icon_loader_; |
| 93 scoped_refptr<LocalActivityResolver> activity_resolver_; | 102 scoped_refptr<LocalActivityResolver> activity_resolver_; |
| 94 | 103 |
| 104 ArcFileSystemService* file_system_service_; // Owned by |services_|. | |
| 105 | |
| 95 base::ObserverList<Observer> observer_list_; | 106 base::ObserverList<Observer> observer_list_; |
| 96 | 107 |
| 97 DISALLOW_COPY_AND_ASSIGN(ArcServiceManager); | 108 DISALLOW_COPY_AND_ASSIGN(ArcServiceManager); |
| 98 }; | 109 }; |
| 99 | 110 |
| 100 } // namespace arc | 111 } // namespace arc |
| 101 | 112 |
| 102 #endif // COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ | 113 #endif // COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ |
| OLD | NEW |