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

Side by Side Diff: ash/wm/maximize_mode/maximize_mode_controller.cc

Issue 1229853004: Base: Make TimeDelta constructors deal with overflow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove static initializers Created 5 years, 5 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 | « no previous file | base/time/time.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/maximize_mode/maximize_mode_controller.h" 5 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
6 6
7 #include "ash/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/accelerators/accelerator_table.h" 8 #include "ash/accelerators/accelerator_table.h"
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // inaccurate and a lid that is fully open may appear to be near closed (and 50 // inaccurate and a lid that is fully open may appear to be near closed (and
51 // vice versa). 51 // vice versa).
52 const float kMinStableAngle = 20.0f; 52 const float kMinStableAngle = 20.0f;
53 const float kMaxStableAngle = 340.0f; 53 const float kMaxStableAngle = 340.0f;
54 #endif // OS_CHROMEOS 54 #endif // OS_CHROMEOS
55 55
56 // The time duration to consider the lid to be recently opened. 56 // The time duration to consider the lid to be recently opened.
57 // This is used to prevent entering maximize mode if an erroneous accelerometer 57 // This is used to prevent entering maximize mode if an erroneous accelerometer
58 // reading makes the lid appear to be fully open when the user is opening the 58 // reading makes the lid appear to be fully open when the user is opening the
59 // lid from a closed position. 59 // lid from a closed position.
60 const base::TimeDelta kLidRecentlyOpenedDuration = 60 const int kLidRecentlyOpenedDurationSeconds = 2;
61 base::TimeDelta::FromSeconds(2);
62 61
63 #if defined(OS_CHROMEOS) 62 #if defined(OS_CHROMEOS)
64 // When the device approaches vertical orientation (i.e. portrait orientation) 63 // When the device approaches vertical orientation (i.e. portrait orientation)
65 // the accelerometers for the base and lid approach the same values (i.e. 64 // the accelerometers for the base and lid approach the same values (i.e.
66 // gravity pointing in the direction of the hinge). When this happens abrupt 65 // gravity pointing in the direction of the hinge). When this happens abrupt
67 // small acceleration perpendicular to the hinge can lead to incorrect hinge 66 // small acceleration perpendicular to the hinge can lead to incorrect hinge
68 // angle calculations. To prevent this the accelerometer updates will be 67 // angle calculations. To prevent this the accelerometer updates will be
69 // smoothed over time in order to reduce this noise. 68 // smoothed over time in order to reduce this noise.
70 // This is the minimum acceleration parallel to the hinge under which to begin 69 // This is the minimum acceleration parallel to the hinge under which to begin
71 // smoothing in m/s^2. 70 // smoothing in m/s^2.
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 } 361 }
363 } 362 }
364 363
365 bool MaximizeModeController::WasLidOpenedRecently() const { 364 bool MaximizeModeController::WasLidOpenedRecently() const {
366 if (last_lid_open_time_.is_null()) 365 if (last_lid_open_time_.is_null())
367 return false; 366 return false;
368 367
369 base::TimeTicks now = tick_clock_->NowTicks(); 368 base::TimeTicks now = tick_clock_->NowTicks();
370 DCHECK(now >= last_lid_open_time_); 369 DCHECK(now >= last_lid_open_time_);
371 base::TimeDelta elapsed_time = now - last_lid_open_time_; 370 base::TimeDelta elapsed_time = now - last_lid_open_time_;
372 return elapsed_time <= kLidRecentlyOpenedDuration; 371 return elapsed_time.InSeconds() <= kLidRecentlyOpenedDurationSeconds;
373 } 372 }
374 373
375 void MaximizeModeController::SetTickClockForTest( 374 void MaximizeModeController::SetTickClockForTest(
376 scoped_ptr<base::TickClock> tick_clock) { 375 scoped_ptr<base::TickClock> tick_clock) {
377 DCHECK(tick_clock_); 376 DCHECK(tick_clock_);
378 tick_clock_ = tick_clock.Pass(); 377 tick_clock_ = tick_clock.Pass();
379 } 378 }
380 379
381 } // namespace ash 380 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | base/time/time.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698