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

Side by Side Diff: content/browser/utility_process_host_impl.cc

Issue 1883323002: Reland of Use a token to initialise ChannelMojo and MojoApplication everywhere. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 #include "content/browser/utility_process_host_impl.h" 5 #include "content/browser/utility_process_host_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // launches a UtilityProcessHost. 252 // launches a UtilityProcessHost.
253 process_.reset(new BrowserChildProcessHostImpl(PROCESS_TYPE_UTILITY, this)); 253 process_.reset(new BrowserChildProcessHostImpl(PROCESS_TYPE_UTILITY, this));
254 process_->SetName(name_); 254 process_->SetName(name_);
255 255
256 std::string channel_id = process_->GetHost()->CreateChannel(); 256 std::string channel_id = process_->GetHost()->CreateChannel();
257 if (channel_id.empty()) { 257 if (channel_id.empty()) {
258 NotifyAndDelete(); 258 NotifyAndDelete();
259 return false; 259 return false;
260 } 260 }
261 261
262 std::string mojo_token = mojo_application_host_->InitWithToken();
263
264 if (RenderProcessHost::run_renderer_in_process()) { 262 if (RenderProcessHost::run_renderer_in_process()) {
265 DCHECK(g_utility_main_thread_factory); 263 DCHECK(g_utility_main_thread_factory);
266 // See comment in RenderProcessHostImpl::Init() for the background on why we 264 // See comment in RenderProcessHostImpl::Init() for the background on why we
267 // support single process mode this way. 265 // support single process mode this way.
268 in_process_thread_.reset( 266 in_process_thread_.reset(
269 g_utility_main_thread_factory(InProcessChildThreadParams( 267 g_utility_main_thread_factory(InProcessChildThreadParams(
270 channel_id, BrowserThread::UnsafeGetMessageLoopForThread( 268 channel_id, BrowserThread::UnsafeGetMessageLoopForThread(
271 BrowserThread::IO)->task_runner(), 269 BrowserThread::IO)->task_runner(),
272 mojo::MessagePipeHandle(), mojo_token))); 270 std::string(), mojo_application_host_->GetToken())));
273 in_process_thread_->Start(); 271 in_process_thread_->Start();
274 } else { 272 } else {
275 const base::CommandLine& browser_command_line = 273 const base::CommandLine& browser_command_line =
276 *base::CommandLine::ForCurrentProcess(); 274 *base::CommandLine::ForCurrentProcess();
277 275
278 bool has_cmd_prefix = browser_command_line.HasSwitch( 276 bool has_cmd_prefix = browser_command_line.HasSwitch(
279 switches::kUtilityCmdPrefix); 277 switches::kUtilityCmdPrefix);
280 278
281 #if defined(OS_ANDROID) 279 #if defined(OS_ANDROID)
282 // readlink("/prof/self/exe") sometimes fails on Android at startup. 280 // readlink("/prof/self/exe") sometimes fails on Android at startup.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 exposed_dir_); 339 exposed_dir_);
342 } 340 }
343 341
344 #if defined(OS_WIN) 342 #if defined(OS_WIN)
345 // Let the utility process know if it is intended to be elevated. 343 // Let the utility process know if it is intended to be elevated.
346 if (run_elevated_) 344 if (run_elevated_)
347 cmd_line->AppendSwitch(switches::kUtilityProcessRunningElevated); 345 cmd_line->AppendSwitch(switches::kUtilityProcessRunningElevated);
348 #endif 346 #endif
349 347
350 cmd_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, 348 cmd_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken,
351 mojo_token); 349 mojo_application_host_->GetToken());
352 350
353 process_->Launch( 351 process_->Launch(
354 new UtilitySandboxedProcessLauncherDelegate(exposed_dir_, 352 new UtilitySandboxedProcessLauncherDelegate(exposed_dir_,
355 run_elevated_, 353 run_elevated_,
356 no_sandbox_, env_, 354 no_sandbox_, env_,
357 process_->GetHost()), 355 process_->GetHost()),
358 cmd_line, 356 cmd_line,
359 true); 357 true);
360 } 358 }
361 359
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 void UtilityProcessHostImpl::NotifyLaunchFailedAndDelete( 405 void UtilityProcessHostImpl::NotifyLaunchFailedAndDelete(
408 base::WeakPtr<UtilityProcessHostImpl> host) { 406 base::WeakPtr<UtilityProcessHostImpl> host) {
409 if (!host) 407 if (!host)
410 return; 408 return;
411 409
412 host->OnProcessLaunchFailed(); 410 host->OnProcessLaunchFailed();
413 delete host.get(); 411 delete host.get();
414 } 412 }
415 413
416 } // namespace content 414 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | content/child/child_thread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698