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

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

Issue 1923653002: Wire up process launch error codes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix debug and clang Created 4 years, 7 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
« no previous file with comments | « content/browser/utility_process_host_impl.h ('k') | content/common/sandbox_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 if (is_batch_mode_) 248 if (is_batch_mode_)
249 return true; 249 return true;
250 250
251 // Name must be set or metrics_service will crash in any test which 251 // Name must be set or metrics_service will crash in any test which
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(LAUNCH_RESULT_FAILURE);
259 return false; 259 return false;
260 } 260 }
261 261
262 if (RenderProcessHost::run_renderer_in_process()) { 262 if (RenderProcessHost::run_renderer_in_process()) {
263 DCHECK(g_utility_main_thread_factory); 263 DCHECK(g_utility_main_thread_factory);
264 // See comment in RenderProcessHostImpl::Init() for the background on why we 264 // See comment in RenderProcessHostImpl::Init() for the background on why we
265 // support single process mode this way. 265 // support single process mode this way.
266 in_process_thread_.reset( 266 in_process_thread_.reset(
267 g_utility_main_thread_factory(InProcessChildThreadParams( 267 g_utility_main_thread_factory(InProcessChildThreadParams(
268 channel_id, BrowserThread::UnsafeGetMessageLoopForThread( 268 channel_id, BrowserThread::UnsafeGetMessageLoopForThread(
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 client_task_runner_->PostTask( 367 client_task_runner_->PostTask(
368 FROM_HERE, 368 FROM_HERE,
369 base::Bind( 369 base::Bind(
370 base::IgnoreResult(&UtilityProcessHostClient::OnMessageReceived), 370 base::IgnoreResult(&UtilityProcessHostClient::OnMessageReceived),
371 client_.get(), 371 client_.get(),
372 message)); 372 message));
373 373
374 return true; 374 return true;
375 } 375 }
376 376
377 void UtilityProcessHostImpl::OnProcessLaunchFailed() { 377 void UtilityProcessHostImpl::OnProcessLaunchFailed(int error_code) {
378 if (!client_.get()) 378 if (!client_.get())
379 return; 379 return;
380 380
381 client_task_runner_->PostTask( 381 client_task_runner_->PostTask(
382 FROM_HERE, 382 FROM_HERE,
383 base::Bind(&UtilityProcessHostClient::OnProcessLaunchFailed, 383 base::Bind(&UtilityProcessHostClient::OnProcessLaunchFailed,
384 client_.get())); 384 client_.get(),
385 error_code));
385 } 386 }
386 387
387 void UtilityProcessHostImpl::OnProcessCrashed(int exit_code) { 388 void UtilityProcessHostImpl::OnProcessCrashed(int exit_code) {
388 if (!client_.get()) 389 if (!client_.get())
389 return; 390 return;
390 391
391 client_task_runner_->PostTask( 392 client_task_runner_->PostTask(
392 FROM_HERE, 393 FROM_HERE,
393 base::Bind(&UtilityProcessHostClient::OnProcessCrashed, client_.get(), 394 base::Bind(&UtilityProcessHostClient::OnProcessCrashed, client_.get(),
394 exit_code)); 395 exit_code));
395 } 396 }
396 397
397 void UtilityProcessHostImpl::NotifyAndDelete() { 398 void UtilityProcessHostImpl::NotifyAndDelete(int error_code) {
398 BrowserThread::PostTask( 399 BrowserThread::PostTask(
399 BrowserThread::IO, FROM_HERE, 400 BrowserThread::IO, FROM_HERE,
400 base::Bind(&UtilityProcessHostImpl::NotifyLaunchFailedAndDelete, 401 base::Bind(&UtilityProcessHostImpl::NotifyLaunchFailedAndDelete,
401 weak_ptr_factory_.GetWeakPtr())); 402 weak_ptr_factory_.GetWeakPtr(),
403 error_code));
402 } 404 }
403 405
404 // static 406 // static
405 void UtilityProcessHostImpl::NotifyLaunchFailedAndDelete( 407 void UtilityProcessHostImpl::NotifyLaunchFailedAndDelete(
406 base::WeakPtr<UtilityProcessHostImpl> host) { 408 base::WeakPtr<UtilityProcessHostImpl> host,
409 int error_code) {
407 if (!host) 410 if (!host)
408 return; 411 return;
409 412
410 host->OnProcessLaunchFailed(); 413 host->OnProcessLaunchFailed(error_code);
411 delete host.get(); 414 delete host.get();
412 } 415 }
413 416
414 } // namespace content 417 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/utility_process_host_impl.h ('k') | content/common/sandbox_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698