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

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

Issue 9769011: Histogram times surrounding render crashes (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
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 #if defined(OS_WIN) 10 #if defined(OS_WIN)
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 776
777 // Test if there's an unload listener. 777 // Test if there's an unload listener.
778 // NOTE: It's possible that an onunload listener may be installed 778 // NOTE: It's possible that an onunload listener may be installed
779 // while we're shutting down, so there's a small race here. Given that 779 // while we're shutting down, so there's a small race here. Given that
780 // the window is small, it's unlikely that the web page has much 780 // the window is small, it's unlikely that the web page has much
781 // state that will be lost by not calling its unload handlers properly. 781 // state that will be lost by not calling its unload handlers properly.
782 if (!SuddenTerminationAllowed()) 782 if (!SuddenTerminationAllowed())
783 return false; 783 return false;
784 784
785 // Store the handle before it gets changed. 785 // Store the handle before it gets changed.
786 base::ProcessHandle handle = GetHandle(); 786 RendererClosedDetails details(GetHandle());
787 ProcessDied(handle, base::TERMINATION_STATUS_NORMAL_TERMINATION, 0, false); 787 DCHECK_EQ(details.status, base::TERMINATION_STATUS_NORMAL_TERMINATION);
788 DCHECK_EQ(details.exit_code, 0);
789 DCHECK_EQ(details.was_alive, false);
790 ProcessDied(&details);
788 fast_shutdown_started_ = true; 791 fast_shutdown_started_ = true;
789 return true; 792 return true;
790 } 793 }
791 794
792 void RenderProcessHostImpl::DumpHandles() { 795 void RenderProcessHostImpl::DumpHandles() {
793 #if defined(OS_WIN) 796 #if defined(OS_WIN)
794 Send(new ChildProcessMsg_DumpHandles()); 797 Send(new ChildProcessMsg_DumpHandles());
795 return; 798 return;
796 #endif 799 #endif
797 800
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 tracked_objects::ThreadData::Status status = 964 tracked_objects::ThreadData::Status status =
962 tracked_objects::ThreadData::status(); 965 tracked_objects::ThreadData::status();
963 Send(new ChildProcessMsg_SetProfilerStatus(status)); 966 Send(new ChildProcessMsg_SetProfilerStatus(status));
964 } 967 }
965 968
966 void RenderProcessHostImpl::OnChannelError() { 969 void RenderProcessHostImpl::OnChannelError() {
967 if (!channel_.get()) 970 if (!channel_.get())
968 return; 971 return;
969 972
970 // Store the handle before it gets changed. 973 // Store the handle before it gets changed.
971 base::ProcessHandle handle = GetHandle(); 974 RendererClosedDetails details(GetHandle());
972
973 // child_process_launcher_ can be NULL in single process mode or if fast 975 // child_process_launcher_ can be NULL in single process mode or if fast
974 // termination happened. 976 // termination happened.
975 int exit_code = 0; 977 details.status = child_process_launcher_.get() ?
976 base::TerminationStatus status = 978 child_process_launcher_->GetChildTerminationStatus(&details.exit_code) :
977 child_process_launcher_.get() ?
978 child_process_launcher_->GetChildTerminationStatus(&exit_code) :
979 base::TERMINATION_STATUS_NORMAL_TERMINATION; 979 base::TERMINATION_STATUS_NORMAL_TERMINATION;
980 980
981 #if defined(OS_WIN) 981 #if defined(OS_WIN)
982 if (!run_renderer_in_process()) { 982 if (!run_renderer_in_process()) {
983 if (status == base::TERMINATION_STATUS_STILL_RUNNING) { 983 if (details.status == base::TERMINATION_STATUS_STILL_RUNNING) {
984 HANDLE process = child_process_launcher_->GetHandle(); 984 HANDLE process = child_process_launcher_->GetHandle();
985 child_process_watcher_.StartWatching( 985 child_process_watcher_.StartWatching(
986 new base::WaitableEvent(process), this); 986 new base::WaitableEvent(process), this);
987 return; 987 return;
988 } 988 }
989 } 989 }
990 #endif 990 #endif
991 ProcessDied(handle, status, exit_code, false); 991 details.was_alive = false;
992 } 992 ProcessDied(&details);
993 }
993 994
994 // Called when the renderer process handle has been signaled. 995 // Called when the renderer process handle has been signaled.
995 void RenderProcessHostImpl::OnWaitableEventSignaled( 996 void RenderProcessHostImpl::OnWaitableEventSignaled(
996 base::WaitableEvent* waitable_event) { 997 base::WaitableEvent* waitable_event) {
997 #if defined (OS_WIN) 998 #if defined (OS_WIN)
998 base::ProcessHandle handle = GetHandle(); 999 RendererClosedDetails details(GetHandle());
999 int exit_code = 0; 1000 details.status = base::GetTerminationStatus(waitable_event->Release(),
1000 base::TerminationStatus status = 1001 &details.exit_code);
1001 base::GetTerminationStatus(waitable_event->Release(), &exit_code);
1002 delete waitable_event; 1002 delete waitable_event;
1003 ProcessDied(handle, status, exit_code, true); 1003 details.was_alive = true;
1004 ProcessDied(&details);
1004 #endif 1005 #endif
1005 } 1006 }
1006 1007
1007 content::BrowserContext* RenderProcessHostImpl::GetBrowserContext() const { 1008 content::BrowserContext* RenderProcessHostImpl::GetBrowserContext() const {
1008 return browser_context_; 1009 return browser_context_;
1009 } 1010 }
1010 1011
1011 int RenderProcessHostImpl::GetID() const { 1012 int RenderProcessHostImpl::GetID() const {
1012 return id_; 1013 return id_;
1013 } 1014 }
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 // Now pick a random suitable renderer, if we have any. 1228 // Now pick a random suitable renderer, if we have any.
1228 if (!suitable_renderers.empty()) { 1229 if (!suitable_renderers.empty()) {
1229 int suitable_count = static_cast<int>(suitable_renderers.size()); 1230 int suitable_count = static_cast<int>(suitable_renderers.size());
1230 int random_index = base::RandInt(0, suitable_count - 1); 1231 int random_index = base::RandInt(0, suitable_count - 1);
1231 return suitable_renderers[random_index]; 1232 return suitable_renderers[random_index];
1232 } 1233 }
1233 1234
1234 return NULL; 1235 return NULL;
1235 } 1236 }
1236 1237
1237 void RenderProcessHostImpl::ProcessDied(base::ProcessHandle handle, 1238 void RenderProcessHostImpl::ProcessDied(RendererClosedDetails* details) {
1238 base::TerminationStatus status,
1239 int exit_code,
1240 bool was_alive) {
1241 // Our child process has died. If we didn't expect it, it's a crash. 1239 // Our child process has died. If we didn't expect it, it's a crash.
1242 // In any case, we need to let everyone know it's gone. 1240 // In any case, we need to let everyone know it's gone.
1243 // The OnChannelError notification can fire multiple times due to nested sync 1241 // The OnChannelError notification can fire multiple times due to nested sync
1244 // calls to a renderer. If we don't have a valid channel here it means we 1242 // calls to a renderer. If we don't have a valid channel here it means we
1245 // already handled the error. 1243 // already handled the error.
1246 1244
1247 RendererClosedDetails details(handle, status, exit_code, was_alive);
1248 content::NotificationService::current()->Notify( 1245 content::NotificationService::current()->Notify(
1249 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 1246 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
1250 content::Source<RenderProcessHost>(this), 1247 content::Source<RenderProcessHost>(this),
1251 content::Details<RendererClosedDetails>(&details)); 1248 content::Details<RendererClosedDetails>(details));
1252 1249
1253 child_process_launcher_.reset(); 1250 child_process_launcher_.reset();
1254 channel_.reset(); 1251 channel_.reset();
1255 gpu_message_filter_ = NULL; 1252 gpu_message_filter_ = NULL;
1256 1253
1257 IDMap<RenderWidgetHost>::iterator iter(&render_widget_hosts_); 1254 IDMap<RenderWidgetHost>::iterator iter(&render_widget_hosts_);
1258 while (!iter.IsAtEnd()) { 1255 while (!iter.IsAtEnd()) {
1259 RenderWidgetHostImpl::From(iter.GetCurrentValue())->OnMessageReceived( 1256 RenderWidgetHostImpl::From(iter.GetCurrentValue())->OnMessageReceived(
1260 ViewHostMsg_RenderViewGone(iter.GetCurrentKey(), 1257 ViewHostMsg_RenderViewGone(iter.GetCurrentKey(),
1261 static_cast<int>(status), 1258 static_cast<int>(details->status),
1262 exit_code)); 1259 details->exit_code));
1263 iter.Advance(); 1260 iter.Advance();
1264 } 1261 }
1265 1262
1266 ClearTransportDIBCache(); 1263 ClearTransportDIBCache();
1267 1264
1268 // this object is not deleted at this point and may be reused later. 1265 // this object is not deleted at this point and may be reused later.
1269 // TODO(darin): clean this up 1266 // TODO(darin): clean this up
1270 } 1267 }
1271 1268
1272 void RenderProcessHostImpl::OnShutdownRequest() { 1269 void RenderProcessHostImpl::OnShutdownRequest() {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) { 1363 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) {
1367 // Only honor the request if appropriate persmissions are granted. 1364 // Only honor the request if appropriate persmissions are granted.
1368 if (ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(GetID(), 1365 if (ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(GetID(),
1369 path)) 1366 path))
1370 content::GetContentClient()->browser()->OpenItem(path); 1367 content::GetContentClient()->browser()->OpenItem(path);
1371 } 1368 }
1372 1369
1373 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { 1370 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) {
1374 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size); 1371 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size);
1375 } 1372 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/public/browser/render_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698