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

Side by Side Diff: content/child/child_thread_impl.cc

Issue 999033003: Remove uses of KillProcess() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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/child/child_thread_impl.h" 5 #include "content/child/child_thread_impl.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/allocator/allocator_extension.h" 11 #include "base/allocator/allocator_extension.h"
12 #include "base/base_switches.h" 12 #include "base/base_switches.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/debug/leak_annotations.h" 15 #include "base/debug/leak_annotations.h"
16 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
19 #include "base/message_loop/timer_slack.h" 19 #include "base/message_loop/timer_slack.h"
20 #include "base/metrics/field_trial.h" 20 #include "base/metrics/field_trial.h"
21 #include "base/process/kill.h" 21 #include "base/process/process.h"
22 #include "base/process/process_handle.h" 22 #include "base/process/process_handle.h"
23 #include "base/strings/string_number_conversions.h" 23 #include "base/strings/string_number_conversions.h"
24 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
25 #include "base/synchronization/condition_variable.h" 25 #include "base/synchronization/condition_variable.h"
26 #include "base/synchronization/lock.h" 26 #include "base/synchronization/lock.h"
27 #include "base/threading/thread_local.h" 27 #include "base/threading/thread_local.h"
28 #include "base/tracked_objects.h" 28 #include "base/tracked_objects.h"
29 #include "components/tracing/child_trace_message_filter.h" 29 #include "components/tracing/child_trace_message_filter.h"
30 #include "content/child/bluetooth/bluetooth_message_filter.h" 30 #include "content/child/bluetooth/bluetooth_message_filter.h"
31 #include "content/child/child_discardable_shared_memory_manager.h" 31 #include "content/child/child_discardable_shared_memory_manager.h"
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 // where we send out an initial feeler request to the child process host 706 // where we send out an initial feeler request to the child process host
707 // instance in the browser to verify if it's ok to shutdown the child process. 707 // instance in the browser to verify if it's ok to shutdown the child process.
708 // The browser then sends back a response if it's ok to shutdown. This avoids 708 // The browser then sends back a response if it's ok to shutdown. This avoids
709 // race conditions if the process refcount is 0 but there's an IPC message 709 // race conditions if the process refcount is 0 but there's an IPC message
710 // inflight that would addref it. 710 // inflight that would addref it.
711 Send(new ChildProcessHostMsg_ShutdownRequest); 711 Send(new ChildProcessHostMsg_ShutdownRequest);
712 } 712 }
713 713
714 void ChildThreadImpl::EnsureConnected() { 714 void ChildThreadImpl::EnsureConnected() {
715 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 715 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
716 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); 716 base::Process::Current().Terminate(0, false);
717 } 717 }
718 718
cpu_(ooo_6.6-7.5) 2015/03/17 20:36:31 ensure connected --> kills ensure dead --> connect
rvargas (doing something else) 2015/03/17 22:40:53 That sounds reasonable!. (I don't really know wha
719 void ChildThreadImpl::OnProcessBackgrounded(bool background) { 719 void ChildThreadImpl::OnProcessBackgrounded(bool background) {
720 // Set timer slack to maximum on main thread when in background. 720 // Set timer slack to maximum on main thread when in background.
721 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; 721 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE;
722 if (background) 722 if (background)
723 timer_slack = base::TIMER_SLACK_MAXIMUM; 723 timer_slack = base::TIMER_SLACK_MAXIMUM;
724 base::MessageLoop::current()->SetTimerSlack(timer_slack); 724 base::MessageLoop::current()->SetTimerSlack(timer_slack);
725 725
726 #ifdef OS_WIN 726 #ifdef OS_WIN
727 // Windows Vista+ has a fancy process backgrounding mode that can only be set 727 // Windows Vista+ has a fancy process backgrounding mode that can only be set
728 // from within the process. This used to be how chrome set its renderers into 728 // from within the process. This used to be how chrome set its renderers into
729 // background mode on Windows but was removed due to http://crbug.com/398103. 729 // background mode on Windows but was removed due to http://crbug.com/398103.
730 // As we experiment with bringing back some other form of background mode for 730 // As we experiment with bringing back some other form of background mode for
731 // hidden renderers, add a bucket to allow us to trigger this undesired method 731 // hidden renderers, add a bucket to allow us to trigger this undesired method
732 // of setting background state in order to confirm that the metrics which were 732 // of setting background state in order to confirm that the metrics which were
733 // added to prevent regressions on the aforementioned issue indeed catch such 733 // added to prevent regressions on the aforementioned issue indeed catch such
734 // regressions and are thus a reliable way to confirm that our latest proposal 734 // regressions and are thus a reliable way to confirm that our latest proposal
735 // doesn't cause such issues. TODO(gab): Remove this once the experiment is 735 // doesn't cause such issues. TODO(gab): Remove this once the experiment is
736 // over (http://crbug.com/458594). 736 // over (http://crbug.com/458594).
737 base::FieldTrial* trial = 737 base::FieldTrial* trial =
738 base::FieldTrialList::Find("BackgroundRendererProcesses"); 738 base::FieldTrialList::Find("BackgroundRendererProcesses");
739 if (trial && trial->group_name() == "AllowBackgroundModeFromRenderer") 739 if (trial && trial->group_name() == "AllowBackgroundModeFromRenderer")
740 base::Process::Current().SetProcessBackgrounded(background); 740 base::Process::Current().SetProcessBackgrounded(background);
741 #endif // OS_WIN 741 #endif // OS_WIN
742 } 742 }
743 743
744 } // namespace content 744 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698