OLD | NEW |
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 "chrome/browser/prerender/prerender_test_utils.h" | 5 #include "chrome/browser/prerender/prerender_test_utils.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h" | 9 #include "chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h" |
10 #include "chrome/browser/prerender/prerender_manager.h" | 10 #include "chrome/browser/prerender/prerender_manager.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 | 243 |
244 // A used PrerenderContents will only be destroyed when we swap out | 244 // A used PrerenderContents will only be destroyed when we swap out |
245 // WebContents, at the end of a navigation caused by a call to | 245 // WebContents, at the end of a navigation caused by a call to |
246 // NavigateToURLImpl(). | 246 // NavigateToURLImpl(). |
247 if (final_status() == FINAL_STATUS_USED) | 247 if (final_status() == FINAL_STATUS_USED) |
248 EXPECT_TRUE(new_render_view_host_); | 248 EXPECT_TRUE(new_render_view_host_); |
249 | 249 |
250 EXPECT_EQ(should_be_shown_, was_shown_); | 250 EXPECT_EQ(should_be_shown_, was_shown_); |
251 } | 251 } |
252 | 252 |
253 void TestPrerenderContents::RenderProcessGone(base::TerminationStatus status) { | |
254 // On quit, it's possible to end up here when render processes are closed | |
255 // before the PrerenderManager is destroyed. As a result, it's possible to | |
256 // get either FINAL_STATUS_APP_TERMINATING or FINAL_STATUS_RENDERER_CRASHED | |
257 // on quit. | |
258 // | |
259 // It's also possible for this to be called after we've been notified of | |
260 // app termination, but before we've been deleted, which is why the second | |
261 // check is needed. | |
262 if (expected_final_status_ == FINAL_STATUS_APP_TERMINATING && | |
263 final_status() != expected_final_status_) { | |
264 expected_final_status_ = FINAL_STATUS_RENDERER_CRASHED; | |
265 } | |
266 | |
267 PrerenderContents::RenderProcessGone(status); | |
268 } | |
269 | |
270 bool TestPrerenderContents::CheckURL(const GURL& url) { | 253 bool TestPrerenderContents::CheckURL(const GURL& url) { |
271 // Prevent FINAL_STATUS_UNSUPPORTED_SCHEME when navigating to about:crash in | 254 // Prevent FINAL_STATUS_UNSUPPORTED_SCHEME when navigating to about:crash in |
272 // the PrerenderRendererCrash test. | 255 // the PrerenderRendererCrash test. |
273 if (url.spec() != content::kChromeUICrashURL) | 256 if (url.spec() != content::kChromeUICrashURL) |
274 return PrerenderContents::CheckURL(url); | 257 return PrerenderContents::CheckURL(url); |
275 return true; | 258 return true; |
276 } | 259 } |
277 | 260 |
278 void TestPrerenderContents::OnRenderViewHostCreated( | 261 void TestPrerenderContents::OnRenderViewHostCreated( |
279 RenderViewHost* new_render_view_host) { | 262 RenderViewHost* new_render_view_host) { |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 void CreateMockInterceptorOnIO(const GURL& url, const base::FilePath& file) { | 633 void CreateMockInterceptorOnIO(const GURL& url, const base::FilePath& file) { |
651 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 634 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
652 net::URLRequestFilter::GetInstance()->AddUrlInterceptor( | 635 net::URLRequestFilter::GetInstance()->AddUrlInterceptor( |
653 url, net::URLRequestMockHTTPJob::CreateInterceptorForSingleFile( | 636 url, net::URLRequestMockHTTPJob::CreateInterceptorForSingleFile( |
654 file, content::BrowserThread::GetBlockingPool())); | 637 file, content::BrowserThread::GetBlockingPool())); |
655 } | 638 } |
656 | 639 |
657 } // namespace test_utils | 640 } // namespace test_utils |
658 | 641 |
659 } // namespace prerender | 642 } // namespace prerender |
OLD | NEW |