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

Side by Side Diff: chrome/browser/chromeos/policy/remote_commands/device_command_reboot_job.cc

Issue 1417673009: base: SysInfo::Uptime() returns a TimeDelta (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update perf_provider_chromeos.cc (just updated in another CL) Created 5 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/policy/remote_commands/device_command_reboot_j ob.h" 5 #include "chrome/browser/chromeos/policy/remote_commands/device_command_reboot_j ob.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 bool DeviceCommandRebootJob::IsExpired(base::TimeTicks now) { 48 bool DeviceCommandRebootJob::IsExpired(base::TimeTicks now) {
49 return now > issued_time() + base::TimeDelta::FromMinutes( 49 return now > issued_time() + base::TimeDelta::FromMinutes(
50 kCommandExpirationTimeInMinutes); 50 kCommandExpirationTimeInMinutes);
51 } 51 }
52 52
53 void DeviceCommandRebootJob::RunImpl( 53 void DeviceCommandRebootJob::RunImpl(
54 const CallbackWithResult& succeeded_callback, 54 const CallbackWithResult& succeeded_callback,
55 const CallbackWithResult& failed_callback) { 55 const CallbackWithResult& failed_callback) {
56 // Determines the time delta between the command having been issued and the 56 // Determines the time delta between the command having been issued and the
57 // boot time of the system. 57 // boot time of the system.
58 const base::TimeDelta uptime = 58 const base::TimeDelta uptime = base::SysInfo::Uptime();
59 base::TimeDelta::FromMilliseconds(base::SysInfo::Uptime());
60 const base::TimeTicks boot_time = base::TimeTicks::Now() - uptime; 59 const base::TimeTicks boot_time = base::TimeTicks::Now() - uptime;
61 const base::TimeDelta delta = boot_time - issued_time(); 60 const base::TimeDelta delta = boot_time - issued_time();
62 // If the reboot command was issued before the system booted, we inform the 61 // If the reboot command was issued before the system booted, we inform the
63 // server that the reboot succeeded. Otherwise, the reboot must still be 62 // server that the reboot succeeded. Otherwise, the reboot must still be
64 // performed and we invoke it. |kMinimumUptimeInMinutes| defines a lower limit 63 // performed and we invoke it. |kMinimumUptimeInMinutes| defines a lower limit
65 // on the uptime to avoid uninterruptable reboot loops. 64 // on the uptime to avoid uninterruptable reboot loops.
66 if (delta > base::TimeDelta()) { 65 if (delta > base::TimeDelta()) {
67 base::ThreadTaskRunnerHandle::Get()->PostTask( 66 base::ThreadTaskRunnerHandle::Get()->PostTask(
68 FROM_HERE, base::Bind(succeeded_callback, nullptr)); 67 FROM_HERE, base::Bind(succeeded_callback, nullptr));
69 return; 68 return;
(...skipping 14 matching lines...) Expand all
84 83
85 base::TimeDelta DeviceCommandRebootJob::GetCommmandTimeout() const { 84 base::TimeDelta DeviceCommandRebootJob::GetCommmandTimeout() const {
86 return base::TimeDelta::FromMinutes(kMinimumUptimeInMinutes); 85 return base::TimeDelta::FromMinutes(kMinimumUptimeInMinutes);
87 } 86 }
88 87
89 void DeviceCommandRebootJob::Reboot() const { 88 void DeviceCommandRebootJob::Reboot() const {
90 power_manager_client_->RequestRestart(); 89 power_manager_client_->RequestRestart();
91 } 90 }
92 91
93 } // namespace policy 92 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/caps/generate_state_json.cc ('k') | chrome/browser/metrics/perf/perf_provider_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698