Update SplitString calls to new form
[chromium-blink-merge.git] / remoting / host / shutdown_watchdog.h
blob660d581a6f0bdfbba1bd442b474807b4366bc6d2
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.
5 #ifndef REMOTING_HOST_SHUTDOWN_WATCHDOG_H_
6 #define REMOTING_HOST_SHUTDOWN_WATCHDOG_H_
8 #include "base/synchronization/lock.h"
9 #include "base/threading/watchdog.h"
11 namespace remoting {
13 // This implements a watchdog timer that ensures the host process eventually
14 // terminates, even if some threads are blocked or being kept alive for
15 // some reason. This is not expected to trigger if host shutdown is working
16 // correctly (on a normally loaded system). The triggering of the alarm
17 // indicates a sign of trouble, and so the Alarm() method will log some
18 // diagnostic information before shutting down the process.
19 class ShutdownWatchdog : public base::Watchdog {
20 public:
21 // Creates a watchdog that waits for |duration| (after the watchdog is
22 // armed) before shutting down the process.
23 explicit ShutdownWatchdog(const base::TimeDelta& duration);
25 // This method should be called to set the process's exit-code before arming
26 // the watchdog. Otherwise an exit-code of 0 is assumed.
27 void SetExitCode(int exit_code);
29 void Alarm() override;
31 private:
32 int exit_code_;
34 // Protects |exit_code_|, since Alarm() gets called on a separate thread.
35 base::Lock lock_;
37 DISALLOW_COPY_AND_ASSIGN(ShutdownWatchdog);
40 } // namespace remoting
42 #endif // REMOTING_HOST_SHUTDOWN_WATCHDOG_H_