| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/system/chromeos/power/power_event_observer.h" | 5 #include "ash/system/chromeos/power/power_event_observer.h" |
| 6 | 6 |
| 7 #include "ash/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/system/tray/system_tray_notifier.h" | 8 #include "ash/common/system/tray/system_tray_notifier.h" |
| 9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 void OnSuspendDisplaysCompleted(const base::Closure& suspend_callback, | 40 void OnSuspendDisplaysCompleted(const base::Closure& suspend_callback, |
| 41 bool status) { | 41 bool status) { |
| 42 suspend_callback.Run(); | 42 suspend_callback.Run(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 PowerEventObserver::PowerEventObserver() | 47 PowerEventObserver::PowerEventObserver() |
| 48 : screen_locked_(false), waiting_for_lock_screen_animations_(false) { | 48 : screen_locked_(false), waiting_for_lock_screen_animations_(false) { |
| 49 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 49 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( |
| 50 AddObserver(this); | 50 this); |
| 51 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | 51 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver( |
| 52 AddObserver(this); | 52 this); |
| 53 } | 53 } |
| 54 | 54 |
| 55 PowerEventObserver::~PowerEventObserver() { | 55 PowerEventObserver::~PowerEventObserver() { |
| 56 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 56 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( |
| 57 RemoveObserver(this); | 57 this); |
| 58 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | 58 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver( |
| 59 RemoveObserver(this); | 59 this); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void PowerEventObserver::OnLockAnimationsComplete() { | 62 void PowerEventObserver::OnLockAnimationsComplete() { |
| 63 VLOG(1) << "Screen locker animations have completed."; | 63 VLOG(1) << "Screen locker animations have completed."; |
| 64 waiting_for_lock_screen_animations_ = false; | 64 waiting_for_lock_screen_animations_ = false; |
| 65 | 65 |
| 66 if (!screen_lock_callback_.is_null()) { | 66 if (!screen_lock_callback_.is_null()) { |
| 67 StopRenderingRequests(); | 67 StopRenderingRequests(); |
| 68 | 68 |
| 69 screen_lock_callback_.Run(); | 69 screen_lock_callback_.Run(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 88 // until the lock screen is fully visible. While it is sufficient from a | 88 // until the lock screen is fully visible. While it is sufficient from a |
| 89 // security perspective to block only until the lock screen is ready, which | 89 // security perspective to block only until the lock screen is ready, which |
| 90 // guarantees that the contents of the user's screen are no longer visible, | 90 // guarantees that the contents of the user's screen are no longer visible, |
| 91 // this leads to poor UX on the first resume since neither the user pod nor | 91 // this leads to poor UX on the first resume since neither the user pod nor |
| 92 // the header bar will be visible for a few hundred milliseconds until the GPU | 92 // the header bar will be visible for a few hundred milliseconds until the GPU |
| 93 // process starts rendering again. To deal with this, the suspend is delayed | 93 // process starts rendering again. To deal with this, the suspend is delayed |
| 94 // until all the lock screen animations have completed and the suspend request | 94 // until all the lock screen animations have completed and the suspend request |
| 95 // is unblocked from OnLockAnimationsComplete(). | 95 // is unblocked from OnLockAnimationsComplete(). |
| 96 if (!screen_locked_ && delegate->ShouldLockScreenBeforeSuspending() && | 96 if (!screen_locked_ && delegate->ShouldLockScreenBeforeSuspending() && |
| 97 delegate->CanLockScreen()) { | 97 delegate->CanLockScreen()) { |
| 98 screen_lock_callback_ = chromeos::DBusThreadManager::Get()-> | 98 screen_lock_callback_ = chromeos::DBusThreadManager::Get() |
| 99 GetPowerManagerClient()->GetSuspendReadinessCallback(); | 99 ->GetPowerManagerClient() |
| 100 ->GetSuspendReadinessCallback(); |
| 100 VLOG(1) << "Requesting screen lock from PowerEventObserver"; | 101 VLOG(1) << "Requesting screen lock from PowerEventObserver"; |
| 101 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | 102 chromeos::DBusThreadManager::Get() |
| 102 RequestLockScreen(); | 103 ->GetSessionManagerClient() |
| 104 ->RequestLockScreen(); |
| 103 } else if (waiting_for_lock_screen_animations_) { | 105 } else if (waiting_for_lock_screen_animations_) { |
| 104 // The lock-before-suspending pref has been set and the lock screen is ready | 106 // The lock-before-suspending pref has been set and the lock screen is ready |
| 105 // but the animations have not completed yet. This can happen if a suspend | 107 // but the animations have not completed yet. This can happen if a suspend |
| 106 // request is canceled after the lock screen is ready but before the | 108 // request is canceled after the lock screen is ready but before the |
| 107 // animations have completed and then another suspend request is immediately | 109 // animations have completed and then another suspend request is immediately |
| 108 // started. In practice, it is highly unlikely that this will ever happen | 110 // started. In practice, it is highly unlikely that this will ever happen |
| 109 // but it's better to be safe since the cost of not dealing with it properly | 111 // but it's better to be safe since the cost of not dealing with it properly |
| 110 // is a memory leak in the GPU and weird artifacts on the screen. | 112 // is a memory leak in the GPU and weird artifacts on the screen. |
| 111 screen_lock_callback_ = chromeos::DBusThreadManager::Get() | 113 screen_lock_callback_ = chromeos::DBusThreadManager::Get() |
| 112 ->GetPowerManagerClient() | 114 ->GetPowerManagerClient() |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 } else { | 150 } else { |
| 149 VLOG(1) << "Screen locked without suspend"; | 151 VLOG(1) << "Screen locked without suspend"; |
| 150 } | 152 } |
| 151 } | 153 } |
| 152 | 154 |
| 153 void PowerEventObserver::ScreenIsUnlocked() { | 155 void PowerEventObserver::ScreenIsUnlocked() { |
| 154 screen_locked_ = false; | 156 screen_locked_ = false; |
| 155 } | 157 } |
| 156 | 158 |
| 157 } // namespace ash | 159 } // namespace ash |
| OLD | NEW |