| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/chromeos/arc/boot_phase_monitor/arc_boot_phase_monitor_
bridge.h" | 5 #include "chrome/browser/chromeos/arc/boot_phase_monitor/arc_boot_phase_monitor_
bridge.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "chrome/browser/chromeos/arc/boot_phase_monitor/arc_instance_throttle.h
" | 9 #include "chrome/browser/chromeos/arc/boot_phase_monitor/arc_instance_throttle.h
" |
| 10 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 11 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 9 #include "chromeos/dbus/dbus_thread_manager.h" | 12 #include "chromeos/dbus/dbus_thread_manager.h" |
| 10 #include "chromeos/dbus/session_manager_client.h" | 13 #include "chromeos/dbus/session_manager_client.h" |
| 11 #include "components/arc/arc_bridge_service.h" | 14 #include "components/arc/arc_bridge_service.h" |
| 12 | 15 |
| 16 namespace { |
| 17 |
| 18 void OnEmitArcBooted(bool success) { |
| 19 if (!success) |
| 20 VLOG(1) << "Failed to emit arc booted signal."; |
| 21 } |
| 22 |
| 23 } // namespace |
| 24 |
| 13 namespace arc { | 25 namespace arc { |
| 14 | 26 |
| 15 ArcBootPhaseMonitorBridge::ArcBootPhaseMonitorBridge( | 27 ArcBootPhaseMonitorBridge::ArcBootPhaseMonitorBridge( |
| 16 ArcBridgeService* bridge_service) | 28 ArcBridgeService* bridge_service, |
| 17 : ArcService(bridge_service), binding_(this) { | 29 const AccountId& account_id) |
| 30 : ArcService(bridge_service), account_id_(account_id), binding_(this) { |
| 18 DCHECK(thread_checker_.CalledOnValidThread()); | 31 DCHECK(thread_checker_.CalledOnValidThread()); |
| 19 arc_bridge_service()->boot_phase_monitor()->AddObserver(this); | 32 arc_bridge_service()->boot_phase_monitor()->AddObserver(this); |
| 20 } | 33 } |
| 21 | 34 |
| 22 ArcBootPhaseMonitorBridge::~ArcBootPhaseMonitorBridge() { | 35 ArcBootPhaseMonitorBridge::~ArcBootPhaseMonitorBridge() { |
| 23 DCHECK(thread_checker_.CalledOnValidThread()); | 36 DCHECK(thread_checker_.CalledOnValidThread()); |
| 24 arc_bridge_service()->boot_phase_monitor()->RemoveObserver(this); | 37 arc_bridge_service()->boot_phase_monitor()->RemoveObserver(this); |
| 25 } | 38 } |
| 26 | 39 |
| 27 void ArcBootPhaseMonitorBridge::OnInstanceReady() { | 40 void ArcBootPhaseMonitorBridge::OnInstanceReady() { |
| 28 DCHECK(thread_checker_.CalledOnValidThread()); | 41 DCHECK(thread_checker_.CalledOnValidThread()); |
| 29 auto* instance = ARC_GET_INSTANCE_FOR_METHOD( | 42 auto* instance = ARC_GET_INSTANCE_FOR_METHOD( |
| 30 arc_bridge_service()->boot_phase_monitor(), Init); | 43 arc_bridge_service()->boot_phase_monitor(), Init); |
| 31 DCHECK(instance); | 44 DCHECK(instance); |
| 32 instance->Init(binding_.CreateInterfacePtrAndBind()); | 45 instance->Init(binding_.CreateInterfacePtrAndBind()); |
| 33 } | 46 } |
| 34 | 47 |
| 35 void ArcBootPhaseMonitorBridge::OnInstanceClosed() { | 48 void ArcBootPhaseMonitorBridge::OnInstanceClosed() { |
| 36 DCHECK(thread_checker_.CalledOnValidThread()); | 49 DCHECK(thread_checker_.CalledOnValidThread()); |
| 37 } | 50 } |
| 38 | 51 |
| 39 void ArcBootPhaseMonitorBridge::OnBootCompleted() { | 52 void ArcBootPhaseMonitorBridge::OnBootCompleted() { |
| 40 DCHECK(thread_checker_.CalledOnValidThread()); | 53 DCHECK(thread_checker_.CalledOnValidThread()); |
| 41 VLOG(2) << "OnBootCompleted"; | 54 VLOG(2) << "OnBootCompleted"; |
| 42 | 55 |
| 43 chromeos::SessionManagerClient* session_manager_client = | 56 chromeos::SessionManagerClient* session_manager_client = |
| 44 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); | 57 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); |
| 45 session_manager_client->EmitArcBooted(); | 58 session_manager_client->EmitArcBooted(cryptohome::Identification(account_id_), |
| 59 base::Bind(&OnEmitArcBooted)); |
| 46 | 60 |
| 47 // Start monitoring window activation changes to prioritize/throttle the | 61 // Start monitoring window activation changes to prioritize/throttle the |
| 48 // container when needed. | 62 // container when needed. |
| 49 throttle_ = base::MakeUnique<ArcInstanceThrottle>(); | 63 throttle_ = base::MakeUnique<ArcInstanceThrottle>(); |
| 50 } | 64 } |
| 51 | 65 |
| 52 } // namespace arc | 66 } // namespace arc |
| OLD | NEW |