Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_resource_handler.h" | 5 #include "chrome/browser/prerender/prerender_resource_handler.h" |
| 6 #include "chrome/common/resource_response.h" | 6 #include "chrome/common/resource_response.h" |
| 7 #include "net/http/http_response_headers.h" | 7 #include "net/http/http_response_headers.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 mock_handler_, | 93 mock_handler_, |
| 94 NewCallback( | 94 NewCallback( |
| 95 this, | 95 this, |
| 96 &PrerenderResourceHandlerTest::SetLastHandledURL)))), | 96 &PrerenderResourceHandlerTest::SetLastHandledURL)))), |
| 97 ui_thread_(BrowserThread::UI, &loop_), | 97 ui_thread_(BrowserThread::UI, &loop_), |
| 98 default_url_("http://www.prerender.com") { | 98 default_url_("http://www.prerender.com") { |
| 99 pre_handler_->set_prerender_duration(prerender_duration_); | 99 pre_handler_->set_prerender_duration(prerender_duration_); |
| 100 pre_handler_->set_get_current_time_function(&FixedGetCurrentTime); | 100 pre_handler_->set_get_current_time_function(&FixedGetCurrentTime); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void SetLastHandledURL(const GURL& url) { | 103 void SetLastHandledURL(const GURL& url, const std::vector<GURL>& alias_url) { |
|
cbentzel
2011/01/14 02:01:13
I recommend copying alias_urls into a member varia
tburkard
2011/01/18 22:29:18
Done.
| |
| 104 last_handled_url_ = url; | 104 last_handled_url_ = url; |
| 105 } | 105 } |
| 106 | 106 |
| 107 // Common logic shared by many of the tests | 107 // Common logic shared by many of the tests |
| 108 void StartPrerendering(const std::string& mime_type, | 108 void StartPrerendering(const std::string& mime_type, |
| 109 const char* headers) { | 109 const char* headers) { |
| 110 int request_id = 1; | 110 int request_id = 1; |
| 111 bool defer = false; | 111 bool defer = false; |
| 112 EXPECT_TRUE(pre_handler_->OnWillStart(request_id, default_url_, &defer)); | 112 EXPECT_TRUE(pre_handler_->OnWillStart(request_id, default_url_, &defer)); |
| 113 EXPECT_FALSE(defer); | 113 EXPECT_FALSE(defer); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 response->response_head.headers = CreateResponseHeaders( | 204 response->response_head.headers = CreateResponseHeaders( |
| 205 "HTTP/1.1 200 OK\n" | 205 "HTTP/1.1 200 OK\n" |
| 206 "cache-control: max-age=86400\n"); | 206 "cache-control: max-age=86400\n"); |
| 207 EXPECT_TRUE(pre_handler_->OnResponseStarted(request_id, response)); | 207 EXPECT_TRUE(pre_handler_->OnResponseStarted(request_id, response)); |
| 208 EXPECT_TRUE(last_handled_url_.is_empty()); | 208 EXPECT_TRUE(last_handled_url_.is_empty()); |
| 209 loop_.RunAllPending(); | 209 loop_.RunAllPending(); |
| 210 EXPECT_EQ(url_redirect, last_handled_url_); | 210 EXPECT_EQ(url_redirect, last_handled_url_); |
| 211 } | 211 } |
| 212 | 212 |
| 213 } | 213 } |
| 214 | |
| OLD | NEW |