Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: ash/system/chromeos/power/power_event_observer.cc

Issue 2319783002: mash: Allow a subset of D-Bus clients to be created in DBusThreadManager (Closed)
Patch Set: WIP, add DBusThreadManagerAsh and DBusThreadManagerChrome Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/shell.cc ('k') | ash/system/chromeos/power/power_event_observer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/dbus_thread_manager_ash.h"
7 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/system/tray/system_tray_notifier.h" 9 #include "ash/common/system/tray/system_tray_notifier.h"
9 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
10 #include "ash/shell.h" 11 #include "ash/shell.h"
11 #include "ash/wm/power_button_controller.h" 12 #include "ash/wm/power_button_controller.h"
12 #include "chromeos/dbus/dbus_thread_manager.h" 13 // #include "chromeos/dbus/dbus_thread_manager.h"
13 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
14 #include "ui/aura/window_tree_host.h" 15 #include "ui/aura/window_tree_host.h"
15 #include "ui/base/user_activity/user_activity_detector.h" 16 #include "ui/base/user_activity/user_activity_detector.h"
16 #include "ui/compositor/compositor.h" 17 #include "ui/compositor/compositor.h"
17 #include "ui/display/chromeos/display_configurator.h" 18 #include "ui/display/chromeos/display_configurator.h"
18 19
19 namespace ash { 20 namespace ash {
20 21
21 namespace { 22 namespace {
22 23
(...skipping 15 matching lines...) Expand all
38 39
39 void OnSuspendDisplaysCompleted(const base::Closure& suspend_callback, 40 void OnSuspendDisplaysCompleted(const base::Closure& suspend_callback,
40 bool status) { 41 bool status) {
41 suspend_callback.Run(); 42 suspend_callback.Run();
42 } 43 }
43 44
44 } // namespace 45 } // namespace
45 46
46 PowerEventObserver::PowerEventObserver() 47 PowerEventObserver::PowerEventObserver()
47 : screen_locked_(false), waiting_for_lock_screen_animations_(false) { 48 : screen_locked_(false), waiting_for_lock_screen_animations_(false) {
48 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( 49 DBusThreadManagerAsh::Get()->GetPowerManagerClient()->AddObserver(
49 this); 50 this);
50 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver( 51 DBusThreadManagerAsh::Get()->GetSessionManagerClient()->AddObserver(
51 this); 52 this);
52 } 53 }
53 54
54 PowerEventObserver::~PowerEventObserver() { 55 PowerEventObserver::~PowerEventObserver() {
55 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( 56 DBusThreadManagerAsh::Get()->GetPowerManagerClient()->RemoveObserver(
56 this); 57 this);
57 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver( 58 DBusThreadManagerAsh::Get()->GetSessionManagerClient()->RemoveObserver(
58 this); 59 this);
59 } 60 }
60 61
61 void PowerEventObserver::OnLockAnimationsComplete() { 62 void PowerEventObserver::OnLockAnimationsComplete() {
62 VLOG(1) << "Screen locker animations have completed."; 63 VLOG(1) << "Screen locker animations have completed.";
63 waiting_for_lock_screen_animations_ = false; 64 waiting_for_lock_screen_animations_ = false;
64 65
65 if (!screen_lock_callback_.is_null()) { 66 if (!screen_lock_callback_.is_null()) {
66 StopRenderingRequests(); 67 StopRenderingRequests();
67 68
(...skipping 18 matching lines...) Expand all
86 // until the lock screen is fully visible. While it is sufficient from a 87 // until the lock screen is fully visible. While it is sufficient from a
87 // security perspective to block only until the lock screen is ready, which 88 // security perspective to block only until the lock screen is ready, which
88 // guarantees that the contents of the user's screen are no longer visible, 89 // guarantees that the contents of the user's screen are no longer visible,
89 // this leads to poor UX on the first resume since neither the user pod nor 90 // this leads to poor UX on the first resume since neither the user pod nor
90 // the header bar will be visible for a few hundred milliseconds until the GPU 91 // the header bar will be visible for a few hundred milliseconds until the GPU
91 // process starts rendering again. To deal with this, the suspend is delayed 92 // process starts rendering again. To deal with this, the suspend is delayed
92 // until all the lock screen animations have completed and the suspend request 93 // until all the lock screen animations have completed and the suspend request
93 // is unblocked from OnLockAnimationsComplete(). 94 // is unblocked from OnLockAnimationsComplete().
94 if (!screen_locked_ && delegate->ShouldLockScreenBeforeSuspending() && 95 if (!screen_locked_ && delegate->ShouldLockScreenBeforeSuspending() &&
95 delegate->CanLockScreen()) { 96 delegate->CanLockScreen()) {
96 screen_lock_callback_ = chromeos::DBusThreadManager::Get() 97 screen_lock_callback_ = DBusThreadManagerAsh::Get()
97 ->GetPowerManagerClient() 98 ->GetPowerManagerClient()
98 ->GetSuspendReadinessCallback(); 99 ->GetSuspendReadinessCallback();
99 VLOG(1) << "Requesting screen lock from PowerEventObserver"; 100 VLOG(1) << "Requesting screen lock from PowerEventObserver";
100 chromeos::DBusThreadManager::Get() 101 DBusThreadManagerAsh::Get()
101 ->GetSessionManagerClient() 102 ->GetSessionManagerClient()
102 ->RequestLockScreen(); 103 ->RequestLockScreen();
103 } else if (waiting_for_lock_screen_animations_) { 104 } else if (waiting_for_lock_screen_animations_) {
104 // The lock-before-suspending pref has been set and the lock screen is ready 105 // 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 106 // 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 107 // request is canceled after the lock screen is ready but before the
107 // animations have completed and then another suspend request is immediately 108 // animations have completed and then another suspend request is immediately
108 // started. In practice, it is highly unlikely that this will ever happen 109 // 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 110 // 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. 111 // is a memory leak in the GPU and weird artifacts on the screen.
111 screen_lock_callback_ = chromeos::DBusThreadManager::Get() 112 screen_lock_callback_ = DBusThreadManagerAsh::Get()
112 ->GetPowerManagerClient() 113 ->GetPowerManagerClient()
113 ->GetSuspendReadinessCallback(); 114 ->GetSuspendReadinessCallback();
114 } else { 115 } else {
115 // The lock-before-suspending pref is not set or the screen has already been 116 // The lock-before-suspending pref is not set or the screen has already been
116 // locked and the animations have completed. Rendering can be stopped now. 117 // locked and the animations have completed. Rendering can be stopped now.
117 StopRenderingRequests(); 118 StopRenderingRequests();
118 } 119 }
119 120
120 ui::UserActivityDetector::Get()->OnDisplayPowerChanging(); 121 ui::UserActivityDetector::Get()->OnDisplayPowerChanging();
121 Shell::GetInstance()->display_configurator()->SuspendDisplays(base::Bind( 122 Shell::GetInstance()->display_configurator()->SuspendDisplays(base::Bind(
122 &OnSuspendDisplaysCompleted, chromeos::DBusThreadManager::Get() 123 &OnSuspendDisplaysCompleted, DBusThreadManagerAsh::Get()
123 ->GetPowerManagerClient() 124 ->GetPowerManagerClient()
124 ->GetSuspendReadinessCallback())); 125 ->GetSuspendReadinessCallback()));
125 } 126 }
126 127
127 void PowerEventObserver::SuspendDone(const base::TimeDelta& sleep_duration) { 128 void PowerEventObserver::SuspendDone(const base::TimeDelta& sleep_duration) {
128 Shell::GetInstance()->display_configurator()->ResumeDisplays(); 129 Shell::GetInstance()->display_configurator()->ResumeDisplays();
129 WmShell::Get()->system_tray_notifier()->NotifyRefreshClock(); 130 WmShell::Get()->system_tray_notifier()->NotifyRefreshClock();
130 131
131 // If the suspend request was being blocked while waiting for the lock 132 // If the suspend request was being blocked while waiting for the lock
132 // animation to complete, clear the blocker since the suspend has already 133 // animation to complete, clear the blocker since the suspend has already
(...skipping 15 matching lines...) Expand all
148 } else { 149 } else {
149 VLOG(1) << "Screen locked without suspend"; 150 VLOG(1) << "Screen locked without suspend";
150 } 151 }
151 } 152 }
152 153
153 void PowerEventObserver::ScreenIsUnlocked() { 154 void PowerEventObserver::ScreenIsUnlocked() {
154 screen_locked_ = false; 155 screen_locked_ = false;
155 } 156 }
156 157
157 } // namespace ash 158 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell.cc ('k') | ash/system/chromeos/power/power_event_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698