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

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

Issue 1630923002: Remove PRODUCT_STRING_PATH from chrome_constants.h on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@c2_rm_PSP_profile_resetter
Patch Set: de-dup is_win blocks in GN too Created 4 years, 8 months 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
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 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 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 #ifndef COMPONENTS_BROWSER_WATCHER_EXIT_CODE_WATCHER_WIN_H_ 4 #ifndef COMPONENTS_BROWSER_WATCHER_EXIT_CODE_WATCHER_WIN_H_
5 #define COMPONENTS_BROWSER_WATCHER_EXIT_CODE_WATCHER_WIN_H_ 5 #define COMPONENTS_BROWSER_WATCHER_EXIT_CODE_WATCHER_WIN_H_
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/process/process.h" 8 #include "base/process/process.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_piece.h"
10 #include "base/time/time.h" 11 #include "base/time/time.h"
11 #include "base/win/scoped_handle.h" 12 #include "base/win/scoped_handle.h"
12 13
13 namespace browser_watcher { 14 namespace browser_watcher {
14 15
15 // Watches for the exit code of a process and records it in a given registry 16 // Watches for the exit code of a process and records it in a given registry
16 // location. 17 // location.
17 class ExitCodeWatcher { 18 class ExitCodeWatcher {
18 public: 19 public:
19 // Initialize the watcher with a registry path. 20 // Initialize the watcher with a registry path.
20 explicit ExitCodeWatcher(const base::char16* registry_path); 21 explicit ExitCodeWatcher(base::StringPiece16 registry_path);
21 ~ExitCodeWatcher(); 22 ~ExitCodeWatcher();
22 23
23 // Initializes from arguments on |cmd_line|, returns true on success. 24 // Initializes from arguments on |cmd_line|, returns true on success.
24 // This function expects |process| to be open with sufficient privilege to 25 // This function expects |process| to be open with sufficient privilege to
25 // wait and retrieve the process exit code. 26 // wait and retrieve the process exit code.
26 // It checks the handle for validity and takes ownership of it. 27 // It checks the handle for validity and takes ownership of it.
27 // The intent is for this handle to be inherited into the watcher process 28 // The intent is for this handle to be inherited into the watcher process
28 // hosting the instance of this class. 29 // hosting the instance of this class.
29 bool Initialize(base::Process process); 30 bool Initialize(base::Process process);
30 31
31 // Waits for the process to exit and records its exit code in registry. 32 // Waits for the process to exit and records its exit code in registry.
32 // This is a blocking call. 33 // This is a blocking call.
33 void WaitForExit(); 34 void WaitForExit();
34 35
35 const base::Process& process() const { return process_; } 36 const base::Process& process() const { return process_; }
36 int exit_code() const { return exit_code_; } 37 int exit_code() const { return exit_code_; }
37 38
38 private: 39 private:
39 // Writes |exit_code| to registry, returns true on success. 40 // Writes |exit_code| to registry, returns true on success.
40 bool WriteProcessExitCode(int exit_code); 41 bool WriteProcessExitCode(int exit_code);
41 42
42 // The registry path the exit codes are written to. 43 // The registry path the exit codes are written to.
43 base::string16 registry_path_; 44 const base::string16 registry_path_;
44 45
45 // Watched process and its creation time. 46 // Watched process and its creation time.
46 base::Process process_; 47 base::Process process_;
47 base::Time process_creation_time_; 48 base::Time process_creation_time_;
48 49
49 // The exit code of the watched process. Valid after WaitForExit. 50 // The exit code of the watched process. Valid after WaitForExit.
50 int exit_code_; 51 int exit_code_;
51 52
52 DISALLOW_COPY_AND_ASSIGN(ExitCodeWatcher); 53 DISALLOW_COPY_AND_ASSIGN(ExitCodeWatcher);
53 }; 54 };
54 55
55 } // namespace browser_watcher 56 } // namespace browser_watcher
56 57
57 #endif // COMPONENTS_BROWSER_WATCHER_EXIT_CODE_WATCHER_WIN_H_ 58 #endif // COMPONENTS_BROWSER_WATCHER_EXIT_CODE_WATCHER_WIN_H_
OLDNEW
« no previous file with comments | « chrome/common/metrics_constants_util_win.cc ('k') | components/browser_watcher/exit_code_watcher_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698