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 <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 | 14 |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
17 #include "base/callback.h" | 17 #include "base/callback.h" |
18 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
19 #include "base/files/file_util.h" | 19 #include "base/files/file_util.h" |
20 #include "base/files/scoped_file.h" | 20 #include "base/files/scoped_file.h" |
21 #include "base/location.h" | 21 #include "base/location.h" |
22 #include "base/logging.h" | 22 #include "base/logging.h" |
23 #include "base/memory/ref_counted.h" | 23 #include "base/memory/ref_counted.h" |
24 #include "base/message_loop/message_loop.h" | 24 #include "base/message_loop/message_loop.h" |
25 #include "base/path_service.h" | 25 #include "base/path_service.h" |
26 #include "base/posix/eintr_wrapper.h" | 26 #include "base/posix/eintr_wrapper.h" |
27 #include "base/single_thread_task_runner.h" | 27 #include "base/single_thread_task_runner.h" |
28 #include "base/strings/string_number_conversions.h" | 28 #include "base/strings/string_number_conversions.h" |
| 29 #include "base/task_scheduler/post_task.h" |
29 #include "base/threading/sequenced_worker_pool.h" | 30 #include "base/threading/sequenced_worker_pool.h" |
30 #include "base/threading/thread_restrictions.h" | 31 #include "base/threading/thread_restrictions.h" |
31 #include "base/threading/thread_task_runner_handle.h" | 32 #include "base/threading/thread_task_runner_handle.h" |
32 #include "base/time/tick_clock.h" | 33 #include "base/time/tick_clock.h" |
33 #include "chrome/browser/browser_process.h" | 34 #include "chrome/browser/browser_process.h" |
34 #include "chrome/browser/chrome_notification_types.h" | 35 #include "chrome/browser/chrome_notification_types.h" |
35 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
36 #include "chromeos/chromeos_paths.h" | 37 #include "chromeos/chromeos_paths.h" |
37 #include "chromeos/chromeos_switches.h" | 38 #include "chromeos/chromeos_switches.h" |
38 #include "chromeos/dbus/dbus_thread_manager.h" | 39 #include "chromeos/dbus/dbus_thread_manager.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 void AutomaticRebootManager::UpdateStatusChanged( | 229 void AutomaticRebootManager::UpdateStatusChanged( |
229 const UpdateEngineClient::Status& status) { | 230 const UpdateEngineClient::Status& status) { |
230 // Ignore repeated notifications that a reboot is necessary. This is important | 231 // Ignore repeated notifications that a reboot is necessary. This is important |
231 // so that only the time of the first notification is taken into account and | 232 // so that only the time of the first notification is taken into account and |
232 // repeated notifications do not postpone the reboot request and grace period. | 233 // repeated notifications do not postpone the reboot request and grace period. |
233 if (status.status != UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT || | 234 if (status.status != UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT || |
234 !have_boot_time_ || have_update_reboot_needed_time_) { | 235 !have_boot_time_ || have_update_reboot_needed_time_) { |
235 return; | 236 return; |
236 } | 237 } |
237 | 238 |
238 content::BrowserThread::PostBlockingPoolTask( | 239 base::PostTaskWithTraits( |
239 FROM_HERE, base::Bind(&SaveUpdateRebootNeededUptime)); | 240 FROM_HERE, |
| 241 base::TaskTraits() |
| 242 .WithPriority(base::TaskPriority::BACKGROUND) |
| 243 .WithShutdownBehavior(base::TaskShutdownBehavior::BLOCK_SHUTDOWN) |
| 244 .MayBlock(), |
| 245 base::Bind(&SaveUpdateRebootNeededUptime)); |
240 | 246 |
241 update_reboot_needed_time_ = clock_->NowTicks(); | 247 update_reboot_needed_time_ = clock_->NowTicks(); |
242 have_update_reboot_needed_time_ = true; | 248 have_update_reboot_needed_time_ = true; |
243 | 249 |
244 Reschedule(); | 250 Reschedule(); |
245 } | 251 } |
246 | 252 |
247 void AutomaticRebootManager::OnUserActivity(const ui::Event* event) { | 253 void AutomaticRebootManager::OnUserActivity(const ui::Event* event) { |
248 if (!login_screen_idle_timer_) | 254 if (!login_screen_idle_timer_) |
249 return; | 255 return; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 } | 417 } |
412 | 418 |
413 login_screen_idle_timer_.reset(); | 419 login_screen_idle_timer_.reset(); |
414 grace_start_timer_.reset(); | 420 grace_start_timer_.reset(); |
415 grace_end_timer_.reset(); | 421 grace_end_timer_.reset(); |
416 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | 422 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
417 } | 423 } |
418 | 424 |
419 } // namespace system | 425 } // namespace system |
420 } // namespace chromeos | 426 } // namespace chromeos |
OLD | NEW |