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 |
| 10 #include <memory> |
9 #include <vector> | 11 #include <vector> |
10 | 12 |
11 #include "base/command_line.h" | 13 #include "base/command_line.h" |
12 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/win/scoped_handle.h" | 15 #include "base/win/scoped_handle.h" |
15 | 16 |
16 // Class for configuring the Chrome watcher process via the command-line. This | 17 // Class for configuring the Chrome watcher process via the command-line. This |
17 // accepts configuration from the parent process and generates the required | 18 // accepts configuration from the parent process and generates the required |
18 // command-line. | 19 // command-line. |
19 // | 20 // |
20 // It provides functionality for the common task of sharing handles from a | 21 // It provides functionality for the common task of sharing handles from a |
21 // parent to a child process, automatically duplicating them with the | 22 // parent to a child process, automatically duplicating them with the |
22 // appropriate permissions. These handles are closed when the generator is | 23 // appropriate permissions. These handles are closed when the generator is |
23 // destroyed so the generator must outlive the process creation. | 24 // destroyed so the generator must outlive the process creation. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 class ChromeWatcherCommandLine { | 69 class ChromeWatcherCommandLine { |
69 public: | 70 public: |
70 // Causes the process to explode if any inherited handles weren't taken from | 71 // Causes the process to explode if any inherited handles weren't taken from |
71 // this object. | 72 // this object. |
72 ~ChromeWatcherCommandLine(); | 73 ~ChromeWatcherCommandLine(); |
73 | 74 |
74 // Parses the provided command-line used to launch a Chrome Watcher process. | 75 // Parses the provided command-line used to launch a Chrome Watcher process. |
75 // If this fails any successfully opened handles will be closed prior to | 76 // If this fails any successfully opened handles will be closed prior to |
76 // return. Returns a ChromeWatcherCommandLine object on success, nullptr | 77 // return. Returns a ChromeWatcherCommandLine object on success, nullptr |
77 // otherwise. | 78 // otherwise. |
78 static scoped_ptr<ChromeWatcherCommandLine> InterpretCommandLine( | 79 static std::unique_ptr<ChromeWatcherCommandLine> InterpretCommandLine( |
79 const base::CommandLine& command_line); | 80 const base::CommandLine& command_line); |
80 | 81 |
81 // Accessors for handles. Any handles not taken from this object at the time | 82 // Accessors for handles. Any handles not taken from this object at the time |
82 // of its destruction will cause a terminal error. | 83 // of its destruction will cause a terminal error. |
83 base::win::ScopedHandle TakeOnInitializedEventHandle(); | 84 base::win::ScopedHandle TakeOnInitializedEventHandle(); |
84 base::win::ScopedHandle TakeParentProcessHandle(); | 85 base::win::ScopedHandle TakeParentProcessHandle(); |
85 | 86 |
86 // Returns the ID of the main thread in the parent process. | 87 // Returns the ID of the main thread in the parent process. |
87 DWORD main_thread_id() const { return main_thread_id_; } | 88 DWORD main_thread_id() const { return main_thread_id_; } |
88 | 89 |
(...skipping 28 matching lines...) Expand all Loading... |
117 // before returning them. Returns true if all parameters are successfully parsed | 118 // before returning them. Returns true if all parameters are successfully parsed |
118 // and false otherwise. In case of partial failure, any successfully parsed | 119 // and false otherwise. In case of partial failure, any successfully parsed |
119 // HANDLEs will be closed. | 120 // HANDLEs will be closed. |
120 bool InterpretChromeWatcherCommandLine( | 121 bool InterpretChromeWatcherCommandLine( |
121 const base::CommandLine& command_line, | 122 const base::CommandLine& command_line, |
122 base::win::ScopedHandle* parent_process, | 123 base::win::ScopedHandle* parent_process, |
123 DWORD* main_thread_id, | 124 DWORD* main_thread_id, |
124 base::win::ScopedHandle* on_initialized_event); | 125 base::win::ScopedHandle* on_initialized_event); |
125 | 126 |
126 #endif // CHROME_APP_CHROME_WATCHER_COMMAND_LINE_WIN_H_ | 127 #endif // CHROME_APP_CHROME_WATCHER_COMMAND_LINE_WIN_H_ |
OLD | NEW |