Remove EWK_BRINGUPS for M120 #3
[platform/framework/web/chromium-efl.git] / chrome / app / exit_code_watcher_win.h
1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 #ifndef CHROME_APP_EXIT_CODE_WATCHER_WIN_H_
5 #define CHROME_APP_EXIT_CODE_WATCHER_WIN_H_
6
7 #include "base/process/process.h"
8 #include "base/threading/thread.h"
9 #include "base/win/scoped_handle.h"
10
11 // Watches for the exit code of a process and records
12 class ExitCodeWatcher {
13  public:
14   ExitCodeWatcher();
15
16   ExitCodeWatcher(const ExitCodeWatcher&) = delete;
17   ExitCodeWatcher& operator=(const ExitCodeWatcher&) = delete;
18
19   ~ExitCodeWatcher();
20
21   // This function expects |process| to be open with sufficient privilege to
22   // wait and retrieve the process exit code.
23   // It checks the handle for validity and takes ownership of it.
24   bool Initialize(base::Process process);
25
26   bool StartWatching();
27
28   void StopWatching();
29
30   const base::Process& process() const { return process_; }
31   int ExitCodeForTesting() const { return exit_code_; }
32
33  private:
34   // Waits for the process to exit and records its exit code in a histogram.
35   // This is a blocking call.
36   void WaitForExit();
37
38   // Watched process and its creation time.
39   base::Process process_;
40
41   // The thread that runs WaitForExit().
42   base::Thread background_thread_;
43
44   // The exit code of the watched process. Valid after WaitForExit.
45   int exit_code_;
46
47   // Event handle to use to stop exit watcher thread
48   base::win::ScopedHandle stop_watching_handle_;
49 };
50
51 #endif  // CHROME_APP_EXIT_CODE_WATCHER_WIN_H_