Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/chromeos/logging.h" | |
| 11 #include "base/location.h" | 10 #include "base/location.h" |
| 12 #include "base/logging.h" | 11 #include "base/logging.h" |
| 13 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 14 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 14 #include "base/syslog_logging.h" | |
| 15 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "chromeos/dbus/power_manager_client.h" | 17 #include "chromeos/dbus/power_manager_client.h" |
| 18 #include "components/policy/proto/device_management_backend.pb.h" | 18 #include "components/policy/proto/device_management_backend.pb.h" |
| 19 | 19 |
| 20 namespace policy { | 20 namespace policy { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // Determines the time, measured from the time of issue, after which the command | 24 // Determines the time, measured from the time of issue, after which the command |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 42 } | 42 } |
| 43 | 43 |
| 44 bool DeviceCommandRebootJob::IsExpired(base::TimeTicks now) { | 44 bool DeviceCommandRebootJob::IsExpired(base::TimeTicks now) { |
| 45 return now > issued_time() + base::TimeDelta::FromMinutes( | 45 return now > issued_time() + base::TimeDelta::FromMinutes( |
| 46 kCommandExpirationTimeInMinutes); | 46 kCommandExpirationTimeInMinutes); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void DeviceCommandRebootJob::RunImpl( | 49 void DeviceCommandRebootJob::RunImpl( |
| 50 const CallbackWithResult& succeeded_callback, | 50 const CallbackWithResult& succeeded_callback, |
| 51 const CallbackWithResult& failed_callback) { | 51 const CallbackWithResult& failed_callback) { |
| 52 CHROMEOS_SYSLOG(WARNING) << "Running reboot command."; | 52 SYSLOG(INFO) << "Running reboot command."; |
|
Andrew T Wilson (Slow)
2016/10/14 12:41:14
Should this really be INFO? Doesn't this mean this
Marton Hunyady
2016/10/14 12:47:58
According to https://cs.chromium.org/chromium/src/
| |
| 53 | 53 |
| 54 // Determines the time delta between the command having been issued and the | 54 // Determines the time delta between the command having been issued and the |
| 55 // boot time of the system. | 55 // boot time of the system. |
| 56 const base::TimeDelta uptime = base::SysInfo::Uptime(); | 56 const base::TimeDelta uptime = base::SysInfo::Uptime(); |
| 57 const base::TimeTicks boot_time = base::TimeTicks::Now() - uptime; | 57 const base::TimeTicks boot_time = base::TimeTicks::Now() - uptime; |
| 58 const base::TimeDelta delta = boot_time - issued_time(); | 58 const base::TimeDelta delta = boot_time - issued_time(); |
| 59 // If the reboot command was issued before the system booted, we inform the | 59 // If the reboot command was issued before the system booted, we inform the |
| 60 // server that the reboot succeeded. Otherwise, the reboot must still be | 60 // server that the reboot succeeded. Otherwise, the reboot must still be |
| 61 // performed and we invoke it. | 61 // performed and we invoke it. |
| 62 if (delta > base::TimeDelta()) { | 62 if (delta > base::TimeDelta()) { |
| 63 CHROMEOS_SYSLOG(WARNING) << "Ignoring reboot command issued " << delta | 63 SYSLOG(WARNING) << "Ignoring reboot command issued " << delta |
| 64 << " before current boot time"; | 64 << " before current boot time"; |
| 65 base::ThreadTaskRunnerHandle::Get()->PostTask( | 65 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 66 FROM_HERE, base::Bind(succeeded_callback, nullptr)); | 66 FROM_HERE, base::Bind(succeeded_callback, nullptr)); |
| 67 return; | 67 return; |
| 68 } | 68 } |
| 69 | 69 |
| 70 CHROMEOS_SYSLOG(WARNING) << "Rebooting immediately."; | 70 SYSLOG(INFO) << "Rebooting immediately."; |
| 71 power_manager_client_->RequestRestart(); | 71 power_manager_client_->RequestRestart(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 base::TimeDelta DeviceCommandRebootJob::GetCommmandTimeout() const { | 74 base::TimeDelta DeviceCommandRebootJob::GetCommmandTimeout() const { |
| 75 return base::TimeDelta::FromMinutes(kCommandExpirationTimeInMinutes); | 75 return base::TimeDelta::FromMinutes(kCommandExpirationTimeInMinutes); |
| 76 } | 76 } |
| 77 | 77 |
| 78 } // namespace policy | 78 } // namespace policy |
| OLD | NEW |