OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/chromeos/system/automatic_reboot_manager.h" | 5 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "base/prefs/pref_registry_simple.h" | 21 #include "base/prefs/pref_registry_simple.h" |
22 #include "base/prefs/pref_service.h" | 22 #include "base/prefs/pref_service.h" |
23 #include "base/single_thread_task_runner.h" | 23 #include "base/single_thread_task_runner.h" |
24 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
25 #include "base/thread_task_runner_handle.h" | 25 #include "base/thread_task_runner_handle.h" |
26 #include "base/threading/sequenced_worker_pool.h" | 26 #include "base/threading/sequenced_worker_pool.h" |
27 #include "base/time/tick_clock.h" | 27 #include "base/time/tick_clock.h" |
28 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
29 #include "chrome/browser/chromeos/login/user_manager.h" | 29 #include "chrome/browser/chromeos/login/user_manager.h" |
30 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.h" |
31 #include "chrome/common/chrome_paths.h" | |
32 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 32 #include "chromeos/chromeos_paths.h" |
33 #include "chromeos/chromeos_switches.h" | 33 #include "chromeos/chromeos_switches.h" |
34 #include "chromeos/dbus/dbus_thread_manager.h" | 34 #include "chromeos/dbus/dbus_thread_manager.h" |
35 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
36 #include "content/public/browser/notification_details.h" | 36 #include "content/public/browser/notification_details.h" |
37 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
38 #include "content/public/browser/notification_source.h" | 38 #include "content/public/browser/notification_source.h" |
39 | 39 |
40 namespace chromeos { | 40 namespace chromeos { |
41 namespace system { | 41 namespace system { |
42 | 42 |
(...skipping 13 matching lines...) Expand all Loading... |
56 return base::TimeDelta(); | 56 return base::TimeDelta(); |
57 } | 57 } |
58 return base::TimeDelta::FromMilliseconds(seconds * 1000.0); | 58 return base::TimeDelta::FromMilliseconds(seconds * 1000.0); |
59 } | 59 } |
60 | 60 |
61 void GetSystemEventTimes( | 61 void GetSystemEventTimes( |
62 scoped_refptr<base::SingleThreadTaskRunner> reply_task_runner, | 62 scoped_refptr<base::SingleThreadTaskRunner> reply_task_runner, |
63 base::Callback<void( | 63 base::Callback<void( |
64 const AutomaticRebootManager::SystemEventTimes&)> reply) { | 64 const AutomaticRebootManager::SystemEventTimes&)> reply) { |
65 base::FilePath uptime_file; | 65 base::FilePath uptime_file; |
66 CHECK(PathService::Get(chrome::FILE_UPTIME, &uptime_file)); | 66 CHECK(PathService::Get(chromeos::FILE_UPTIME, &uptime_file)); |
67 base::FilePath update_reboot_needed_uptime_file; | 67 base::FilePath update_reboot_needed_uptime_file; |
68 CHECK(PathService::Get(chrome::FILE_UPDATE_REBOOT_NEEDED_UPTIME, | 68 CHECK(PathService::Get(chromeos::FILE_UPDATE_REBOOT_NEEDED_UPTIME, |
69 &update_reboot_needed_uptime_file)); | 69 &update_reboot_needed_uptime_file)); |
70 reply_task_runner->PostTask(FROM_HERE, base::Bind(reply, | 70 reply_task_runner->PostTask(FROM_HERE, base::Bind(reply, |
71 AutomaticRebootManager::SystemEventTimes( | 71 AutomaticRebootManager::SystemEventTimes( |
72 ReadTimeDeltaFromFile(uptime_file), | 72 ReadTimeDeltaFromFile(uptime_file), |
73 ReadTimeDeltaFromFile(update_reboot_needed_uptime_file)))); | 73 ReadTimeDeltaFromFile(update_reboot_needed_uptime_file)))); |
74 } | 74 } |
75 | 75 |
76 void SaveUpdateRebootNeededUptime() { | 76 void SaveUpdateRebootNeededUptime() { |
77 const base::TimeDelta kZeroTimeDelta; | 77 const base::TimeDelta kZeroTimeDelta; |
78 | 78 |
79 base::FilePath update_reboot_needed_uptime_file; | 79 base::FilePath update_reboot_needed_uptime_file; |
80 CHECK(PathService::Get(chrome::FILE_UPDATE_REBOOT_NEEDED_UPTIME, | 80 CHECK(PathService::Get(chromeos::FILE_UPDATE_REBOOT_NEEDED_UPTIME, |
81 &update_reboot_needed_uptime_file)); | 81 &update_reboot_needed_uptime_file)); |
82 const base::TimeDelta last_update_reboot_needed_uptime = | 82 const base::TimeDelta last_update_reboot_needed_uptime = |
83 ReadTimeDeltaFromFile(update_reboot_needed_uptime_file); | 83 ReadTimeDeltaFromFile(update_reboot_needed_uptime_file); |
84 if (last_update_reboot_needed_uptime != kZeroTimeDelta) | 84 if (last_update_reboot_needed_uptime != kZeroTimeDelta) |
85 return; | 85 return; |
86 | 86 |
87 base::FilePath uptime_file; | 87 base::FilePath uptime_file; |
88 CHECK(PathService::Get(chrome::FILE_UPTIME, &uptime_file)); | 88 CHECK(PathService::Get(chromeos::FILE_UPTIME, &uptime_file)); |
89 const base::TimeDelta uptime = ReadTimeDeltaFromFile(uptime_file); | 89 const base::TimeDelta uptime = ReadTimeDeltaFromFile(uptime_file); |
90 if (uptime == kZeroTimeDelta) | 90 if (uptime == kZeroTimeDelta) |
91 return; | 91 return; |
92 | 92 |
93 std::string update_reboot_needed_uptime = | 93 std::string update_reboot_needed_uptime = |
94 base::DoubleToString(uptime.InSecondsF()); | 94 base::DoubleToString(uptime.InSecondsF()); |
95 file_util::WriteFile(update_reboot_needed_uptime_file, | 95 file_util::WriteFile(update_reboot_needed_uptime_file, |
96 update_reboot_needed_uptime.c_str(), | 96 update_reboot_needed_uptime.c_str(), |
97 update_reboot_needed_uptime.size()); | 97 update_reboot_needed_uptime.size()); |
98 } | 98 } |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 345 |
346 void AutomaticRebootManager::Reboot() { | 346 void AutomaticRebootManager::Reboot() { |
347 login_screen_idle_timer_.reset(); | 347 login_screen_idle_timer_.reset(); |
348 grace_start_timer_.reset(); | 348 grace_start_timer_.reset(); |
349 grace_end_timer_.reset(); | 349 grace_end_timer_.reset(); |
350 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | 350 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
351 } | 351 } |
352 | 352 |
353 } // namespace system | 353 } // namespace system |
354 } // namespace chromeos | 354 } // namespace chromeos |
OLD | NEW |