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

Unified Diff: content/browser/child_process_launcher.cc

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 side-by-side diff with in-line comments
Download patch
Index: content/browser/child_process_launcher.cc
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index 6970d248feaae5d83716e9eee6dee0c0d243d81a..d471973367142fe5c2dd525b401fe4250e965ea8 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -23,13 +23,14 @@ ChildProcessLauncher::ChildProcessLauncher(
std::unique_ptr<base::CommandLine> command_line,
int child_process_id,
Client* client,
- const std::string& mojo_child_token,
+ std::unique_ptr<mojo::edk::PendingProcessConnection> pending_connection,
const mojo::edk::ProcessErrorCallback& process_error_callback,
bool terminate_on_shutdown)
: client_(client),
termination_status_(base::TERMINATION_STATUS_NORMAL_TERMINATION),
exit_code_(RESULT_CODE_NORMAL_EXIT),
starting_(true),
+ pending_connection_(std::move(pending_connection)),
process_error_callback_(process_error_callback),
#if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \
defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \
@@ -38,7 +39,6 @@ ChildProcessLauncher::ChildProcessLauncher(
#else
terminate_child_on_shutdown_(terminate_on_shutdown),
#endif
- mojo_child_token_(mojo_child_token),
weak_factory_(this) {
DCHECK(CalledOnValidThread());
CHECK(BrowserThread::GetCurrentThreadIdentifier(&client_thread_id_));
@@ -80,13 +80,13 @@ void ChildProcessLauncher::Notify(
if (process_.process.IsValid()) {
// Set up Mojo IPC to the new process.
- mojo::edk::ChildProcessLaunched(process_.process.Handle(),
- std::move(server_handle),
- mojo_child_token_,
- process_error_callback_);
+ DCHECK(pending_connection_);
+ pending_connection_->Connect(process_.process.Handle(),
+ std::move(server_handle),
+ process_error_callback_);
client_->OnProcessLaunched();
} else {
- mojo::edk::ChildProcessLaunchFailed(mojo_child_token_);
+ pending_connection_.reset();
Sam McNally 2017/02/09 05:38:47 Can we clear this unconditionally?
Ken Rockot(use gerrit already) 2017/02/09 06:01:58 Sure, done
termination_status_ = base::TERMINATION_STATUS_LAUNCH_FAILED;
client_->OnProcessLaunchFailed(error_code);
}

Powered by Google App Engine
This is Rietveld 408576698