OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "remoting/host/shutdown_watchdog.h" |
| 6 |
| 7 #include <stdlib.h> // For _exit() on Windows. |
| 8 |
| 9 #include "base/logging.h" |
| 10 |
| 11 #if defined(OS_POSIX) |
| 12 #include <unistd.h> |
| 13 #endif // defined(OS_POSIX) |
| 14 |
| 15 namespace remoting { |
| 16 |
| 17 ShutdownWatchdog::ShutdownWatchdog(const base::TimeDelta& duration) |
| 18 : base::Watchdog(duration, "Shutdown watchdog", true) { |
| 19 } |
| 20 |
| 21 void ShutdownWatchdog::SetExitCode(int exit_code) { |
| 22 base::AutoLock lock(lock_); |
| 23 exit_code_ = exit_code; |
| 24 } |
| 25 |
| 26 void ShutdownWatchdog::Alarm() { |
| 27 // Holding a lock while calling _exit() might not be a safe thing to do, so |
| 28 // make a local copy. |
| 29 int exit_code; |
| 30 { |
| 31 base::AutoLock lock(lock_); |
| 32 exit_code = exit_code_; |
| 33 } |
| 34 |
| 35 LOG(ERROR) << "Shutdown watchdog triggered, exiting with code " << exit_code; |
| 36 _exit(exit_code); |
| 37 } |
| 38 |
| 39 } // namespace remoting |
OLD | NEW |