OLD | NEW |
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 CHROME_APP_CHROME_WATCHER_COMMAND_LINE_WIN_H_ | 5 #ifndef CHROME_APP_CHROME_WATCHER_COMMAND_LINE_WIN_H_ |
6 #define CHROME_APP_CHROME_WATCHER_COMMAND_LINE_WIN_H_ | 6 #define CHROME_APP_CHROME_WATCHER_COMMAND_LINE_WIN_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/win/scoped_handle.h" | 14 #include "base/win/scoped_handle.h" |
15 | 15 |
16 // Class for configuring the Chrome watcher process via the command-line. This | 16 // Class for configuring the Chrome watcher process via the command-line. This |
17 // accepts configuration from the parent process and generates the required | 17 // accepts configuration from the parent process and generates the required |
18 // command-line. | 18 // command-line. |
19 // | 19 // |
20 // It provides functionality for the common task of sharing handles from a | 20 // It provides functionality for the common task of sharing handles from a |
21 // parent to a child process, automatically duplicating them with the | 21 // parent to a child process, automatically duplicating them with the |
22 // appropriate permissions. These handles are closed when the generator is | 22 // appropriate permissions. These handles are closed when the generator is |
23 // destroyed so the generator must outlive the process creation. | 23 // destroyed so the generator must outlive the process creation. |
24 class ChromeWatcherCommandLineGenerator { | 24 class ChromeWatcherCommandLineGenerator { |
25 public: | 25 public: |
26 explicit ChromeWatcherCommandLineGenerator(const base::FilePath& chrome_exe); | 26 explicit ChromeWatcherCommandLineGenerator(const base::FilePath& chrome_exe); |
| 27 ~ChromeWatcherCommandLineGenerator(); |
27 | 28 |
28 // Sets a handle to be shared with the child process. This will duplicate the | 29 // Sets a handle to be shared with the child process. This will duplicate the |
29 // handle with the inherit flag, with this object retaining ownership of the | 30 // handle with the inherit flag, with this object retaining ownership of the |
30 // duplicated handle. As such, this object must live at least until after the | 31 // duplicated handle. As such, this object must live at least until after the |
31 // watcher process has been created. Returns true on success, false on | 32 // watcher process has been created. Returns true on success, false on |
32 // failure. This can fail if the call to DuplicateHandle fails. Each of these | 33 // failure. This can fail if the call to DuplicateHandle fails. Each of these |
33 // may only be called once. | 34 // may only be called once. |
34 bool SetOnInitializedEventHandle(HANDLE on_initialized_event_handle); | 35 bool SetOnInitializedEventHandle(HANDLE on_initialized_event_handle); |
35 bool SetParentProcessHandle(HANDLE parent_process_handle_); | 36 bool SetParentProcessHandle(HANDLE parent_process_handle_); |
36 | 37 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // before returning them. Returns true if all parameters are successfully parsed | 117 // before returning them. Returns true if all parameters are successfully parsed |
117 // and false otherwise. In case of partial failure, any successfully parsed | 118 // and false otherwise. In case of partial failure, any successfully parsed |
118 // HANDLEs will be closed. | 119 // HANDLEs will be closed. |
119 bool InterpretChromeWatcherCommandLine( | 120 bool InterpretChromeWatcherCommandLine( |
120 const base::CommandLine& command_line, | 121 const base::CommandLine& command_line, |
121 base::win::ScopedHandle* parent_process, | 122 base::win::ScopedHandle* parent_process, |
122 DWORD* main_thread_id, | 123 DWORD* main_thread_id, |
123 base::win::ScopedHandle* on_initialized_event); | 124 base::win::ScopedHandle* on_initialized_event); |
124 | 125 |
125 #endif // CHROME_APP_CHROME_WATCHER_COMMAND_LINE_WIN_H_ | 126 #endif // CHROME_APP_CHROME_WATCHER_COMMAND_LINE_WIN_H_ |
OLD | NEW |