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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/shell/webkit_test_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/shell/webkit_test_controller.h" 5 #include "content/shell/webkit_test_controller.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/process_util.h"
12 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/string_number_conversions.h"
13 #include "content/public/browser/navigation_controller.h" 15 #include "content/public/browser/navigation_controller.h"
16 #include "content/public/browser/notification_service.h"
17 #include "content/public/browser/notification_types.h"
18 #include "content/public/browser/render_process_host.h"
14 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
16 #include "content/shell/shell.h" 21 #include "content/shell/shell.h"
17 #include "content/shell/shell_browser_context.h" 22 #include "content/shell/shell_browser_context.h"
18 #include "content/shell/shell_content_browser_client.h" 23 #include "content/shell/shell_content_browser_client.h"
19 #include "content/shell/shell_messages.h" 24 #include "content/shell/shell_messages.h"
20 #include "content/shell/shell_switches.h" 25 #include "content/shell/shell_switches.h"
21 #include "content/shell/webkit_test_helpers.h" 26 #include "content/shell/webkit_test_helpers.h"
22 #include "webkit/fileapi/isolated_context.h" 27 #include "webkit/fileapi/isolated_context.h"
23 #include "webkit/support/webkit_support_gfx.h" 28 #include "webkit/support/webkit_support_gfx.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // static 128 // static
124 WebKitTestController* WebKitTestController::Get() { 129 WebKitTestController* WebKitTestController::Get() {
125 DCHECK(instance_); 130 DCHECK(instance_);
126 return instance_; 131 return instance_;
127 } 132 }
128 133
129 WebKitTestController::WebKitTestController() { 134 WebKitTestController::WebKitTestController() {
130 CHECK(!instance_); 135 CHECK(!instance_);
131 instance_ = this; 136 instance_ = this;
132 printer_.reset(new WebKitTestResultPrinter(&std::cout, &std::cerr)); 137 printer_.reset(new WebKitTestResultPrinter(&std::cout, &std::cerr));
138 registrar_.Add(this,
139 NOTIFICATION_RENDERER_PROCESS_CREATED,
140 NotificationService::AllSources());
133 ResetAfterLayoutTest(); 141 ResetAfterLayoutTest();
134 } 142 }
135 143
136 WebKitTestController::~WebKitTestController() { 144 WebKitTestController::~WebKitTestController() {
137 DCHECK(CalledOnValidThread()); 145 DCHECK(CalledOnValidThread());
138 CHECK(instance_ == this); 146 CHECK(instance_ == this);
139 if (main_window_) 147 if (main_window_)
140 main_window_->Close(); 148 main_window_->Close();
141 instance_ = NULL; 149 instance_ = NULL;
142 } 150 }
(...skipping 11 matching lines...) Expand all
154 printer_->PrintTextHeader(); 162 printer_->PrintTextHeader();
155 content::ShellBrowserContext* browser_context = 163 content::ShellBrowserContext* browser_context =
156 static_cast<content::ShellContentBrowserClient*>( 164 static_cast<content::ShellContentBrowserClient*>(
157 content::GetContentClient()->browser())->browser_context(); 165 content::GetContentClient()->browser())->browser_context();
158 main_window_ = content::Shell::CreateNewWindow( 166 main_window_ = content::Shell::CreateNewWindow(
159 browser_context, 167 browser_context,
160 GURL(), 168 GURL(),
161 NULL, 169 NULL,
162 MSG_ROUTING_NONE, 170 MSG_ROUTING_NONE,
163 NULL); 171 NULL);
164 Observe(main_window_->web_contents()); 172 WebContentsObserver::Observe(main_window_->web_contents());
165 main_window_->LoadURL(test_url); 173 main_window_->LoadURL(test_url);
166 if (test_url.spec().find("/dumpAsText/") != std::string::npos || 174 if (test_url.spec().find("/dumpAsText/") != std::string::npos ||
167 test_url.spec().find("\\dumpAsText\\") != std::string::npos) { 175 test_url.spec().find("\\dumpAsText\\") != std::string::npos) {
168 dump_as_text_ = true; 176 dump_as_text_ = true;
169 enable_pixel_dumping_ = false; 177 enable_pixel_dumping_ = false;
170 } 178 }
171 if (test_url.spec().find("/inspector/") != std::string::npos || 179 if (test_url.spec().find("/inspector/") != std::string::npos ||
172 test_url.spec().find("\\inspector\\") != std::string::npos) { 180 test_url.spec().find("\\inspector\\") != std::string::npos) {
173 main_window_->ShowDevTools(); 181 main_window_->ShowDevTools();
174 } 182 }
(...skipping 16 matching lines...) Expand all
191 wait_until_done_ = false; 199 wait_until_done_ = false;
192 did_finish_load_ = false; 200 did_finish_load_ = false;
193 prefs_ = webkit_glue::WebPreferences(); 201 prefs_ = webkit_glue::WebPreferences();
194 should_override_prefs_ = false; 202 should_override_prefs_ = false;
195 { 203 {
196 base::AutoLock lock(lock_); 204 base::AutoLock lock(lock_);
197 can_open_windows_ = false; 205 can_open_windows_ = false;
198 } 206 }
199 watchdog_.Cancel(); 207 watchdog_.Cancel();
200 if (main_window_) { 208 if (main_window_) {
201 Observe(NULL); 209 WebContentsObserver::Observe(NULL);
202 main_window_ = NULL; 210 main_window_ = NULL;
203 } 211 }
204 Shell::CloseAllWindows(); 212 Shell::CloseAllWindows();
205 Send(new ShellViewMsg_ResetAll); 213 Send(new ShellViewMsg_ResetAll);
214 current_pid_ = base::kNullProcessId;
206 return true; 215 return true;
207 } 216 }
208 217
209 void WebKitTestController::RendererUnresponsive() { 218 void WebKitTestController::RendererUnresponsive() {
210 DCHECK(CalledOnValidThread()); 219 DCHECK(CalledOnValidThread());
211 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTimeout)) 220 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTimeout))
212 printer_->AddErrorMessage("#PROCESS UNRESPONSIVE - renderer"); 221 printer_->AddErrorMessage("#PROCESS UNRESPONSIVE - renderer");
213 } 222 }
214 223
215 void WebKitTestController::OverrideWebkitPrefs( 224 void WebKitTestController::OverrideWebkitPrefs(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 return handled; 266 return handled;
258 } 267 }
259 268
260 void WebKitTestController::PluginCrashed(const FilePath& plugin_path) { 269 void WebKitTestController::PluginCrashed(const FilePath& plugin_path) {
261 DCHECK(CalledOnValidThread()); 270 DCHECK(CalledOnValidThread());
262 printer_->AddErrorMessage("#CRASHED - plugin"); 271 printer_->AddErrorMessage("#CRASHED - plugin");
263 } 272 }
264 273
265 void WebKitTestController::RenderViewCreated(RenderViewHost* render_view_host) { 274 void WebKitTestController::RenderViewCreated(RenderViewHost* render_view_host) {
266 DCHECK(CalledOnValidThread()); 275 DCHECK(CalledOnValidThread());
276 // Might be kNullProcessId, in which case we will receive a notification later
277 // when the RenderProcessHost was created.
278 current_pid_ = base::GetProcId(render_view_host->GetProcess()->GetHandle());
267 render_view_host->Send(new ShellViewMsg_SetCurrentWorkingDirectory( 279 render_view_host->Send(new ShellViewMsg_SetCurrentWorkingDirectory(
268 render_view_host->GetRoutingID(), current_working_directory_)); 280 render_view_host->GetRoutingID(), current_working_directory_));
269 } 281 }
270 282
271 void WebKitTestController::RenderViewGone(base::TerminationStatus status) { 283 void WebKitTestController::RenderViewGone(base::TerminationStatus status) {
272 DCHECK(CalledOnValidThread()); 284 DCHECK(CalledOnValidThread());
273 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || 285 if (current_pid_ != base::kNullProcessId) {
274 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { 286 printer_->AddErrorMessage(std::string("#CRASHED - renderer (pid ") +
287 base::IntToString(current_pid_) + ")");
288 } else {
275 printer_->AddErrorMessage("#CRASHED - renderer"); 289 printer_->AddErrorMessage("#CRASHED - renderer");
276 } 290 }
277 } 291 }
278 292
279 void WebKitTestController::WebContentsDestroyed(WebContents* web_contents) { 293 void WebKitTestController::WebContentsDestroyed(WebContents* web_contents) {
280 DCHECK(CalledOnValidThread()); 294 DCHECK(CalledOnValidThread());
281 main_window_ = NULL; 295 main_window_ = NULL;
282 printer_->AddErrorMessage("FAIL: main window was destroyed"); 296 printer_->AddErrorMessage("FAIL: main window was destroyed");
283 } 297 }
284 298
299 void WebKitTestController::Observe(int type,
300 const NotificationSource& source,
301 const NotificationDetails& details) {
302 DCHECK(CalledOnValidThread());
303 switch (type) {
304 case NOTIFICATION_RENDERER_PROCESS_CREATED: {
305 if (!main_window_)
306 return;
307 RenderViewHost* render_view_host =
308 main_window_->web_contents()->GetRenderViewHost();
309 if (!render_view_host)
310 return;
311 RenderProcessHost* render_process_host =
312 Source<RenderProcessHost>(source).ptr();
313 if (render_process_host != render_view_host->GetProcess())
314 return;
315 current_pid_ = base::GetProcId(render_process_host->GetHandle());
316 break;
317 }
318 default:
319 NOTREACHED();
320 }
321 }
322
285 void WebKitTestController::CaptureDump() { 323 void WebKitTestController::CaptureDump() {
286 if (captured_dump_ || !main_window_ || !printer_->in_text_block()) 324 if (captured_dump_ || !main_window_ || !printer_->in_text_block())
287 return; 325 return;
288 captured_dump_ = true; 326 captured_dump_ = true;
289 327
290 if (main_window_->web_contents()->GetContentsMimeType() == "text/plain") { 328 if (main_window_->web_contents()->GetContentsMimeType() == "text/plain") {
291 dump_as_text_ = true; 329 dump_as_text_ = true;
292 enable_pixel_dumping_ = false; 330 enable_pixel_dumping_ = false;
293 } 331 }
294 332
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 495
458 void WebKitTestController::OnNotImplemented( 496 void WebKitTestController::OnNotImplemented(
459 const std::string& object_name, 497 const std::string& object_name,
460 const std::string& property_name) { 498 const std::string& property_name) {
461 printer_->AddErrorMessage( 499 printer_->AddErrorMessage(
462 std::string("FAIL: NOT IMPLEMENTED: ") + 500 std::string("FAIL: NOT IMPLEMENTED: ") +
463 object_name + "." + property_name); 501 object_name + "." + property_name);
464 } 502 }
465 503
466 } // namespace content 504 } // namespace content
OLDNEW
« 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