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

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

Issue 886613002: Introduce the ability to wait for the watcher process to initialize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 4
5 #ifndef COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_ 5 #ifndef COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_
6 #define COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_ 6 #define COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/process/process.h" 10 #include "base/process/process.h"
(...skipping 14 matching lines...) Expand all
25 25
26 // Constructs a watcher client that launches its watcher process using the 26 // Constructs a watcher client that launches its watcher process using the
27 // command line generated by |command_line_generator|. 27 // command line generated by |command_line_generator|.
28 explicit WatcherClient(const CommandLineGenerator& command_line_generator); 28 explicit WatcherClient(const CommandLineGenerator& command_line_generator);
29 29
30 // Launches the watcher process such that the child process is able to inherit 30 // Launches the watcher process such that the child process is able to inherit
31 // a handle to the current process. If use_legacy_launch() is true, this uses 31 // a handle to the current process. If use_legacy_launch() is true, this uses
32 // a non-threadsafe legacy launch mode that's compatible with Windows XP. 32 // a non-threadsafe legacy launch mode that's compatible with Windows XP.
33 void LaunchWatcher(); 33 void LaunchWatcher();
34 34
35 void AddInheritedHandle(HANDLE handle);
36
37 const base::Process& process() const { return process_; }
38
35 // Accessors, exposed only for testing. 39 // Accessors, exposed only for testing.
36 bool use_legacy_launch() const { return use_legacy_launch_; } 40 bool use_legacy_launch() const { return use_legacy_launch_; }
37 void set_use_legacy_launch(bool use_legacy_launch) { 41 void set_use_legacy_launch(bool use_legacy_launch) {
38 use_legacy_launch_ = use_legacy_launch; 42 use_legacy_launch_ = use_legacy_launch;
39 } 43 }
40 base::ProcessHandle process() const { return process_.Handle(); }
41 44
42 private: 45 private:
43 // If true, the watcher process will be launched with XP legacy handle 46 // If true, the watcher process will be launched with XP legacy handle
44 // inheritance. This is not thread safe and can leak random handles into the 47 // inheritance. This is not thread safe and can leak random handles into the
45 // child process, but it's the best we can do on XP. 48 // child process, but it's the best we can do on XP.
46 bool use_legacy_launch_; 49 bool use_legacy_launch_;
47 50
48 // The CommandLineGenerator passed to the constructor. 51 // The CommandLineGenerator passed to the constructor.
49 CommandLineGenerator command_line_generator_; 52 CommandLineGenerator command_line_generator_;
50 53
51 // A handle to the launched watcher process. Valid after a successful 54 // A handle to the launched watcher process. Valid after a successful
52 // LaunchWatcher() call. 55 // LaunchWatcher() call.
53 base::Process process_; 56 base::Process process_;
54 57
58 std::vector<HANDLE> inherited_handles_;
59
55 DISALLOW_COPY_AND_ASSIGN(WatcherClient); 60 DISALLOW_COPY_AND_ASSIGN(WatcherClient);
56 }; 61 };
57 62
58 } // namespace browser_watcher 63 } // namespace browser_watcher
59 64
60 #endif // COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_ 65 #endif // COMPONENTS_BROWSER_WATCHER_WATCHER_CLIENT_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698