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

Unified Diff: content/shell/webkit_test_controller.cc

Issue 11819028: [content shell] report the PID of a crashed renderer, and always report crashes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/shell/webkit_test_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/webkit_test_controller.cc
diff --git a/content/shell/webkit_test_controller.cc b/content/shell/webkit_test_controller.cc
index 7b282765d8500fae63f59b2aee2f807b86fcc367..f12c4a42e1959ae4abf3fe6e0bf3a070ddb86b01 100644
--- a/content/shell/webkit_test_controller.cc
+++ b/content/shell/webkit_test_controller.cc
@@ -9,8 +9,13 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/message_loop.h"
+#include "base/process_util.h"
#include "base/run_loop.h"
+#include "base/string_number_conversions.h"
#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_types.h"
+#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/shell/shell.h"
@@ -130,6 +135,9 @@ WebKitTestController::WebKitTestController() {
CHECK(!instance_);
instance_ = this;
printer_.reset(new WebKitTestResultPrinter(&std::cout, &std::cerr));
+ registrar_.Add(this,
+ NOTIFICATION_RENDERER_PROCESS_CREATED,
+ NotificationService::AllSources());
ResetAfterLayoutTest();
}
@@ -161,7 +169,7 @@ bool WebKitTestController::PrepareForLayoutTest(
NULL,
MSG_ROUTING_NONE,
NULL);
- Observe(main_window_->web_contents());
+ WebContentsObserver::Observe(main_window_->web_contents());
main_window_->LoadURL(test_url);
if (test_url.spec().find("/dumpAsText/") != std::string::npos ||
test_url.spec().find("\\dumpAsText\\") != std::string::npos) {
@@ -198,11 +206,12 @@ bool WebKitTestController::ResetAfterLayoutTest() {
}
watchdog_.Cancel();
if (main_window_) {
- Observe(NULL);
+ WebContentsObserver::Observe(NULL);
main_window_ = NULL;
}
Shell::CloseAllWindows();
Send(new ShellViewMsg_ResetAll);
+ current_pid_ = base::kNullProcessId;
return true;
}
@@ -264,14 +273,19 @@ void WebKitTestController::PluginCrashed(const FilePath& plugin_path) {
void WebKitTestController::RenderViewCreated(RenderViewHost* render_view_host) {
DCHECK(CalledOnValidThread());
+ // Might be kNullProcessId, in which case we will receive a notification later
+ // when the RenderProcessHost was created.
+ current_pid_ = base::GetProcId(render_view_host->GetProcess()->GetHandle());
render_view_host->Send(new ShellViewMsg_SetCurrentWorkingDirectory(
render_view_host->GetRoutingID(), current_working_directory_));
}
void WebKitTestController::RenderViewGone(base::TerminationStatus status) {
DCHECK(CalledOnValidThread());
- if (status == base::TERMINATION_STATUS_PROCESS_CRASHED ||
- status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) {
+ if (current_pid_ != base::kNullProcessId) {
+ printer_->AddErrorMessage(std::string("#CRASHED - renderer (pid ") +
+ base::IntToString(current_pid_) + ")");
+ } else {
printer_->AddErrorMessage("#CRASHED - renderer");
}
}
@@ -282,6 +296,30 @@ void WebKitTestController::WebContentsDestroyed(WebContents* web_contents) {
printer_->AddErrorMessage("FAIL: main window was destroyed");
}
+void WebKitTestController::Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ DCHECK(CalledOnValidThread());
+ switch (type) {
+ case NOTIFICATION_RENDERER_PROCESS_CREATED: {
+ if (!main_window_)
+ return;
+ RenderViewHost* render_view_host =
+ main_window_->web_contents()->GetRenderViewHost();
+ if (!render_view_host)
+ return;
+ RenderProcessHost* render_process_host =
+ Source<RenderProcessHost>(source).ptr();
+ if (render_process_host != render_view_host->GetProcess())
+ return;
+ current_pid_ = base::GetProcId(render_process_host->GetHandle());
+ break;
+ }
+ default:
+ NOTREACHED();
+ }
+}
+
void WebKitTestController::CaptureDump() {
if (captured_dump_ || !main_window_ || !printer_->in_text_block())
return;
« no previous file with comments | « content/shell/webkit_test_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698