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

Side by Side Diff: chrome/browser/renderer_host/browser_render_process_host.cc

Issue 5172009: This adds some plumbing for propagating the reason for a renderer's death (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final review changes Created 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/browser_render_process_host.h" 8 #include "chrome/browser/renderer_host/browser_render_process_host.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 975
976 void BrowserRenderProcessHost::OnChannelError() { 976 void BrowserRenderProcessHost::OnChannelError() {
977 // Our child process has died. If we didn't expect it, it's a crash. 977 // Our child process has died. If we didn't expect it, it's a crash.
978 // In any case, we need to let everyone know it's gone. 978 // In any case, we need to let everyone know it's gone.
979 // The OnChannelError notification can fire multiple times due to nested sync 979 // The OnChannelError notification can fire multiple times due to nested sync
980 // calls to a renderer. If we don't have a valid channel here it means we 980 // calls to a renderer. If we don't have a valid channel here it means we
981 // already handled the error. 981 // already handled the error.
982 if (!channel_.get()) 982 if (!channel_.get())
983 return; 983 return;
984 984
985 // NULL in single process mode or if fast termination happened. 985 // child_process_ can be NULL in single process mode or if fast
986 bool did_crash = 986 // termination happened.
987 child_process_.get() ? child_process_->DidProcessCrash() : false; 987 int exit_code = 0;
988 base::TerminationStatus status =
989 child_process_.get() ?
990 child_process_->GetChildTerminationStatus(&exit_code) :
991 base::TERMINATION_STATUS_NORMAL_TERMINATION;
988 992
989 if (did_crash) { 993 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED ||
994 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) {
990 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", 995 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes",
991 extension_process_ ? 2 : 1); 996 extension_process_ ? 2 : 1);
992 } 997 }
993 998
994 RendererClosedDetails details(did_crash, extension_process_); 999 if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) {
1000 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills",
1001 extension_process_ ? 2 : 1);
1002 }
1003
1004 RendererClosedDetails details(status, exit_code, extension_process_);
995 NotificationService::current()->Notify( 1005 NotificationService::current()->Notify(
996 NotificationType::RENDERER_PROCESS_CLOSED, 1006 NotificationType::RENDERER_PROCESS_CLOSED,
997 Source<RenderProcessHost>(this), 1007 Source<RenderProcessHost>(this),
998 Details<RendererClosedDetails>(&details)); 1008 Details<RendererClosedDetails>(&details));
999 1009
1000 WebCacheManager::GetInstance()->Remove(id()); 1010 WebCacheManager::GetInstance()->Remove(id());
1001 child_process_.reset(); 1011 child_process_.reset();
1002 channel_.reset(); 1012 channel_.reset();
1003 1013
1004 IDMap<IPC::Channel::Listener>::iterator iter(&listeners_); 1014 IDMap<IPC::Channel::Listener>::iterator iter(&listeners_);
1005 while (!iter.IsAtEnd()) { 1015 while (!iter.IsAtEnd()) {
1006 iter.GetCurrentValue()->OnMessageReceived( 1016 iter.GetCurrentValue()->OnMessageReceived(
1007 ViewHostMsg_RenderViewGone(iter.GetCurrentKey())); 1017 ViewHostMsg_RenderViewGone(iter.GetCurrentKey(),
1018 static_cast<int>(status),
1019 exit_code));
1008 iter.Advance(); 1020 iter.Advance();
1009 } 1021 }
1010 1022
1011 ClearTransportDIBCache(); 1023 ClearTransportDIBCache();
1012 1024
1013 // this object is not deleted at this point and may be reused later. 1025 // this object is not deleted at this point and may be reused later.
1014 // TODO(darin): clean this up 1026 // TODO(darin): clean this up
1015 } 1027 }
1016 1028
1017 void BrowserRenderProcessHost::OnUpdatedCacheStats( 1029 void BrowserRenderProcessHost::OnUpdatedCacheStats(
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 IPC::PlatformFileForTransit file; 1235 IPC::PlatformFileForTransit file;
1224 #if defined(OS_POSIX) 1236 #if defined(OS_POSIX)
1225 file = base::FileDescriptor(model_file, false); 1237 file = base::FileDescriptor(model_file, false);
1226 #elif defined(OS_WIN) 1238 #elif defined(OS_WIN)
1227 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, 1239 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0,
1228 false, DUPLICATE_SAME_ACCESS); 1240 false, DUPLICATE_SAME_ACCESS);
1229 #endif 1241 #endif
1230 Send(new ViewMsg_SetPhishingModel(file)); 1242 Send(new ViewMsg_SetPhishingModel(file));
1231 } 1243 }
1232 } 1244 }
OLDNEW
« no previous file with comments | « chrome/browser/profile_import_process_host.cc ('k') | chrome/browser/renderer_host/render_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698