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

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

Issue 9837026: Histogram times surrounding render crashes (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1025/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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 747
748 // Test if there's an unload listener. 748 // Test if there's an unload listener.
749 // NOTE: It's possible that an onunload listener may be installed 749 // NOTE: It's possible that an onunload listener may be installed
750 // while we're shutting down, so there's a small race here. Given that 750 // while we're shutting down, so there's a small race here. Given that
751 // the window is small, it's unlikely that the web page has much 751 // the window is small, it's unlikely that the web page has much
752 // state that will be lost by not calling its unload handlers properly. 752 // state that will be lost by not calling its unload handlers properly.
753 if (!SuddenTerminationAllowed()) 753 if (!SuddenTerminationAllowed())
754 return false; 754 return false;
755 755
756 // Store the handle before it gets changed. 756 // Store the handle before it gets changed.
757 base::ProcessHandle handle = GetHandle(); 757 RendererClosedDetails details(GetHandle());
758 ProcessDied(handle, base::TERMINATION_STATUS_NORMAL_TERMINATION, 0, false); 758 DCHECK_EQ(details.status, base::TERMINATION_STATUS_NORMAL_TERMINATION);
759 details.exit_code = 0;
760 details.was_alive = false;
761 ProcessDied(&details);
759 fast_shutdown_started_ = true; 762 fast_shutdown_started_ = true;
760 return true; 763 return true;
761 } 764 }
762 765
763 void RenderProcessHostImpl::DumpHandles() { 766 void RenderProcessHostImpl::DumpHandles() {
764 #if defined(OS_WIN) 767 #if defined(OS_WIN)
765 Send(new ChildProcessMsg_DumpHandles()); 768 Send(new ChildProcessMsg_DumpHandles());
766 return; 769 return;
767 #endif 770 #endif
768 771
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 914
912 bool enable = tracked_objects::ThreadData::tracking_status(); 915 bool enable = tracked_objects::ThreadData::tracking_status();
913 Send(new ChildProcessMsg_SetProfilerStatus(enable)); 916 Send(new ChildProcessMsg_SetProfilerStatus(enable));
914 } 917 }
915 918
916 void RenderProcessHostImpl::OnChannelError() { 919 void RenderProcessHostImpl::OnChannelError() {
917 if (!channel_.get()) 920 if (!channel_.get())
918 return; 921 return;
919 922
920 // Store the handle before it gets changed. 923 // Store the handle before it gets changed.
921 base::ProcessHandle handle = GetHandle(); 924 RendererClosedDetails details(GetHandle());
922
923 // child_process_launcher_ can be NULL in single process mode or if fast 925 // child_process_launcher_ can be NULL in single process mode or if fast
924 // termination happened. 926 // termination happened.
925 int exit_code = 0; 927 details.status = child_process_launcher_.get() ?
926 base::TerminationStatus status = 928 child_process_launcher_->GetChildTerminationStatus(&details.exit_code) :
927 child_process_launcher_.get() ?
928 child_process_launcher_->GetChildTerminationStatus(&exit_code) :
929 base::TERMINATION_STATUS_NORMAL_TERMINATION; 929 base::TERMINATION_STATUS_NORMAL_TERMINATION;
930 930
931 #if defined(OS_WIN) 931 #if defined(OS_WIN)
932 if (!run_renderer_in_process()) { 932 if (!run_renderer_in_process()) {
933 if (status == base::TERMINATION_STATUS_STILL_RUNNING) { 933 if (details.status == base::TERMINATION_STATUS_STILL_RUNNING) {
934 HANDLE process = child_process_launcher_->GetHandle(); 934 HANDLE process = child_process_launcher_->GetHandle();
935 child_process_watcher_.StartWatching( 935 child_process_watcher_.StartWatching(
936 new base::WaitableEvent(process), this); 936 new base::WaitableEvent(process), this);
937 return; 937 return;
938 } 938 }
939 } 939 }
940 #endif 940 #endif
941 ProcessDied(handle, status, exit_code, false); 941 details.was_alive = false;
942 } 942 ProcessDied(&details);
943 }
943 944
944 // Called when the renderer process handle has been signaled. 945 // Called when the renderer process handle has been signaled.
945 void RenderProcessHostImpl::OnWaitableEventSignaled( 946 void RenderProcessHostImpl::OnWaitableEventSignaled(
946 base::WaitableEvent* waitable_event) { 947 base::WaitableEvent* waitable_event) {
947 #if defined (OS_WIN) 948 #if defined (OS_WIN)
948 base::ProcessHandle handle = GetHandle(); 949 RendererClosedDetails details(GetHandle());
949 int exit_code = 0; 950 details.status = base::GetTerminationStatus(waitable_event->Release(),
950 base::TerminationStatus status = 951 &details.exit_code);
951 base::GetTerminationStatus(waitable_event->Release(), &exit_code);
952 delete waitable_event; 952 delete waitable_event;
953 ProcessDied(handle, status, exit_code, true); 953 details.was_alive = true;
954 ProcessDied(&details);
954 #endif 955 #endif
955 } 956 }
956 957
957 content::BrowserContext* RenderProcessHostImpl::GetBrowserContext() const { 958 content::BrowserContext* RenderProcessHostImpl::GetBrowserContext() const {
958 return browser_context_; 959 return browser_context_;
959 } 960 }
960 961
961 int RenderProcessHostImpl::GetID() const { 962 int RenderProcessHostImpl::GetID() const {
962 return id_; 963 return id_;
963 } 964 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 // Now pick a random suitable renderer, if we have any. 1167 // Now pick a random suitable renderer, if we have any.
1167 if (!suitable_renderers.empty()) { 1168 if (!suitable_renderers.empty()) {
1168 int suitable_count = static_cast<int>(suitable_renderers.size()); 1169 int suitable_count = static_cast<int>(suitable_renderers.size());
1169 int random_index = base::RandInt(0, suitable_count - 1); 1170 int random_index = base::RandInt(0, suitable_count - 1);
1170 return suitable_renderers[random_index]; 1171 return suitable_renderers[random_index];
1171 } 1172 }
1172 1173
1173 return NULL; 1174 return NULL;
1174 } 1175 }
1175 1176
1176 void RenderProcessHostImpl::ProcessDied(base::ProcessHandle handle, 1177 void RenderProcessHostImpl::ProcessDied(RendererClosedDetails* details) {
1177 base::TerminationStatus status,
1178 int exit_code,
1179 bool was_alive) {
1180 // Our child process has died. If we didn't expect it, it's a crash. 1178 // Our child process has died. If we didn't expect it, it's a crash.
1181 // In any case, we need to let everyone know it's gone. 1179 // In any case, we need to let everyone know it's gone.
1182 // The OnChannelError notification can fire multiple times due to nested sync 1180 // The OnChannelError notification can fire multiple times due to nested sync
1183 // calls to a renderer. If we don't have a valid channel here it means we 1181 // calls to a renderer. If we don't have a valid channel here it means we
1184 // already handled the error. 1182 // already handled the error.
1185 1183
1186 RendererClosedDetails details(handle, status, exit_code, was_alive);
1187 content::NotificationService::current()->Notify( 1184 content::NotificationService::current()->Notify(
1188 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 1185 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
1189 content::Source<RenderProcessHost>(this), 1186 content::Source<RenderProcessHost>(this),
1190 content::Details<RendererClosedDetails>(&details)); 1187 content::Details<RendererClosedDetails>(details));
1191 1188
1192 child_process_launcher_.reset(); 1189 child_process_launcher_.reset();
1193 channel_.reset(); 1190 channel_.reset();
1194 1191
1195 IDMap<IPC::Channel::Listener>::iterator iter(&listeners_); 1192 IDMap<IPC::Channel::Listener>::iterator iter(&listeners_);
1196 while (!iter.IsAtEnd()) { 1193 while (!iter.IsAtEnd()) {
1197 iter.GetCurrentValue()->OnMessageReceived( 1194 iter.GetCurrentValue()->OnMessageReceived(
1198 ViewHostMsg_RenderViewGone(iter.GetCurrentKey(), 1195 ViewHostMsg_RenderViewGone(iter.GetCurrentKey(),
1199 static_cast<int>(status), 1196 static_cast<int>(details->status),
1200 exit_code)); 1197 details->exit_code));
1201 iter.Advance(); 1198 iter.Advance();
1202 } 1199 }
1203 1200
1204 ClearTransportDIBCache(); 1201 ClearTransportDIBCache();
1205 1202
1206 // this object is not deleted at this point and may be reused later. 1203 // this object is not deleted at this point and may be reused later.
1207 // TODO(darin): clean this up 1204 // TODO(darin): clean this up
1208 } 1205 }
1209 1206
1210 void RenderProcessHostImpl::OnShutdownRequest() { 1207 void RenderProcessHostImpl::OnShutdownRequest() {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) { 1292 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) {
1296 // Only honor the request if appropriate persmissions are granted. 1293 // Only honor the request if appropriate persmissions are granted.
1297 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(GetID(), path)) 1294 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(GetID(), path))
1298 content::GetContentClient()->browser()->OpenItem(path); 1295 content::GetContentClient()->browser()->OpenItem(path);
1299 } 1296 }
1300 1297
1301 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { 1298 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) {
1302 content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> 1299 content::GetContentClient()->browser()->GetMHTMLGenerationManager()->
1303 MHTMLGenerated(job_id, data_size); 1300 MHTMLGenerated(job_id, data_size);
1304 } 1301 }
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