Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: components/browser_watcher/watcher_win.h

Issue 717223002: Browser watcher end-end-to-end . (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/lkgr
Patch Set: Address Erik's comments. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 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 #ifndef COMPONENTS_BROWSER_WATCHER_WATCHER_WIN_H_
5 #define COMPONENTS_BROWSER_WATCHER_WATCHER_WIN_H_
6
7 #include "base/macros.h"
8 #include "base/process/process_handle.h"
9 #include "base/strings/string16.h"
10 #include "base/time/time.h"
11 #include "base/win/scoped_handle.h"
12
13 namespace base {
14 class CommandLine;
15 }
16
17 namespace browser_watcher {
18
19 // Watches for the exit code of a process and records it in a given registry
20 // location.
21 class ExitCodeWatcher {
22 public:
23 // Initialize the watcher with a registry path.
24 explicit ExitCodeWatcher(const base::char16* registry_path);
25 ~ExitCodeWatcher();
26
27 // Initializes from arguments on |cmd_line|, returns true on success.
28 // This function expects the process handle indicated in |cmd_line| to be open
29 // with sufficient privilege to wait and retrieve the process exit code.
30 // It checks the handle for validity and takes ownership of it.
31 // The intent is for this handle to be inherited into the watcher process
32 // hosting the instance of this class.
33 bool ParseArguments(const base::CommandLine& cmd_line);
34
35 // Waits for the process to exit and records its exit code in registry.
36 // This is a blocking call.
37 void WaitForExit();
38
39 base::ProcessHandle process() const { return process_.Get(); }
40
41 private:
42 // The registry path the exit codes are written to.
43 base::string16 registry_path_;
44
45 // Handle, PID, and creation time of the watched process.
46 base::win::ScopedHandle process_;
47 base::ProcessId process_pid_;
48 base::Time process_creation_time_;
49
50 DISALLOW_COPY_AND_ASSIGN(ExitCodeWatcher);
51 };
52
53 } // namespace browser_watcher
54
55 #endif // COMPONENTS_BROWSER_WATCHER_WATCHER_WIN_H_
OLDNEW
« no previous file with comments | « components/browser_watcher/watcher_metrics_provider_win_unittest.cc ('k') | components/browser_watcher/watcher_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698