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

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

Issue 2680973006: Mojo EDK: Add safe process connection API (Closed)
Patch Set: . Created 3 years, 10 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 <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/shared_memory.h" 12 #include "base/memory/shared_memory.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/process/kill.h" 14 #include "base/process/kill.h"
15 #include "base/process/process.h" 15 #include "base/process/process.h"
16 #include "base/threading/non_thread_safe.h" 16 #include "base/threading/non_thread_safe.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "content/browser/child_process_launcher_helper.h" 18 #include "content/browser/child_process_launcher_helper.h"
19 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/common/result_codes.h" 21 #include "content/public/common/result_codes.h"
22 #include "mojo/edk/embedder/embedder.h" 22 #include "mojo/edk/embedder/pending_process_connection.h"
23 #include "mojo/edk/embedder/scoped_platform_handle.h" 23 #include "mojo/edk/embedder/scoped_platform_handle.h"
24 24
25 namespace base { 25 namespace base {
26 class CommandLine; 26 class CommandLine;
27 } 27 }
28 28
29 namespace content { 29 namespace content {
30 30
31 class SandboxedProcessLauncherDelegate; 31 class SandboxedProcessLauncherDelegate;
32 32
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 std::unique_ptr<SandboxedProcessLauncherDelegate> delegate, 79 std::unique_ptr<SandboxedProcessLauncherDelegate> delegate,
80 std::unique_ptr<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 std::unique_ptr<mojo::edk::PendingProcessConnection> pending_connection,
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
91 // Getter for the process. Only call after the process has started. 91 // Getter for the process. Only call after the process has started.
92 const base::Process& GetProcess() const; 92 const base::Process& GetProcess() const;
93 93
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 Client* client_; 139 Client* client_;
140 BrowserThread::ID client_thread_id_; 140 BrowserThread::ID client_thread_id_;
141 141
142 // The process associated with this ChildProcessLauncher. Set in Notify by 142 // The process associated with this ChildProcessLauncher. Set in Notify by
143 // ChildProcessLauncherHelper once the process was started. 143 // ChildProcessLauncherHelper once the process was started.
144 internal::ChildProcessLauncherHelper::Process process_; 144 internal::ChildProcessLauncherHelper::Process process_;
145 145
146 base::TerminationStatus termination_status_; 146 base::TerminationStatus termination_status_;
147 int exit_code_; 147 int exit_code_;
148 bool starting_; 148 bool starting_;
149 std::unique_ptr<mojo::edk::PendingProcessConnection> pending_connection_;
149 const mojo::edk::ProcessErrorCallback process_error_callback_; 150 const mojo::edk::ProcessErrorCallback process_error_callback_;
150 151
151 // Controls whether the child process should be terminated on browser 152 // Controls whether the child process should be terminated on browser
152 // shutdown. Default behavior is to terminate the child. 153 // shutdown. Default behavior is to terminate the child.
153 const bool terminate_child_on_shutdown_; 154 const bool terminate_child_on_shutdown_;
154 155
155 const std::string mojo_child_token_;
156
157 scoped_refptr<internal::ChildProcessLauncherHelper> helper_; 156 scoped_refptr<internal::ChildProcessLauncherHelper> helper_;
158 157
159 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_; 158 base::WeakPtrFactory<ChildProcessLauncher> weak_factory_;
160 159
161 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher); 160 DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncher);
162 }; 161 };
163 162
164 } // namespace content 163 } // namespace content
165 164
166 #endif // CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_H_ 165 #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