| 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 <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
| 13 #include "components/signin/core/account_id/account_id.h" | 13 #include "components/signin/core/account_id/account_id.h" |
| 14 | 14 |
| 15 namespace arc { | 15 namespace arc { |
| 16 | 16 |
| 17 class ArcBridgeService; | 17 class ArcBridgeService; |
| 18 class ArcService; | 18 class ArcService; |
| 19 | 19 |
| 20 // Manages creation and destruction of services that communicate with the ARC | 20 // Manages creation and destruction of services that communicate with the ARC |
| 21 // instance via the ArcBridgeService. | 21 // instance via the ArcBridgeService. |
| 22 class ArcServiceManager { | 22 class ArcServiceManager { |
| 23 public: | 23 public: |
| 24 ArcServiceManager(); | 24 ArcServiceManager(); |
| 25 virtual ~ArcServiceManager(); | 25 virtual ~ArcServiceManager(); |
| 26 | 26 |
| 27 // |arc_bridge_service| can only be accessed on the thread that this | 27 // |arc_bridge_service| can only be accessed on the thread that this |
| 28 // class was created on. | 28 // class was created on. |
| 29 ArcBridgeService* arc_bridge_service(); | 29 ArcBridgeService* arc_bridge_service(); |
| 30 | 30 |
| 31 // Adds a service to the managed services list. | 31 // Adds a service to the managed services list. |
| 32 void AddService(scoped_ptr<ArcService> service); | 32 void AddService(std::unique_ptr<ArcService> service); |
| 33 | 33 |
| 34 // Gets the global instance of the ARC Service Manager. This can only be | 34 // Gets the global instance of the ARC Service Manager. This can only be |
| 35 // called on the thread that this class was created on. | 35 // called on the thread that this class was created on. |
| 36 static ArcServiceManager* Get(); | 36 static ArcServiceManager* Get(); |
| 37 | 37 |
| 38 // Called when the main profile is initialized after user logs in. | 38 // Called when the main profile is initialized after user logs in. |
| 39 void OnPrimaryUserProfilePrepared(const AccountId& account_id); | 39 void OnPrimaryUserProfilePrepared(const AccountId& account_id); |
| 40 | 40 |
| 41 // Called to shut down all ARC services. | 41 // Called to shut down all ARC services. |
| 42 void Shutdown(); | 42 void Shutdown(); |
| 43 | 43 |
| 44 // Set ArcBridgeService instance for testing. Call before ArcServiceManager | 44 // Set ArcBridgeService instance for testing. Call before ArcServiceManager |
| 45 // creation. ArcServiceManager owns |arc_bridge_service|. | 45 // creation. ArcServiceManager owns |arc_bridge_service|. |
| 46 static void SetArcBridgeServiceForTesting( | 46 static void SetArcBridgeServiceForTesting( |
| 47 scoped_ptr<ArcBridgeService> arc_bridge_service); | 47 std::unique_ptr<ArcBridgeService> arc_bridge_service); |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 base::ThreadChecker thread_checker_; | 50 base::ThreadChecker thread_checker_; |
| 51 scoped_ptr<ArcBridgeService> arc_bridge_service_; | 51 std::unique_ptr<ArcBridgeService> arc_bridge_service_; |
| 52 std::vector<scoped_ptr<ArcService>> services_; | 52 std::vector<std::unique_ptr<ArcService>> services_; |
| 53 | 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(ArcServiceManager); | 54 DISALLOW_COPY_AND_ASSIGN(ArcServiceManager); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 } // namespace arc | 57 } // namespace arc |
| 58 | 58 |
| 59 #endif // COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ | 59 #endif // COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ |
| OLD | NEW |