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

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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 775
776 // Test if there's an unload listener. 776 // Test if there's an unload listener.
777 // NOTE: It's possible that an onunload listener may be installed 777 // NOTE: It's possible that an onunload listener may be installed
778 // while we're shutting down, so there's a small race here. Given that 778 // while we're shutting down, so there's a small race here. Given that
779 // the window is small, it's unlikely that the web page has much 779 // the window is small, it's unlikely that the web page has much
780 // state that will be lost by not calling its unload handlers properly. 780 // state that will be lost by not calling its unload handlers properly.
781 if (!SuddenTerminationAllowed()) 781 if (!SuddenTerminationAllowed())
782 return false; 782 return false;
783 783
784 // Store the handle before it gets changed. 784 // Store the handle before it gets changed.
785 base::ProcessHandle handle = GetHandle(); 785 base::ProcessHandle handle = GetHandle();
rvargas (doing something else) 2012/03/22 22:16:30 nit: most of the time we don't keep an extra local
jar (doing other things) 2012/03/22 22:42:58 Done.
786 ProcessDied(handle, base::TERMINATION_STATUS_NORMAL_TERMINATION, 0, false); 786 RendererClosedDetails details(handle);
787 details.status = base::TERMINATION_STATUS_NORMAL_TERMINATION;
rvargas (doing something else) 2012/03/22 22:16:30 these are the default values
jar (doing other things) 2012/03/22 22:42:58 Changed to a DCHECK to help with readability (not
788 details.exit_code = 0;
789 details.was_alive = false;
790 ProcessDied(&details);
787 fast_shutdown_started_ = true; 791 fast_shutdown_started_ = true;
788 return true; 792 return true;
789 } 793 }
790 794
791 void RenderProcessHostImpl::DumpHandles() { 795 void RenderProcessHostImpl::DumpHandles() {
792 #if defined(OS_WIN) 796 #if defined(OS_WIN)
793 Send(new ChildProcessMsg_DumpHandles()); 797 Send(new ChildProcessMsg_DumpHandles());
794 return; 798 return;
795 #endif 799 #endif
796 800
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 tracked_objects::ThreadData::Status status = 944 tracked_objects::ThreadData::Status status =
941 tracked_objects::ThreadData::status(); 945 tracked_objects::ThreadData::status();
942 Send(new ChildProcessMsg_SetProfilerStatus(status)); 946 Send(new ChildProcessMsg_SetProfilerStatus(status));
943 } 947 }
944 948
945 void RenderProcessHostImpl::OnChannelError() { 949 void RenderProcessHostImpl::OnChannelError() {
946 if (!channel_.get()) 950 if (!channel_.get())
947 return; 951 return;
948 952
949 // Store the handle before it gets changed. 953 // Store the handle before it gets changed.
950 base::ProcessHandle handle = GetHandle(); 954 base::ProcessHandle handle = GetHandle();
rvargas (doing something else) 2012/03/22 22:16:30 I'd also remove this one. In fact, can we add a TO
jar (doing other things) 2012/03/22 22:42:58 Done.
951 955 RendererClosedDetails details(handle);
952 // child_process_launcher_ can be NULL in single process mode or if fast 956 // child_process_launcher_ can be NULL in single process mode or if fast
953 // termination happened. 957 // termination happened.
954 int exit_code = 0; 958 details.status = child_process_launcher_.get() ?
955 base::TerminationStatus status = 959 child_process_launcher_->GetChildTerminationStatus(&details.exit_code) :
956 child_process_launcher_.get() ?
957 child_process_launcher_->GetChildTerminationStatus(&exit_code) :
958 base::TERMINATION_STATUS_NORMAL_TERMINATION; 960 base::TERMINATION_STATUS_NORMAL_TERMINATION;
959 961
960 #if defined(OS_WIN) 962 #if defined(OS_WIN)
961 if (!run_renderer_in_process()) { 963 if (!run_renderer_in_process()) {
962 if (status == base::TERMINATION_STATUS_STILL_RUNNING) { 964 if (details.status == base::TERMINATION_STATUS_STILL_RUNNING) {
963 HANDLE process = child_process_launcher_->GetHandle(); 965 HANDLE process = child_process_launcher_->GetHandle();
964 child_process_watcher_.StartWatching( 966 child_process_watcher_.StartWatching(
965 new base::WaitableEvent(process), this); 967 new base::WaitableEvent(process), this);
966 return; 968 return;
967 } 969 }
968 } 970 }
969 #endif 971 #endif
970 ProcessDied(handle, status, exit_code, false); 972 details.was_alive = false;
971 } 973 ProcessDied(&details);
974 }
972 975
973 // Called when the renderer process handle has been signaled. 976 // Called when the renderer process handle has been signaled.
974 void RenderProcessHostImpl::OnWaitableEventSignaled( 977 void RenderProcessHostImpl::OnWaitableEventSignaled(
975 base::WaitableEvent* waitable_event) { 978 base::WaitableEvent* waitable_event) {
976 #if defined (OS_WIN) 979 #if defined (OS_WIN)
977 base::ProcessHandle handle = GetHandle(); 980 base::ProcessHandle handle = GetHandle();
978 int exit_code = 0; 981 RendererClosedDetails details(handle);
979 base::TerminationStatus status = 982 details.status = base::GetTerminationStatus(waitable_event->Release(),
980 base::GetTerminationStatus(waitable_event->Release(), &exit_code); 983 &details.exit_code);
981 delete waitable_event; 984 delete waitable_event;
982 ProcessDied(handle, status, exit_code, true); 985 details.was_alive = true;
986 ProcessDied(&details);
983 #endif 987 #endif
984 } 988 }
985 989
986 content::BrowserContext* RenderProcessHostImpl::GetBrowserContext() const { 990 content::BrowserContext* RenderProcessHostImpl::GetBrowserContext() const {
987 return browser_context_; 991 return browser_context_;
988 } 992 }
989 993
990 int RenderProcessHostImpl::GetID() const { 994 int RenderProcessHostImpl::GetID() const {
991 return id_; 995 return id_;
992 } 996 }
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 // Now pick a random suitable renderer, if we have any. 1210 // Now pick a random suitable renderer, if we have any.
1207 if (!suitable_renderers.empty()) { 1211 if (!suitable_renderers.empty()) {
1208 int suitable_count = static_cast<int>(suitable_renderers.size()); 1212 int suitable_count = static_cast<int>(suitable_renderers.size());
1209 int random_index = base::RandInt(0, suitable_count - 1); 1213 int random_index = base::RandInt(0, suitable_count - 1);
1210 return suitable_renderers[random_index]; 1214 return suitable_renderers[random_index];
1211 } 1215 }
1212 1216
1213 return NULL; 1217 return NULL;
1214 } 1218 }
1215 1219
1216 void RenderProcessHostImpl::ProcessDied(base::ProcessHandle handle, 1220 void RenderProcessHostImpl::ProcessDied(RendererClosedDetails* details) {
1217 base::TerminationStatus status,
1218 int exit_code,
1219 bool was_alive) {
1220 // Our child process has died. If we didn't expect it, it's a crash. 1221 // Our child process has died. If we didn't expect it, it's a crash.
1221 // In any case, we need to let everyone know it's gone. 1222 // In any case, we need to let everyone know it's gone.
1222 // The OnChannelError notification can fire multiple times due to nested sync 1223 // The OnChannelError notification can fire multiple times due to nested sync
1223 // calls to a renderer. If we don't have a valid channel here it means we 1224 // calls to a renderer. If we don't have a valid channel here it means we
1224 // already handled the error. 1225 // already handled the error.
1225 1226
1226 RendererClosedDetails details(handle, status, exit_code, was_alive);
1227 content::NotificationService::current()->Notify( 1227 content::NotificationService::current()->Notify(
1228 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 1228 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
1229 content::Source<RenderProcessHost>(this), 1229 content::Source<RenderProcessHost>(this),
1230 content::Details<RendererClosedDetails>(&details)); 1230 content::Details<RendererClosedDetails>(details));
1231 1231
1232 child_process_launcher_.reset(); 1232 child_process_launcher_.reset();
1233 channel_.reset(); 1233 channel_.reset();
1234 gpu_message_filter_ = NULL; 1234 gpu_message_filter_ = NULL;
1235 1235
1236 IDMap<RenderWidgetHost>::iterator iter(&render_widget_hosts_); 1236 IDMap<RenderWidgetHost>::iterator iter(&render_widget_hosts_);
1237 while (!iter.IsAtEnd()) { 1237 while (!iter.IsAtEnd()) {
1238 RenderWidgetHostImpl::From(iter.GetCurrentValue())->OnMessageReceived( 1238 RenderWidgetHostImpl::From(iter.GetCurrentValue())->OnMessageReceived(
1239 ViewHostMsg_RenderViewGone(iter.GetCurrentKey(), 1239 ViewHostMsg_RenderViewGone(iter.GetCurrentKey(),
1240 static_cast<int>(status), 1240 static_cast<int>(details->status),
1241 exit_code)); 1241 details->exit_code));
1242 iter.Advance(); 1242 iter.Advance();
1243 } 1243 }
1244 1244
1245 ClearTransportDIBCache(); 1245 ClearTransportDIBCache();
1246 1246
1247 // this object is not deleted at this point and may be reused later. 1247 // this object is not deleted at this point and may be reused later.
1248 // TODO(darin): clean this up 1248 // TODO(darin): clean this up
1249 } 1249 }
1250 1250
1251 void RenderProcessHostImpl::OnShutdownRequest() { 1251 void RenderProcessHostImpl::OnShutdownRequest() {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) { 1336 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) {
1337 // Only honor the request if appropriate persmissions are granted. 1337 // Only honor the request if appropriate persmissions are granted.
1338 if (ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(GetID(), 1338 if (ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(GetID(),
1339 path)) 1339 path))
1340 content::GetContentClient()->browser()->OpenItem(path); 1340 content::GetContentClient()->browser()->OpenItem(path);
1341 } 1341 }
1342 1342
1343 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { 1343 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) {
1344 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size); 1344 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size);
1345 } 1345 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698