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

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: rebase 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 63
63 protected: 64 protected:
64 virtual ~Client() {} 65 virtual ~Client() {}
65 }; 66 };
66 67
67 // Launches the process asynchronously, calling the client when the result is 68 // Launches the process asynchronously, calling the client when the result is
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.
73 //
74 // If |process_error_callback| is provided, it will be called if a Mojo error
75 // is encountered when processing messages from the child process. This
76 // callback must be safe to call from any thread.
72 ChildProcessLauncher( 77 ChildProcessLauncher(
73 SandboxedProcessLauncherDelegate* delegate, 78 SandboxedProcessLauncherDelegate* delegate,
74 base::CommandLine* cmd_line, 79 base::CommandLine* cmd_line,
75 int child_process_id, 80 int child_process_id,
76 Client* client, 81 Client* client,
77 const std::string& mojo_child_token, 82 const std::string& mojo_child_token,
83 const mojo::edk::ProcessErrorCallback& process_error_callback,
78 bool terminate_on_shutdown = true); 84 bool terminate_on_shutdown = true);
79 ~ChildProcessLauncher(); 85 ~ChildProcessLauncher();
80 86
81 // True if the process is being launched and so the handle isn't available. 87 // True if the process is being launched and so the handle isn't available.
82 bool IsStarting(); 88 bool IsStarting();
83 89
84 // Getter for the process. Only call after the process has started. 90 // Getter for the process. Only call after the process has started.
85 const base::Process& GetProcess() const; 91 const base::Process& GetProcess() const;
86 92
87 // Call this when the child process exits to know what happened to it. 93 // 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); 151 int child_process_id);
146 #endif 152 #endif
147 153
148 Client* client_; 154 Client* client_;
149 BrowserThread::ID client_thread_id_; 155 BrowserThread::ID client_thread_id_;
150 base::Process process_; 156 base::Process process_;
151 base::TerminationStatus termination_status_; 157 base::TerminationStatus termination_status_;
152 int exit_code_; 158 int exit_code_;
153 ZygoteHandle zygote_; 159 ZygoteHandle zygote_;
154 bool starting_; 160 bool starting_;
161 const mojo::edk::ProcessErrorCallback process_error_callback_;
162
155 // Controls whether the child process should be terminated on browser 163 // Controls whether the child process should be terminated on browser
156 // shutdown. Default behavior is to terminate the child. 164 // shutdown. Default behavior is to terminate the child.
157 const bool terminate_child_on_shutdown_; 165 const bool terminate_child_on_shutdown_;
158 166
159 // Host side platform handle to establish Mojo IPC. 167 // Host side platform handle to establish Mojo IPC.
160 mojo::edk::ScopedPlatformHandle mojo_host_platform_handle_; 168 mojo::edk::ScopedPlatformHandle mojo_host_platform_handle_;
161 const std::string mojo_child_token_; 169 const std::string mojo_child_token_;
162 170
163 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_; 171 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_;
164 172
165 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); 173 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher);
166 }; 174 };
167 175
168 } // namespace content 176 } // namespace content
169 177
170 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ 178 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_
OLDNEW
« no previous file with comments | « content/browser/browser_child_process_host_impl.cc ('k') | content/browser/child_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698