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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 SandboxedProcessLauncherDelegate* delegate, |
80 base::CommandLine* cmd_line, | 80 base::CommandLine* cmd_line, |
81 int child_process_id, | 81 int child_process_id, |
82 Client* client, | 82 Client* client, |
83 const base::SharedMemory* field_trial_state, | |
84 const std::string& mojo_child_token, | 83 const std::string& mojo_child_token, |
85 const mojo::edk::ProcessErrorCallback& process_error_callback, | 84 const mojo::edk::ProcessErrorCallback& process_error_callback, |
86 bool terminate_on_shutdown = true); | 85 bool terminate_on_shutdown = true); |
87 ~ChildProcessLauncher(); | 86 ~ChildProcessLauncher(); |
88 | 87 |
89 // 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. |
90 bool IsStarting(); | 89 bool IsStarting(); |
91 | 90 |
92 // Getter for the process. Only call after the process has started. | 91 // Getter for the process. Only call after the process has started. |
93 const base::Process& GetProcess() const; | 92 const base::Process& GetProcess() const; |
(...skipping 17 matching lines...) Expand all Loading... |
111 void SetProcessBackgrounded(bool background); | 110 void SetProcessBackgrounded(bool background); |
112 | 111 |
113 // Replaces the ChildProcessLauncher::Client for testing purposes. Returns the | 112 // Replaces the ChildProcessLauncher::Client for testing purposes. Returns the |
114 // previous client. | 113 // previous client. |
115 Client* ReplaceClientForTest(Client* client); | 114 Client* ReplaceClientForTest(Client* client); |
116 | 115 |
117 private: | 116 private: |
118 // 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. |
119 void Launch(SandboxedProcessLauncherDelegate* delegate, | 118 void Launch(SandboxedProcessLauncherDelegate* delegate, |
120 base::CommandLine* cmd_line, | 119 base::CommandLine* cmd_line, |
121 int child_process_id, | 120 int child_process_id); |
122 const base::SharedMemory* field_trial_state); | |
123 | 121 |
124 void UpdateTerminationStatus(bool known_dead); | 122 void UpdateTerminationStatus(bool known_dead); |
125 | 123 |
126 // This is always called on the client thread after an attempt | 124 // This is always called on the client thread after an attempt |
127 // to launch the child process on the launcher thread. | 125 // to launch the child process on the launcher thread. |
128 // It makes sure we always perform the necessary cleanup if the | 126 // It makes sure we always perform the necessary cleanup if the |
129 // client went away. | 127 // client went away. |
130 static void DidLaunch(base::WeakPtr<ChildProcessLauncher> instance, | 128 static void DidLaunch(base::WeakPtr<ChildProcessLauncher> instance, |
131 bool terminate_on_shutdown, | 129 bool terminate_on_shutdown, |
132 mojo::edk::ScopedPlatformHandle server_handle, | 130 mojo::edk::ScopedPlatformHandle server_handle, |
(...skipping 30 matching lines...) Expand all Loading... |
163 const std::string mojo_child_token_; | 161 const std::string mojo_child_token_; |
164 | 162 |
165 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_; | 163 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_; |
166 | 164 |
167 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); | 165 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); |
168 }; | 166 }; |
169 | 167 |
170 } // namespace content | 168 } // namespace content |
171 | 169 |
172 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ | 170 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ |
OLD | NEW |