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

Side by Side Diff: content/browser/child_process_launcher.h

Issue 2054303002: Kill child processes on bad Mojo messages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bad-message
Patch Set: . Created 4 years, 6 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) 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/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/process/kill.h" 11 #include "base/process/kill.h"
12 #include "base/process/launch.h" 12 #include "base/process/launch.h"
13 #include "base/process/process.h" 13 #include "base/process/process.h"
14 #include "base/threading/non_thread_safe.h" 14 #include "base/threading/non_thread_safe.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/common/sandboxed_process_launcher_delegate.h" 18 #include "content/public/common/sandboxed_process_launcher_delegate.h"
19 #include "mojo/edk/embedder/embedder.h"
19 #include "mojo/edk/embedder/scoped_platform_handle.h" 20 #include "mojo/edk/embedder/scoped_platform_handle.h"
20 21
21 #if defined(OS_WIN) 22 #if defined(OS_WIN)
22 #include "sandbox/win/src/sandbox_types.h" 23 #include "sandbox/win/src/sandbox_types.h"
23 #endif 24 #endif
24 25
25 namespace base { 26 namespace base {
26 class CommandLine; 27 class CommandLine;
27 } 28 }
28 29
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // ready. Deleting this object before the process is created is safe, since 69 // ready. Deleting this object before the process is created is safe, since
69 // the callback won't be called. If the process is still running by the time 70 // the callback won't be called. If the process is still running by the time
70 // this object destructs, it will be terminated. 71 // this object destructs, it will be terminated.
71 // Takes ownership of cmd_line. 72 // Takes ownership of cmd_line.
72 ChildProcessLauncher( 73 ChildProcessLauncher(
73 SandboxedProcessLauncherDelegate* delegate, 74 SandboxedProcessLauncherDelegate* delegate,
74 base::CommandLine* cmd_line, 75 base::CommandLine* cmd_line,
75 int child_process_id, 76 int child_process_id,
76 Client* client, 77 Client* client,
77 const std::string& mojo_child_token, 78 const std::string& mojo_child_token,
79 const mojo::edk::ProcessErrorCallback& process_error_callback,
78 bool terminate_on_shutdown = true); 80 bool terminate_on_shutdown = true);
79 ~ChildProcessLauncher(); 81 ~ChildProcessLauncher();
80 82
81 // True if the process is being launched and so the handle isn't available. 83 // True if the process is being launched and so the handle isn't available.
82 bool IsStarting(); 84 bool IsStarting();
83 85
84 // Getter for the process. Only call after the process has started. 86 // Getter for the process. Only call after the process has started.
85 const base::Process& GetProcess() const; 87 const base::Process& GetProcess() const;
86 88
87 // Call this when the child process exits to know what happened to it. 89 // Call this when the child process exits to know what happened to it.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 int child_process_id); 147 int child_process_id);
146 #endif 148 #endif
147 149
148 Client* client_; 150 Client* client_;
149 BrowserThread::ID client_thread_id_; 151 BrowserThread::ID client_thread_id_;
150 base::Process process_; 152 base::Process process_;
151 base::TerminationStatus termination_status_; 153 base::TerminationStatus termination_status_;
152 int exit_code_; 154 int exit_code_;
153 ZygoteHandle zygote_; 155 ZygoteHandle zygote_;
154 bool starting_; 156 bool starting_;
157 const mojo::edk::ProcessErrorCallback process_error_callback_;
158
155 // Controls whether the child process should be terminated on browser 159 // Controls whether the child process should be terminated on browser
156 // shutdown. Default behavior is to terminate the child. 160 // shutdown. Default behavior is to terminate the child.
157 const bool terminate_child_on_shutdown_; 161 const bool terminate_child_on_shutdown_;
158 162
159 // Host side platform handle to establish Mojo IPC. 163 // Host side platform handle to establish Mojo IPC.
160 mojo::edk::ScopedPlatformHandle mojo_host_platform_handle_; 164 mojo::edk::ScopedPlatformHandle mojo_host_platform_handle_;
161 const std::string mojo_child_token_; 165 const std::string mojo_child_token_;
162 166
163 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_; 167 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_;
164 168
165 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); 169 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher);
166 }; 170 };
167 171
168 } // namespace content 172 } // namespace content
169 173
170 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ 174 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698