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 #include "components/arc/arc_service_manager.h" | 5 #include "components/arc/arc_service_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 // static | 52 // static |
53 ArcServiceManager* ArcServiceManager::Get() { | 53 ArcServiceManager* ArcServiceManager::Get() { |
54 DCHECK(g_arc_service_manager); | 54 DCHECK(g_arc_service_manager); |
55 DCHECK(g_arc_service_manager->thread_checker_.CalledOnValidThread()); | 55 DCHECK(g_arc_service_manager->thread_checker_.CalledOnValidThread()); |
56 return g_arc_service_manager; | 56 return g_arc_service_manager; |
57 } | 57 } |
58 | 58 |
| 59 // static |
| 60 bool ArcServiceManager::IsInitialized() { |
| 61 return g_arc_service_manager; |
| 62 } |
| 63 |
59 ArcBridgeService* ArcServiceManager::arc_bridge_service() { | 64 ArcBridgeService* ArcServiceManager::arc_bridge_service() { |
60 DCHECK(thread_checker_.CalledOnValidThread()); | 65 DCHECK(thread_checker_.CalledOnValidThread()); |
61 return arc_bridge_service_.get(); | 66 return arc_bridge_service_.get(); |
62 } | 67 } |
63 | 68 |
64 void ArcServiceManager::AddService(std::unique_ptr<ArcService> service) { | 69 void ArcServiceManager::AddService(std::unique_ptr<ArcService> service) { |
65 DCHECK(thread_checker_.CalledOnValidThread()); | 70 DCHECK(thread_checker_.CalledOnValidThread()); |
66 services_.emplace_back(std::move(service)); | 71 services_.emplace_back(std::move(service)); |
67 } | 72 } |
68 | 73 |
| 74 void ArcServiceManager::AddObserver(Observer* observer) { |
| 75 observer_list_.AddObserver(observer); |
| 76 } |
| 77 |
| 78 void ArcServiceManager::RemoveObserver(Observer* observer) { |
| 79 observer_list_.RemoveObserver(observer); |
| 80 } |
| 81 |
| 82 void ArcServiceManager::OnAppsUpdated() { |
| 83 for (auto& observer : observer_list_) |
| 84 observer.OnAppsUpdated(); |
| 85 } |
| 86 |
69 void ArcServiceManager::Shutdown() { | 87 void ArcServiceManager::Shutdown() { |
70 icon_loader_ = nullptr; | 88 icon_loader_ = nullptr; |
71 activity_resolver_ = nullptr; | 89 activity_resolver_ = nullptr; |
72 services_.clear(); | 90 services_.clear(); |
73 arc_bridge_service_->OnShutdown(); | 91 arc_bridge_service_->OnShutdown(); |
74 } | 92 } |
75 | 93 |
76 // static | 94 // static |
77 void ArcServiceManager::SetArcBridgeServiceForTesting( | 95 void ArcServiceManager::SetArcBridgeServiceForTesting( |
78 std::unique_ptr<ArcBridgeService> arc_bridge_service) { | 96 std::unique_ptr<ArcBridgeService> arc_bridge_service) { |
79 if (g_arc_bridge_service_for_testing) | 97 if (g_arc_bridge_service_for_testing) |
80 delete g_arc_bridge_service_for_testing; | 98 delete g_arc_bridge_service_for_testing; |
81 g_arc_bridge_service_for_testing = arc_bridge_service.release(); | 99 g_arc_bridge_service_for_testing = arc_bridge_service.release(); |
82 } | 100 } |
83 | 101 |
84 } // namespace arc | 102 } // namespace arc |
OLD | NEW |