OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ | 5 #ifndef CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ |
6 #define CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ | 6 #define CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ |
7 | 7 |
8 #include "base/files/scoped_file.h" | 8 #include "base/files/scoped_file.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // Launches the process asynchronously, calling the client when the result is | 69 // Launches the process asynchronously, calling the client when the result is |
70 // ready. Deleting this object before the process is created is safe, since | 70 // ready. Deleting this object before the process is created is safe, since |
71 // the callback won't be called. If the process is still running by the time | 71 // the callback won't be called. If the process is still running by the time |
72 // this object destructs, it will be terminated. | 72 // this object destructs, it will be terminated. |
73 // Takes ownership of cmd_line. | 73 // Takes ownership of cmd_line. |
74 // | 74 // |
75 // If |process_error_callback| is provided, it will be called if a Mojo error | 75 // If |process_error_callback| is provided, it will be called if a Mojo error |
76 // is encountered when processing messages from the child process. This | 76 // is encountered when processing messages from the child process. This |
77 // callback must be safe to call from any thread. | 77 // callback must be safe to call from any thread. |
78 ChildProcessLauncher( | 78 ChildProcessLauncher( |
79 SandboxedProcessLauncherDelegate* delegate, | 79 std::unique_ptr<SandboxedProcessLauncherDelegate> delegate, |
80 base::CommandLine* cmd_line, | 80 std::unique_ptr<base::CommandLine> cmd_line, |
81 int child_process_id, | 81 int child_process_id, |
82 Client* client, | 82 Client* client, |
83 const std::string& mojo_child_token, | 83 const std::string& mojo_child_token, |
84 const mojo::edk::ProcessErrorCallback& process_error_callback, | 84 const mojo::edk::ProcessErrorCallback& process_error_callback, |
85 bool terminate_on_shutdown = true); | 85 bool terminate_on_shutdown = true); |
86 ~ChildProcessLauncher(); | 86 ~ChildProcessLauncher(); |
87 | 87 |
88 // True if the process is being launched and so the handle isn't available. | 88 // True if the process is being launched and so the handle isn't available. |
89 bool IsStarting(); | 89 bool IsStarting(); |
90 | 90 |
(...skipping 17 matching lines...) Expand all Loading... |
108 // Changes whether the process runs in the background or not. Only call | 108 // Changes whether the process runs in the background or not. Only call |
109 // this after the process has started. | 109 // this after the process has started. |
110 void SetProcessBackgrounded(bool background); | 110 void SetProcessBackgrounded(bool background); |
111 | 111 |
112 // Replaces the ChildProcessLauncher::Client for testing purposes. Returns the | 112 // Replaces the ChildProcessLauncher::Client for testing purposes. Returns the |
113 // previous client. | 113 // previous client. |
114 Client* ReplaceClientForTest(Client* client); | 114 Client* ReplaceClientForTest(Client* client); |
115 | 115 |
116 private: | 116 private: |
117 // Posts a task to the launcher thread to do the actual work. | 117 // Posts a task to the launcher thread to do the actual work. |
118 void Launch(SandboxedProcessLauncherDelegate* delegate, | 118 void Launch(std::unique_ptr<SandboxedProcessLauncherDelegate> delegate, |
119 base::CommandLine* cmd_line, | 119 std::unique_ptr<base::CommandLine> cmd_line, |
120 int child_process_id); | 120 int child_process_id); |
121 | 121 |
122 void UpdateTerminationStatus(bool known_dead); | 122 void UpdateTerminationStatus(bool known_dead); |
123 | 123 |
124 // This is always called on the client thread after an attempt | 124 // This is always called on the client thread after an attempt |
125 // to launch the child process on the launcher thread. | 125 // to launch the child process on the launcher thread. |
126 // It makes sure we always perform the necessary cleanup if the | 126 // It makes sure we always perform the necessary cleanup if the |
127 // client went away. | 127 // client went away. |
128 static void DidLaunch(base::WeakPtr<ChildProcessLauncher> instance, | 128 static void DidLaunch(base::WeakPtr<ChildProcessLauncher> instance, |
129 bool terminate_on_shutdown, | 129 bool terminate_on_shutdown, |
(...skipping 27 matching lines...) Expand all Loading... |
157 const std::string mojo_child_token_; | 157 const std::string mojo_child_token_; |
158 | 158 |
159 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_; | 159 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_; |
160 | 160 |
161 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); | 161 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); |
162 }; | 162 }; |
163 | 163 |
164 } // namespace content | 164 } // namespace content |
165 | 165 |
166 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ | 166 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ |
OLD | NEW |