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

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: Revive StopChildProcess and KillProcess 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 base::ProcessHandle RenderProcessHostImpl::GetHandle() const { 1321 base::ProcessHandle RenderProcessHostImpl::GetHandle() const {
1322 if (run_renderer_in_process()) 1322 if (run_renderer_in_process())
1323 return base::GetCurrentProcessHandle(); 1323 return base::GetCurrentProcessHandle();
1324 1324
1325 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting()) 1325 if (!child_process_launcher_.get() || child_process_launcher_->IsStarting())
1326 return base::kNullProcessHandle; 1326 return base::kNullProcessHandle;
1327 1327
1328 return child_process_launcher_->GetProcess().Handle(); 1328 return child_process_launcher_->GetProcess().Handle();
1329 } 1329 }
1330 1330
1331 bool RenderProcessHostImpl::Shutdown(int exit_code, bool wait) {
1332 if (run_renderer_in_process())
1333 return false; // Single process mode never shuts down the renderer.
1334
1335 #if defined(OS_ANDROID)
1336 // Android requires a different approach for killing.
1337 StopChildProcess(GetHandle());
1338 return true;
1339 #else
1340 return base::KillProcess(GetHandle(), exit_code, wait);
1341 #endif
1342 }
1343
1331 bool RenderProcessHostImpl::FastShutdownIfPossible() { 1344 bool RenderProcessHostImpl::FastShutdownIfPossible() {
1332 if (run_renderer_in_process()) 1345 if (run_renderer_in_process())
1333 return false; // Single process mode never shutdown the renderer. 1346 return false; // Single process mode never shuts down the renderer.
1334 1347
1335 if (!GetContentClient()->browser()->IsFastShutdownPossible()) 1348 if (!GetContentClient()->browser()->IsFastShutdownPossible())
1336 return false; 1349 return false;
1337 1350
1338 if (!child_process_launcher_.get() || 1351 if (!child_process_launcher_.get() ||
1339 child_process_launcher_->IsStarting() || 1352 child_process_launcher_->IsStarting() ||
1340 !GetHandle()) 1353 !GetHandle())
1341 return false; // Render process hasn't started or is probably crashed. 1354 return false; // Render process hasn't started or is probably crashed.
1342 1355
1343 // Test if there's an unload listener. 1356 // Test if there's an unload listener.
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 2292
2280 void RenderProcessHostImpl::DecrementWorkerRefCount() { 2293 void RenderProcessHostImpl::DecrementWorkerRefCount() {
2281 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2294 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2282 DCHECK_GT(worker_ref_count_, 0); 2295 DCHECK_GT(worker_ref_count_, 0);
2283 --worker_ref_count_; 2296 --worker_ref_count_;
2284 if (worker_ref_count_ == 0) 2297 if (worker_ref_count_ == 0)
2285 Cleanup(); 2298 Cleanup();
2286 } 2299 }
2287 2300
2288 } // namespace content 2301 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698