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 #include "components/arc/arc_service_manager.h" | 5 #include "components/arc/arc_service_manager.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/sequenced_task_runner.h" | 8 #include "base/sequenced_task_runner.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "components/arc/arc_bridge_bootstrap.h" | 10 #include "components/arc/arc_bridge_bootstrap.h" |
| 11 #include "components/arc/arc_bridge_service.h" | 11 #include "components/arc/arc_bridge_service.h" |
| 12 #include "components/arc/arc_bridge_service_impl.h" | 12 #include "components/arc/arc_bridge_service_impl.h" |
| 13 #include "components/arc/audio/arc_audio_bridge.h" | 13 #include "components/arc/audio/arc_audio_bridge.h" |
| 14 #include "components/arc/bluetooth/arc_bluetooth_bridge.h" | 14 #include "components/arc/bluetooth/arc_bluetooth_bridge.h" |
| 15 #include "components/arc/clipboard/arc_clipboard_bridge.h" | 15 #include "components/arc/clipboard/arc_clipboard_bridge.h" |
| 16 #include "components/arc/crash_collector/arc_crash_collector_bridge.h" | 16 #include "components/arc/crash_collector/arc_crash_collector_bridge.h" |
| 17 #include "components/arc/ime/arc_ime_service.h" | 17 #include "components/arc/ime/arc_ime_service.h" |
| 18 #include "components/arc/intent_helper/activity_icon_loader.h" | 18 #include "components/arc/intent_helper/activity_icon_loader.h" |
| 19 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" | 19 #include "components/arc/intent_helper/arc_intent_helper_bridge.h" |
| 20 #include "components/arc/metrics/arc_metrics_service.h" | 20 #include "components/arc/metrics/arc_metrics_service.h" |
| 21 #include "components/arc/net/arc_net_host_impl.h" | 21 #include "components/arc/net/arc_net_host_impl.h" |
| 22 #include "components/arc/obb_mounter/arc_obb_mounter_bridge.h" | 22 #include "components/arc/obb_mounter/arc_obb_mounter_bridge.h" |
| 23 #include "components/arc/power/arc_power_bridge.h" | 23 #include "components/arc/power/arc_power_bridge.h" |
| 24 #include "components/arc/storage_manager/arc_storage_manager.h" | 24 #include "components/arc/storage_manager/arc_storage_manager.h" |
| 25 #include "components/arc/user_data/arc_user_data_service.h" | |
| 25 #include "components/arc/window_manager/arc_window_manager_bridge.h" | 26 #include "components/arc/window_manager/arc_window_manager_bridge.h" |
| 27 #include "components/prefs/pref_member.h" | |
| 26 #include "ui/arc/notification/arc_notification_manager.h" | 28 #include "ui/arc/notification/arc_notification_manager.h" |
| 27 | 29 |
| 28 namespace arc { | 30 namespace arc { |
| 29 | 31 |
| 30 namespace { | 32 namespace { |
| 31 | 33 |
| 32 // Weak pointer. This class is owned by ChromeBrowserMainPartsChromeos. | 34 // Weak pointer. This class is owned by ChromeBrowserMainPartsChromeos. |
| 33 ArcServiceManager* g_arc_service_manager = nullptr; | 35 ArcServiceManager* g_arc_service_manager = nullptr; |
| 34 | 36 |
| 35 // This pointer is owned by ArcServiceManager. | 37 // This pointer is owned by ArcServiceManager. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 58 base::WrapUnique(new ArcCrashCollectorBridge(arc_bridge_service()))); | 60 base::WrapUnique(new ArcCrashCollectorBridge(arc_bridge_service()))); |
| 59 AddService(base::WrapUnique(new ArcImeService(arc_bridge_service()))); | 61 AddService(base::WrapUnique(new ArcImeService(arc_bridge_service()))); |
| 60 icon_loader_ = new ActivityIconLoader; | 62 icon_loader_ = new ActivityIconLoader; |
| 61 AddService(base::WrapUnique( | 63 AddService(base::WrapUnique( |
| 62 new ArcIntentHelperBridge(arc_bridge_service(), icon_loader_))); | 64 new ArcIntentHelperBridge(arc_bridge_service(), icon_loader_))); |
| 63 AddService(base::WrapUnique(new ArcMetricsService(arc_bridge_service()))); | 65 AddService(base::WrapUnique(new ArcMetricsService(arc_bridge_service()))); |
| 64 AddService(base::WrapUnique(new ArcNetHostImpl(arc_bridge_service()))); | 66 AddService(base::WrapUnique(new ArcNetHostImpl(arc_bridge_service()))); |
| 65 AddService(base::WrapUnique(new ArcObbMounterBridge(arc_bridge_service()))); | 67 AddService(base::WrapUnique(new ArcObbMounterBridge(arc_bridge_service()))); |
| 66 AddService(base::WrapUnique(new ArcPowerBridge(arc_bridge_service()))); | 68 AddService(base::WrapUnique(new ArcPowerBridge(arc_bridge_service()))); |
| 67 AddService(base::WrapUnique(new ArcStorageManager(arc_bridge_service()))); | 69 AddService(base::WrapUnique(new ArcStorageManager(arc_bridge_service()))); |
| 70 | |
| 71 arc_user_data_service_ = new ArcUserDataService(this, arc_bridge_service()); | |
|
hidehiko
2016/06/14 02:05:15
Can we move the instance creation into OnPrimaryUs
dspaid
2016/06/14 04:34:59
Done.
| |
| 72 AddService(base::WrapUnique(arc_user_data_service_)); | |
| 68 } | 73 } |
| 69 | 74 |
| 70 ArcServiceManager::~ArcServiceManager() { | 75 ArcServiceManager::~ArcServiceManager() { |
| 71 DCHECK(thread_checker_.CalledOnValidThread()); | 76 DCHECK(thread_checker_.CalledOnValidThread()); |
| 72 DCHECK(g_arc_service_manager == this); | 77 DCHECK(g_arc_service_manager == this); |
| 73 g_arc_service_manager = nullptr; | 78 g_arc_service_manager = nullptr; |
| 74 if (g_arc_bridge_service_for_testing) { | 79 if (g_arc_bridge_service_for_testing) { |
| 75 delete g_arc_bridge_service_for_testing; | 80 delete g_arc_bridge_service_for_testing; |
| 76 } | 81 } |
| 77 } | 82 } |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 88 return arc_bridge_service_.get(); | 93 return arc_bridge_service_.get(); |
| 89 } | 94 } |
| 90 | 95 |
| 91 void ArcServiceManager::AddService(std::unique_ptr<ArcService> service) { | 96 void ArcServiceManager::AddService(std::unique_ptr<ArcService> service) { |
| 92 DCHECK(thread_checker_.CalledOnValidThread()); | 97 DCHECK(thread_checker_.CalledOnValidThread()); |
| 93 | 98 |
| 94 services_.emplace_back(std::move(service)); | 99 services_.emplace_back(std::move(service)); |
| 95 } | 100 } |
| 96 | 101 |
| 97 void ArcServiceManager::OnPrimaryUserProfilePrepared( | 102 void ArcServiceManager::OnPrimaryUserProfilePrepared( |
| 98 const AccountId& account_id) { | 103 const AccountId& account_id, |
| 104 std::unique_ptr<BooleanPrefMember> arc_enabled_pref) { | |
| 99 DCHECK(thread_checker_.CalledOnValidThread()); | 105 DCHECK(thread_checker_.CalledOnValidThread()); |
| 100 | 106 arc_enabled_pref_ = std::move(arc_enabled_pref); |
|
hidehiko
2016/06/14 02:05:15
Could you pass the instance to the ArcUserDataServ
dspaid
2016/06/14 04:34:59
Done.
| |
| 107 arc_user_data_service_->OnPrimaryUserProfilePrepared(account_id); | |
| 101 AddService(base::WrapUnique( | 108 AddService(base::WrapUnique( |
| 102 new ArcNotificationManager(arc_bridge_service(), account_id))); | 109 new ArcNotificationManager(arc_bridge_service(), account_id))); |
| 103 } | 110 } |
| 104 | 111 |
| 112 bool ArcServiceManager::IsArcEnabled() const { | |
| 113 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 114 return arc_enabled_pref_ && arc_enabled_pref_->GetValue(); | |
| 115 } | |
| 116 | |
| 105 void ArcServiceManager::OnAshStarted() { | 117 void ArcServiceManager::OnAshStarted() { |
| 106 DCHECK(thread_checker_.CalledOnValidThread()); | 118 DCHECK(thread_checker_.CalledOnValidThread()); |
| 107 // We might come here multiple times. As such we should only do this once. | 119 // We might come here multiple times. As such we should only do this once. |
| 108 if (on_ash_started_called_) | 120 if (on_ash_started_called_) |
| 109 return; | 121 return; |
| 110 | 122 |
| 111 on_ash_started_called_ = true; | 123 on_ash_started_called_ = true; |
| 112 AddService( | 124 AddService( |
| 113 base::WrapUnique(new ArcWindowManagerBridge(arc_bridge_service()))); | 125 base::WrapUnique(new ArcWindowManagerBridge(arc_bridge_service()))); |
| 114 } | 126 } |
| 115 | 127 |
| 116 void ArcServiceManager::Shutdown() { | 128 void ArcServiceManager::Shutdown() { |
| 117 icon_loader_ = nullptr; | 129 icon_loader_ = nullptr; |
| 118 services_.clear(); | 130 services_.clear(); |
| 131 arc_enabled_pref_.reset(); | |
| 119 } | 132 } |
| 120 | 133 |
| 121 //static | 134 //static |
| 122 void ArcServiceManager::SetArcBridgeServiceForTesting( | 135 void ArcServiceManager::SetArcBridgeServiceForTesting( |
| 123 std::unique_ptr<ArcBridgeService> arc_bridge_service) { | 136 std::unique_ptr<ArcBridgeService> arc_bridge_service) { |
| 124 if (g_arc_bridge_service_for_testing) { | 137 if (g_arc_bridge_service_for_testing) { |
| 125 delete g_arc_bridge_service_for_testing; | 138 delete g_arc_bridge_service_for_testing; |
| 126 } | 139 } |
| 127 g_arc_bridge_service_for_testing = arc_bridge_service.release(); | 140 g_arc_bridge_service_for_testing = arc_bridge_service.release(); |
| 128 } | 141 } |
| 129 | 142 |
| 130 } // namespace arc | 143 } // namespace arc |
| OLD | NEW |