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

Side by Side Diff: ash/wm/lock_state_controller.cc

Issue 2618143002: cros: Remove some OS platform ifdefs from ash (Closed)
Patch Set: rebase Created 3 years, 11 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
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/wm/lock_state_controller.h" 5 #include "ash/wm/lock_state_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
11 #include "ash/cancel_mode.h" 11 #include "ash/cancel_mode.h"
12 #include "ash/common/accessibility_delegate.h" 12 #include "ash/common/accessibility_delegate.h"
13 #include "ash/common/shell_delegate.h" 13 #include "ash/common/shell_delegate.h"
14 #include "ash/common/shutdown_controller.h" 14 #include "ash/common/shutdown_controller.h"
15 #include "ash/common/wm_shell.h" 15 #include "ash/common/wm_shell.h"
16 #include "ash/public/cpp/shell_window_ids.h" 16 #include "ash/public/cpp/shell_window_ids.h"
17 #include "ash/public/interfaces/shutdown.mojom.h" 17 #include "ash/public/interfaces/shutdown.mojom.h"
18 #include "ash/shell.h" 18 #include "ash/shell.h"
19 #include "ash/wm/session_state_animator.h" 19 #include "ash/wm/session_state_animator.h"
20 #include "ash/wm/session_state_animator_impl.h" 20 #include "ash/wm/session_state_animator_impl.h"
21 #include "base/bind.h" 21 #include "base/bind.h"
22 #include "base/bind_helpers.h" 22 #include "base/bind_helpers.h"
23 #include "base/command_line.h" 23 #include "base/command_line.h"
24 #include "base/location.h" 24 #include "base/location.h"
25 #include "base/logging.h" 25 #include "base/logging.h"
26 #include "base/metrics/histogram_macros.h" 26 #include "base/metrics/histogram_macros.h"
27 #include "base/strings/string_util.h" 27 #include "base/strings/string_util.h"
28 #include "base/sys_info.h"
28 #include "base/timer/timer.h" 29 #include "base/timer/timer.h"
30 #include "chromeos/dbus/dbus_thread_manager.h"
31 #include "chromeos/dbus/session_manager_client.h"
29 #include "ui/aura/window_tree_host.h" 32 #include "ui/aura/window_tree_host.h"
30 #include "ui/views/controls/menu/menu_controller.h" 33 #include "ui/views/controls/menu/menu_controller.h"
31 #include "ui/wm/core/compound_event_filter.h" 34 #include "ui/wm/core/compound_event_filter.h"
32 35
33 #if defined(OS_CHROMEOS)
34 #include "base/sys_info.h"
35 #include "chromeos/dbus/dbus_thread_manager.h"
36 #include "chromeos/dbus/session_manager_client.h"
37 #endif
38
39 #define UMA_HISTOGRAM_LOCK_TIMES(name, sample) \ 36 #define UMA_HISTOGRAM_LOCK_TIMES(name, sample) \
40 UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, \ 37 UMA_HISTOGRAM_CUSTOM_TIMES(name, sample, \
41 base::TimeDelta::FromMilliseconds(1), \ 38 base::TimeDelta::FromMilliseconds(1), \
42 base::TimeDelta::FromSeconds(50), 100) 39 base::TimeDelta::FromSeconds(50), 100)
43 40
44 namespace ash { 41 namespace ash {
45 42
46 namespace { 43 namespace {
47 44
48 #if defined(OS_CHROMEOS)
49 const int kMaxShutdownSoundDurationMs = 1500; 45 const int kMaxShutdownSoundDurationMs = 1500;
50 #endif
51 46
52 } // namespace 47 } // namespace
53 48
54 // ASan/TSan/MSan instrument each memory access. This may slow the execution 49 // ASan/TSan/MSan instrument each memory access. This may slow the execution
55 // down significantly. 50 // down significantly.
56 #if defined(MEMORY_SANITIZER) 51 #if defined(MEMORY_SANITIZER)
57 // For MSan the slowdown depends heavily on the value of msan_track_origins GYP 52 // For MSan the slowdown depends heavily on the value of msan_track_origins GYP
58 // flag. The multiplier below corresponds to msan_track_origins=1. 53 // flag. The multiplier below corresponds to msan_track_origins=1.
59 static const int kTimeoutMultiplier = 6; 54 static const int kTimeoutMultiplier = 6;
60 #elif defined(ADDRESS_SANITIZER) && defined(OS_WIN)
61 // Asan/Win has not been optimized yet, give it a higher
62 // timeout multiplier. See http://crbug.com/412471
63 static const int kTimeoutMultiplier = 3;
64 #elif defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || \ 55 #elif defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || \
65 defined(SYZYASAN) 56 defined(SYZYASAN)
66 static const int kTimeoutMultiplier = 2; 57 static const int kTimeoutMultiplier = 2;
67 #else 58 #else
68 static const int kTimeoutMultiplier = 1; 59 static const int kTimeoutMultiplier = 1;
69 #endif 60 #endif
70 61
71 const int LockStateController::kLockFailTimeoutMs = 8000 * kTimeoutMultiplier; 62 const int LockStateController::kLockFailTimeoutMs = 8000 * kTimeoutMultiplier;
72 const int LockStateController::kLockToShutdownTimeoutMs = 150; 63 const int LockStateController::kLockToShutdownTimeoutMs = 150;
73 const int LockStateController::kShutdownRequestDelayMs = 50; 64 const int LockStateController::kShutdownRequestDelayMs = 50;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 } 277 }
287 278
288 void LockStateController::StartRealShutdownTimer(bool with_animation_time) { 279 void LockStateController::StartRealShutdownTimer(bool with_animation_time) {
289 base::TimeDelta duration = 280 base::TimeDelta duration =
290 base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs); 281 base::TimeDelta::FromMilliseconds(kShutdownRequestDelayMs);
291 if (with_animation_time) { 282 if (with_animation_time) {
292 duration += 283 duration +=
293 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); 284 animator_->GetDuration(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN);
294 } 285 }
295 286
296 #if defined(OS_CHROMEOS)
297 base::TimeDelta sound_duration = 287 base::TimeDelta sound_duration =
298 WmShell::Get()->accessibility_delegate()->PlayShutdownSound(); 288 WmShell::Get()->accessibility_delegate()->PlayShutdownSound();
299 sound_duration = 289 sound_duration =
300 std::min(sound_duration, 290 std::min(sound_duration,
301 base::TimeDelta::FromMilliseconds(kMaxShutdownSoundDurationMs)); 291 base::TimeDelta::FromMilliseconds(kMaxShutdownSoundDurationMs));
302 duration = std::max(duration, sound_duration); 292 duration = std::max(duration, sound_duration);
303 #endif
304 293
305 real_shutdown_timer_.Start( 294 real_shutdown_timer_.Start(
306 FROM_HERE, duration, base::Bind(&LockStateController::OnRealPowerTimeout, 295 FROM_HERE, duration, base::Bind(&LockStateController::OnRealPowerTimeout,
307 base::Unretained(this))); 296 base::Unretained(this)));
308 } 297 }
309 298
310 void LockStateController::OnRealPowerTimeout() { 299 void LockStateController::OnRealPowerTimeout() {
311 VLOG(1) << "OnRealPowerTimeout"; 300 VLOG(1) << "OnRealPowerTimeout";
312 DCHECK(shutting_down_); 301 DCHECK(shutting_down_);
313 WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON); 302 WmShell::Get()->RecordUserMetricsAction(UMA_ACCEL_SHUT_DOWN_POWER_BUTTON);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 if (system_is_locked_) { 459 if (system_is_locked_) {
471 DCHECK(!request_lock) << "Got request to lock already-locked system " 460 DCHECK(!request_lock) << "Got request to lock already-locked system "
472 << "at completion of pre-lock animation"; 461 << "at completion of pre-lock animation";
473 return; 462 return;
474 } 463 }
475 464
476 if (request_lock) { 465 if (request_lock) {
477 WmShell::Get()->RecordUserMetricsAction( 466 WmShell::Get()->RecordUserMetricsAction(
478 shutdown_after_lock_ ? UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON 467 shutdown_after_lock_ ? UMA_ACCEL_LOCK_SCREEN_POWER_BUTTON
479 : UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON); 468 : UMA_ACCEL_LOCK_SCREEN_LOCK_BUTTON);
480 #if defined(OS_CHROMEOS)
481 chromeos::DBusThreadManager::Get() 469 chromeos::DBusThreadManager::Get()
482 ->GetSessionManagerClient() 470 ->GetSessionManagerClient()
483 ->RequestLockScreen(); 471 ->RequestLockScreen();
484 #endif
485 } 472 }
486 473
487 base::TimeDelta timeout = 474 base::TimeDelta timeout =
488 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs); 475 base::TimeDelta::FromMilliseconds(kLockFailTimeoutMs);
489 #if defined(OS_CHROMEOS)
490 // Increase lock timeout for slower hardware, see http://crbug.com/350628 476 // Increase lock timeout for slower hardware, see http://crbug.com/350628
491 // The devices with boards "x86-mario", "daisy", "x86-alex" and "x86-zgb" have 477 // The devices with boards "x86-mario", "daisy", "x86-alex" and "x86-zgb" have
492 // slower hardware. For "x86-alex" and "x86-zgb" there are some modifications 478 // slower hardware. For "x86-alex" and "x86-zgb" there are some modifications
493 // like "x86-alex-he". Also there's "daisy", "daisy_spring" and "daisy_skate", 479 // like "x86-alex-he". Also there's "daisy", "daisy_spring" and "daisy_skate",
494 // but they are all different devices and only "daisy" has slower hardware. 480 // but they are all different devices and only "daisy" has slower hardware.
495 const std::string board = base::SysInfo::GetStrippedReleaseBoard(); 481 const std::string board = base::SysInfo::GetStrippedReleaseBoard();
496 if (board == "x86-mario" || board == "daisy" || 482 if (board == "x86-mario" || board == "daisy" ||
497 base::StartsWith(board, "x86-alex", base::CompareCase::SENSITIVE) || 483 base::StartsWith(board, "x86-alex", base::CompareCase::SENSITIVE) ||
498 base::StartsWith(board, "x86-zgb", base::CompareCase::SENSITIVE)) { 484 base::StartsWith(board, "x86-zgb", base::CompareCase::SENSITIVE)) {
499 timeout *= 2; 485 timeout *= 2;
500 } 486 }
501 #endif
502 lock_fail_timer_.Start(FROM_HERE, timeout, this, 487 lock_fail_timer_.Start(FROM_HERE, timeout, this,
503 &LockStateController::OnLockFailTimeout); 488 &LockStateController::OnLockFailTimeout);
504 489
505 lock_duration_timer_.reset(new base::ElapsedTimer()); 490 lock_duration_timer_.reset(new base::ElapsedTimer());
506 } 491 }
507 492
508 void LockStateController::PostLockAnimationFinished() { 493 void LockStateController::PostLockAnimationFinished() {
509 animating_lock_ = false; 494 animating_lock_ = false;
510 VLOG(1) << "PostLockAnimationFinished"; 495 VLOG(1) << "PostLockAnimationFinished";
511 WmShell::Get()->OnLockStateEvent( 496 WmShell::Get()->OnLockStateEvent(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 SessionStateAnimator::AnimationSpeed speed, 551 SessionStateAnimator::AnimationSpeed speed,
567 SessionStateAnimator::AnimationSequence* animation_sequence) { 552 SessionStateAnimator::AnimationSequence* animation_sequence) {
568 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) { 553 if (unlocked_properties_.get() && unlocked_properties_->wallpaper_is_hidden) {
569 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER, 554 animation_sequence->StartAnimation(SessionStateAnimator::WALLPAPER,
570 SessionStateAnimator::ANIMATION_FADE_OUT, 555 SessionStateAnimator::ANIMATION_FADE_OUT,
571 speed); 556 speed);
572 } 557 }
573 } 558 }
574 559
575 } // namespace ash 560 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/immersive_fullscreen_controller_unittest.cc ('k') | ash/wm/lock_state_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698