OLD | NEW |
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 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 | 958 |
959 void BrowserRenderProcessHost::OnChannelError() { | 959 void BrowserRenderProcessHost::OnChannelError() { |
960 // Our child process has died. If we didn't expect it, it's a crash. | 960 // Our child process has died. If we didn't expect it, it's a crash. |
961 // In any case, we need to let everyone know it's gone. | 961 // In any case, we need to let everyone know it's gone. |
962 // The OnChannelError notification can fire multiple times due to nested sync | 962 // The OnChannelError notification can fire multiple times due to nested sync |
963 // calls to a renderer. If we don't have a valid channel here it means we | 963 // calls to a renderer. If we don't have a valid channel here it means we |
964 // already handled the error. | 964 // already handled the error. |
965 if (!channel_.get()) | 965 if (!channel_.get()) |
966 return; | 966 return; |
967 | 967 |
968 // NULL in single process mode or if fast termination happened. | 968 // child_process_ can be NULL in single process mode or if fast |
969 bool did_crash = | 969 // termination happened. |
970 child_process_.get() ? child_process_->DidProcessCrash() : false; | 970 int exit_code = 0; |
| 971 base::TerminationStatus status = |
| 972 child_process_.get() ? |
| 973 child_process_->GetChildTerminationStatus(&exit_code) : |
| 974 base::TERMINATION_STATUS_NORMAL_TERMINATION; |
971 | 975 |
972 if (did_crash) { | 976 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || |
| 977 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { |
973 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", | 978 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", |
974 extension_process_ ? 2 : 1); | 979 extension_process_ ? 2 : 1); |
975 } | 980 } |
976 | 981 |
977 RendererClosedDetails details(did_crash, extension_process_); | 982 if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { |
| 983 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", |
| 984 extension_process_ ? 2 : 1); |
| 985 } |
| 986 |
| 987 RendererClosedDetails details(status, exit_code, extension_process_); |
978 NotificationService::current()->Notify( | 988 NotificationService::current()->Notify( |
979 NotificationType::RENDERER_PROCESS_CLOSED, | 989 NotificationType::RENDERER_PROCESS_CLOSED, |
980 Source<RenderProcessHost>(this), | 990 Source<RenderProcessHost>(this), |
981 Details<RendererClosedDetails>(&details)); | 991 Details<RendererClosedDetails>(&details)); |
982 | 992 |
983 WebCacheManager::GetInstance()->Remove(id()); | 993 WebCacheManager::GetInstance()->Remove(id()); |
984 child_process_.reset(); | 994 child_process_.reset(); |
985 channel_.reset(); | 995 channel_.reset(); |
986 | 996 |
987 IDMap<IPC::Channel::Listener>::iterator iter(&listeners_); | 997 IDMap<IPC::Channel::Listener>::iterator iter(&listeners_); |
988 while (!iter.IsAtEnd()) { | 998 while (!iter.IsAtEnd()) { |
989 iter.GetCurrentValue()->OnMessageReceived( | 999 iter.GetCurrentValue()->OnMessageReceived( |
990 ViewHostMsg_RenderViewGone(iter.GetCurrentKey())); | 1000 ViewHostMsg_RenderViewGone(iter.GetCurrentKey(), |
| 1001 static_cast<int>(status), |
| 1002 exit_code)); |
991 iter.Advance(); | 1003 iter.Advance(); |
992 } | 1004 } |
993 | 1005 |
994 ClearTransportDIBCache(); | 1006 ClearTransportDIBCache(); |
995 | 1007 |
996 // this object is not deleted at this point and may be reused later. | 1008 // this object is not deleted at this point and may be reused later. |
997 // TODO(darin): clean this up | 1009 // TODO(darin): clean this up |
998 } | 1010 } |
999 | 1011 |
1000 void BrowserRenderProcessHost::OnUpdatedCacheStats( | 1012 void BrowserRenderProcessHost::OnUpdatedCacheStats( |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 IPC::PlatformFileForTransit file; | 1218 IPC::PlatformFileForTransit file; |
1207 #if defined(OS_POSIX) | 1219 #if defined(OS_POSIX) |
1208 file = base::FileDescriptor(model_file, false); | 1220 file = base::FileDescriptor(model_file, false); |
1209 #elif defined(OS_WIN) | 1221 #elif defined(OS_WIN) |
1210 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, | 1222 ::DuplicateHandle(::GetCurrentProcess(), model_file, GetHandle(), &file, 0, |
1211 false, DUPLICATE_SAME_ACCESS); | 1223 false, DUPLICATE_SAME_ACCESS); |
1212 #endif | 1224 #endif |
1213 Send(new ViewMsg_SetPhishingModel(file)); | 1225 Send(new ViewMsg_SetPhishingModel(file)); |
1214 } | 1226 } |
1215 } | 1227 } |
OLD | NEW |