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

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

Issue 1891043002: Revert 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
262 if (RenderProcessHost::run_renderer_in_process()) { 264 if (RenderProcessHost::run_renderer_in_process()) {
263 DCHECK(g_utility_main_thread_factory); 265 DCHECK(g_utility_main_thread_factory);
264 // See comment in RenderProcessHostImpl::Init() for the background on why we 266 // See comment in RenderProcessHostImpl::Init() for the background on why we
265 // support single process mode this way. 267 // support single process mode this way.
266 in_process_thread_.reset( 268 in_process_thread_.reset(
267 g_utility_main_thread_factory(InProcessChildThreadParams( 269 g_utility_main_thread_factory(InProcessChildThreadParams(
268 channel_id, BrowserThread::UnsafeGetMessageLoopForThread( 270 channel_id, BrowserThread::UnsafeGetMessageLoopForThread(
269 BrowserThread::IO)->task_runner(), 271 BrowserThread::IO)->task_runner(),
270 std::string(), mojo_application_host_->GetToken()))); 272 mojo::MessagePipeHandle(), mojo_token)));
271 in_process_thread_->Start(); 273 in_process_thread_->Start();
272 } else { 274 } else {
273 const base::CommandLine& browser_command_line = 275 const base::CommandLine& browser_command_line =
274 *base::CommandLine::ForCurrentProcess(); 276 *base::CommandLine::ForCurrentProcess();
275 277
276 bool has_cmd_prefix = browser_command_line.HasSwitch( 278 bool has_cmd_prefix = browser_command_line.HasSwitch(
277 switches::kUtilityCmdPrefix); 279 switches::kUtilityCmdPrefix);
278 280
279 #if defined(OS_ANDROID) 281 #if defined(OS_ANDROID)
280 // readlink("/prof/self/exe") sometimes fails on Android at startup. 282 // readlink("/prof/self/exe") sometimes fails on Android at startup.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 exposed_dir_); 341 exposed_dir_);
340 } 342 }
341 343
342 #if defined(OS_WIN) 344 #if defined(OS_WIN)
343 // Let the utility process know if it is intended to be elevated. 345 // Let the utility process know if it is intended to be elevated.
344 if (run_elevated_) 346 if (run_elevated_)
345 cmd_line->AppendSwitch(switches::kUtilityProcessRunningElevated); 347 cmd_line->AppendSwitch(switches::kUtilityProcessRunningElevated);
346 #endif 348 #endif
347 349
348 cmd_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, 350 cmd_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken,
349 mojo_application_host_->GetToken()); 351 mojo_token);
350 352
351 process_->Launch( 353 process_->Launch(
352 new UtilitySandboxedProcessLauncherDelegate(exposed_dir_, 354 new UtilitySandboxedProcessLauncherDelegate(exposed_dir_,
353 run_elevated_, 355 run_elevated_,
354 no_sandbox_, env_, 356 no_sandbox_, env_,
355 process_->GetHost()), 357 process_->GetHost()),
356 cmd_line, 358 cmd_line,
357 true); 359 true);
358 } 360 }
359 361
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 void UtilityProcessHostImpl::NotifyLaunchFailedAndDelete( 407 void UtilityProcessHostImpl::NotifyLaunchFailedAndDelete(
406 base::WeakPtr<UtilityProcessHostImpl> host) { 408 base::WeakPtr<UtilityProcessHostImpl> host) {
407 if (!host) 409 if (!host)
408 return; 410 return;
409 411
410 host->OnProcessLaunchFailed(); 412 host->OnProcessLaunchFailed();
411 delete host.get(); 413 delete host.get();
412 } 414 }
413 415
414 } // namespace content 416 } // 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