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

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 740813004: Use StopChildProcess instead of base::KillProcess to kill a renderer process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments Created 6 years 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 // Represents the browser side of the browser <--> renderer communication 5 // Represents the browser side of the browser <--> renderer communication
6 // channel. There will be one RenderProcessHost per renderer process. 6 // channel. There will be one RenderProcessHost per renderer process.
7 7
8 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 #include "storage/browser/fileapi/sandbox_file_system_backend.h" 145 #include "storage/browser/fileapi/sandbox_file_system_backend.h"
146 #include "third_party/skia/include/core/SkBitmap.h" 146 #include "third_party/skia/include/core/SkBitmap.h"
147 #include "ui/base/ui_base_switches.h" 147 #include "ui/base/ui_base_switches.h"
148 #include "ui/events/event_switches.h" 148 #include "ui/events/event_switches.h"
149 #include "ui/gfx/switches.h" 149 #include "ui/gfx/switches.h"
150 #include "ui/gl/gl_switches.h" 150 #include "ui/gl/gl_switches.h"
151 #include "ui/gl/gpu_switching_manager.h" 151 #include "ui/gl/gpu_switching_manager.h"
152 #include "ui/native_theme/native_theme_switches.h" 152 #include "ui/native_theme/native_theme_switches.h"
153 153
154 #if defined(OS_ANDROID) 154 #if defined(OS_ANDROID)
155 #include "content/browser/android/child_process_launcher_android.h"
155 #include "content/browser/media/android/browser_demuxer_android.h" 156 #include "content/browser/media/android/browser_demuxer_android.h"
156 #include "content/browser/screen_orientation/screen_orientation_message_filter_a ndroid.h" 157 #include "content/browser/screen_orientation/screen_orientation_message_filter_a ndroid.h"
157 #endif 158 #endif
158 159
159 #if defined(OS_WIN) 160 #if defined(OS_WIN)
160 #include "base/win/scoped_com_initializer.h" 161 #include "base/win/scoped_com_initializer.h"
161 #include "content/common/font_cache_dispatcher_win.h" 162 #include "content/common/font_cache_dispatcher_win.h"
162 #include "content/common/sandbox_win.h" 163 #include "content/common/sandbox_win.h"
163 #include "ui/gfx/win/dpi.h" 164 #include "ui/gfx/win/dpi.h"
164 #endif 165 #endif
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 if (command_line->HasSwitch(switches::kDisableKillAfterBadIPC)) 965 if (command_line->HasSwitch(switches::kDisableKillAfterBadIPC))
965 return; 966 return;
966 967
967 if (run_renderer_in_process()) { 968 if (run_renderer_in_process()) {
968 // In single process mode it is better if we don't suicide but just 969 // In single process mode it is better if we don't suicide but just
969 // crash. 970 // crash.
970 CHECK(false); 971 CHECK(false);
971 } 972 }
972 // We kill the renderer but don't include a NOTREACHED, because we want the 973 // We kill the renderer but don't include a NOTREACHED, because we want the
973 // browser to try to survive when it gets illegal messages from the renderer. 974 // browser to try to survive when it gets illegal messages from the renderer.
974 base::KillProcess(GetHandle(), RESULT_CODE_KILLED_BAD_MESSAGE, 975 Shutdown(RESULT_CODE_KILLED_BAD_MESSAGE, false);
975 false);
976 } 976 }
977 977
978 void RenderProcessHostImpl::WidgetRestored() { 978 void RenderProcessHostImpl::WidgetRestored() {
979 // Verify we were properly backgrounded. 979 // Verify we were properly backgrounded.
980 DCHECK_EQ(backgrounded_, (visible_widgets_ == 0)); 980 DCHECK_EQ(backgrounded_, (visible_widgets_ == 0));
981 visible_widgets_++; 981 visible_widgets_++;
982 SetBackgrounded(false); 982 SetBackgrounded(false);
983 } 983 }
984 984
985 void RenderProcessHostImpl::WidgetHidden() { 985 void RenderProcessHostImpl::WidgetHidden() {
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 base::ProcessHandle RenderProcessHostImpl::GetHandle() const { 1322 base::ProcessHandle RenderProcessHostImpl::GetHandle() const {
1323 if (run_renderer_in_process()) 1323 if (run_renderer_in_process())
1324 return base::GetCurrentProcessHandle(); 1324 return base::GetCurrentProcessHandle();
1325 1325
1326 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) 1326 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting())
1327 return base::kNullProcessHandle; 1327 return base::kNullProcessHandle;
1328 1328
1329 return child_process_launcher_->GetProcess().Handle(); 1329 return child_process_launcher_->GetProcess().Handle();
1330 } 1330 }
1331 1331
1332 bool RenderProcessHostImpl::Shutdown(int exit_code, bool wait) {
1333 if (run_renderer_in_process())
1334 return false; // Single process mode never shuts down the renderer.
1335
1336 #if defined(OS_ANDROID)
1337 // Android requires a different approach for killing.
1338 StopChildProcess(GetHandle());
1339 return true;
1340 #else
1341 return base::KillProcess(GetHandle(), exit_code, wait);
1342 #endif
1343 }
1344
1332 bool RenderProcessHostImpl::FastShutdownIfPossible() { 1345 bool RenderProcessHostImpl::FastShutdownIfPossible() {
1333 if (run_renderer_in_process()) 1346 if (run_renderer_in_process())
1334 return false; // Single process mode never shutdown the renderer. 1347 return false; // Single process mode never shuts down the renderer.
1335 1348
1336 if (!GetContentClient()->browser()->IsFastShutdownPossible()) 1349 if (!GetContentClient()->browser()->IsFastShutdownPossible())
1337 return false; 1350 return false;
1338 1351
1339 if (!child_process_launcher_.get() || 1352 if (!child_process_launcher_.get() ||
1340 child_process_launcher_->IsStarting() || 1353 child_process_launcher_->IsStarting() ||
1341 !GetHandle()) 1354 !GetHandle())
1342 return false; // Render process hasn't started or is probably crashed. 1355 return false; // Render process hasn't started or is probably crashed.
1343 1356
1344 // Test if there's an unload listener. 1357 // Test if there's an unload listener.
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 2293
2281 void RenderProcessHostImpl::DecrementWorkerRefCount() { 2294 void RenderProcessHostImpl::DecrementWorkerRefCount() {
2282 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2295 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2283 DCHECK_GT(worker_ref_count_, 0); 2296 DCHECK_GT(worker_ref_count_, 0);
2284 --worker_ref_count_; 2297 --worker_ref_count_;
2285 if (worker_ref_count_ == 0) 2298 if (worker_ref_count_ == 0)
2286 Cleanup(); 2299 Cleanup();
2287 } 2300 }
2288 2301
2289 } // namespace content 2302 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/browser/renderer_host/render_view_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698