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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor_unittest.cc

Issue 2321343002: Redirect handling in resource prefetch predictor (Closed)
Patch Set: Redirects database schema changed Created 4 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/predictors/resource_prefetch_predictor.h" 5 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 18 matching lines...) Expand all
29 29
30 using testing::ContainerEq; 30 using testing::ContainerEq;
31 using testing::Pointee; 31 using testing::Pointee;
32 using testing::SetArgPointee; 32 using testing::SetArgPointee;
33 using testing::StrictMock; 33 using testing::StrictMock;
34 34
35 namespace predictors { 35 namespace predictors {
36 36
37 typedef ResourcePrefetchPredictor::URLRequestSummary URLRequestSummary; 37 typedef ResourcePrefetchPredictor::URLRequestSummary URLRequestSummary;
38 typedef ResourcePrefetchPredictorTables::ResourceRow ResourceRow; 38 typedef ResourcePrefetchPredictorTables::ResourceRow ResourceRow;
39 typedef std::vector<ResourceRow> ResourceRows; 39 typedef ResourcePrefetchPredictorTables::RedirectRow RedirectRow;
40 typedef ResourcePrefetchPredictorTables::PrefetchData PrefetchData; 40 typedef ResourcePrefetchPredictorTables::PrefetchData PrefetchData;
41 typedef ResourcePrefetchPredictorTables::PrefetchDataMap PrefetchDataMap; 41 typedef ResourcePrefetchPredictorTables::PrefetchDataMap PrefetchDataMap;
42 typedef ResourcePrefetchPredictorTables::RedirectData RedirectData;
43 typedef ResourcePrefetchPredictorTables::RedirectDataMap RedirectDataMap;
42 44
43 // For printing failures nicely. 45 // For printing failures nicely.
44 void PrintTo(const ResourceRow& row, ::std::ostream* os) { 46 void PrintTo(const ResourceRow& row, ::std::ostream* os) {
45 *os << "[" 47 *os << "["
46 << "," << row.resource_url << "," << row.resource_type << "," 48 << "," << row.resource_url << "," << row.resource_type << ","
47 << row.number_of_hits << "," << row.number_of_misses << "," 49 << row.number_of_hits << "," << row.number_of_misses << ","
48 << row.consecutive_misses << "," << row.average_position << "," 50 << row.consecutive_misses << "," << row.average_position << ","
49 << row.score << "]"; 51 << row.score << "]";
50 } 52 }
51 53
52 void PrintTo(const PrefetchData& data, ::std::ostream* os) { 54 void PrintTo(const PrefetchData& data, ::std::ostream* os) {
53 *os << "[" << data.key_type << "," << data.primary_key 55 *os << "[" << data.key_type << "," << data.primary_key
54 << "," << data.last_visit.ToInternalValue() << "]\n"; 56 << "," << data.last_visit.ToInternalValue() << "]\n";
55 for (ResourceRows::const_iterator it = data.resources.begin(); 57 for (const ResourceRow& resource : data.resources) {
56 it != data.resources.end(); ++it) {
57 *os << "\t\t"; 58 *os << "\t\t";
58 PrintTo(*it, os); 59 PrintTo(resource, os);
59 *os << "\n"; 60 *os << "\n";
60 } 61 }
61 } 62 }
62 63
63 scoped_refptr<net::HttpResponseHeaders> MakeResponseHeaders( 64 scoped_refptr<net::HttpResponseHeaders> MakeResponseHeaders(
64 const char* headers) { 65 const char* headers) {
65 return make_scoped_refptr(new net::HttpResponseHeaders( 66 return make_scoped_refptr(new net::HttpResponseHeaders(
66 net::HttpUtil::AssembleRawHeaders(headers, strlen(headers)))); 67 net::HttpUtil::AssembleRawHeaders(headers, strlen(headers))));
67 } 68 }
68 69
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 private: 142 private:
142 net::HttpResponseInfo response_info_; 143 net::HttpResponseInfo response_info_;
143 std::string mime_type_; 144 std::string mime_type_;
144 }; 145 };
145 146
146 class MockResourcePrefetchPredictorTables 147 class MockResourcePrefetchPredictorTables
147 : public ResourcePrefetchPredictorTables { 148 : public ResourcePrefetchPredictorTables {
148 public: 149 public:
149 MockResourcePrefetchPredictorTables() { } 150 MockResourcePrefetchPredictorTables() { }
150 151
151 MOCK_METHOD2(GetAllData, void(PrefetchDataMap* url_data_map, 152 MOCK_METHOD4(GetAllData,
152 PrefetchDataMap* host_data_map)); 153 void(PrefetchDataMap* url_data_map,
153 MOCK_METHOD2(UpdateData, void(const PrefetchData& url_data, 154 PrefetchDataMap* host_data_map,
154 const PrefetchData& host_data)); 155 RedirectDataMap* url_redirect_data_map,
155 MOCK_METHOD2(DeleteData, void(const std::vector<std::string>& urls, 156 RedirectDataMap* host_redirect_data_map));
156 const std::vector<std::string>& hosts)); 157 MOCK_METHOD4(UpdateData,
157 MOCK_METHOD2(DeleteSingleDataPoint, void(const std::string& key, 158 void(const PrefetchData& url_data,
158 PrefetchKeyType key_type)); 159 const PrefetchData& host_data,
160 const RedirectData& url_redirect_data,
161 const RedirectData& host_redirect_data));
162 MOCK_METHOD2(DeleteResourceData,
163 void(const std::vector<std::string>& urls,
164 const std::vector<std::string>& hosts));
165 MOCK_METHOD2(DeleteSingleResourceDataPoint,
166 void(const std::string& key, PrefetchKeyType key_type));
167 MOCK_METHOD2(DeleteRedirectData,
168 void(const std::vector<std::string>& urls,
169 const std::vector<std::string>& hosts));
170 MOCK_METHOD2(DeleteSingleRedirectDataPoint,
171 void(const std::string& key, PrefetchKeyType key_type));
159 MOCK_METHOD0(DeleteAllData, void()); 172 MOCK_METHOD0(DeleteAllData, void());
160 173
161 protected: 174 protected:
162 ~MockResourcePrefetchPredictorTables() { } 175 ~MockResourcePrefetchPredictorTables() { }
163 }; 176 };
164 177
165 class ResourcePrefetchPredictorTest : public testing::Test { 178 class ResourcePrefetchPredictorTest : public testing::Test {
166 public: 179 public:
167 ResourcePrefetchPredictorTest(); 180 ResourcePrefetchPredictorTest();
168 ~ResourcePrefetchPredictorTest() override; 181 ~ResourcePrefetchPredictorTest() override;
(...skipping 17 matching lines...) Expand all
186 199
187 NavigationID CreateNavigationID(int process_id, 200 NavigationID CreateNavigationID(int process_id,
188 int render_frame_id, 201 int render_frame_id,
189 const std::string& main_frame_url) { 202 const std::string& main_frame_url) {
190 NavigationID navigation_id(process_id, render_frame_id, 203 NavigationID navigation_id(process_id, render_frame_id,
191 GURL(main_frame_url)); 204 GURL(main_frame_url));
192 navigation_id.creation_time = base::TimeTicks::Now(); 205 navigation_id.creation_time = base::TimeTicks::Now();
193 return navigation_id; 206 return navigation_id;
194 } 207 }
195 208
196 ResourcePrefetchPredictor::URLRequestSummary CreateURLRequestSummary( 209 URLRequestSummary CreateURLRequestSummary(
197 int process_id, 210 int process_id,
198 int render_frame_id, 211 int render_frame_id,
199 const std::string& main_frame_url, 212 const std::string& main_frame_url,
200 const std::string& resource_url, 213 const std::string& resource_url = std::string(),
201 content::ResourceType resource_type, 214 content::ResourceType resource_type = content::RESOURCE_TYPE_MAIN_FRAME,
202 net::RequestPriority priority, 215 net::RequestPriority priority = net::MEDIUM,
203 const std::string& mime_type, 216 const std::string& mime_type = std::string(),
204 bool was_cached) { 217 bool was_cached = false) {
205 ResourcePrefetchPredictor::URLRequestSummary summary; 218 URLRequestSummary summary;
206 summary.navigation_id = CreateNavigationID(process_id, render_frame_id, 219 summary.navigation_id = CreateNavigationID(process_id, render_frame_id,
207 main_frame_url); 220 main_frame_url);
208 summary.resource_url = GURL(resource_url); 221 summary.resource_url =
222 resource_url.empty() ? GURL(main_frame_url) : GURL(resource_url);
209 summary.resource_type = resource_type; 223 summary.resource_type = resource_type;
210 summary.priority = priority; 224 summary.priority = priority;
211 summary.mime_type = mime_type; 225 summary.mime_type = mime_type;
212 summary.was_cached = was_cached; 226 summary.was_cached = was_cached;
213 return summary; 227 return summary;
214 } 228 }
215 229
230 URLRequestSummary CreateRedirectRequestSummary(
231 int process_id,
232 int render_frame_id,
233 const std::string& main_frame_url,
234 const std::string& redirect_url) {
235 URLRequestSummary summary =
236 CreateURLRequestSummary(process_id, render_frame_id, main_frame_url);
237 summary.redirect_url = GURL(redirect_url);
238 return summary;
239 }
240
216 std::unique_ptr<net::URLRequest> CreateURLRequest( 241 std::unique_ptr<net::URLRequest> CreateURLRequest(
217 const GURL& url, 242 const GURL& url,
218 net::RequestPriority priority, 243 net::RequestPriority priority,
219 content::ResourceType resource_type, 244 content::ResourceType resource_type,
220 int render_process_id, 245 int render_process_id,
221 int render_frame_id, 246 int render_frame_id,
222 bool is_main_frame) { 247 bool is_main_frame) {
223 std::unique_ptr<net::URLRequest> request = 248 std::unique_ptr<net::URLRequest> request =
224 url_request_context_.CreateRequest(url, priority, 249 url_request_context_.CreateRequest(url, priority,
225 &url_request_delegate_); 250 &url_request_delegate_);
(...skipping 20 matching lines...) Expand all
246 lhs.mime_type == rhs.mime_type && 271 lhs.mime_type == rhs.mime_type &&
247 lhs.was_cached == rhs.was_cached; 272 lhs.was_cached == rhs.was_cached;
248 } 273 }
249 274
250 void ResetPredictor() { 275 void ResetPredictor() {
251 ResourcePrefetchPredictorConfig config; 276 ResourcePrefetchPredictorConfig config;
252 config.max_urls_to_track = 3; 277 config.max_urls_to_track = 3;
253 config.max_hosts_to_track = 2; 278 config.max_hosts_to_track = 2;
254 config.min_url_visit_count = 2; 279 config.min_url_visit_count = 2;
255 config.max_resources_per_entry = 4; 280 config.max_resources_per_entry = 4;
281 config.max_redirects_per_entry = 3;
256 config.max_consecutive_misses = 2; 282 config.max_consecutive_misses = 2;
257 283
258 // TODO(shishir): Enable the prefetching mode in the tests. 284 // TODO(shishir): Enable the prefetching mode in the tests.
259 config.mode |= ResourcePrefetchPredictorConfig::URL_LEARNING; 285 config.mode |= ResourcePrefetchPredictorConfig::URL_LEARNING;
260 config.mode |= ResourcePrefetchPredictorConfig::HOST_LEARNING; 286 config.mode |= ResourcePrefetchPredictorConfig::HOST_LEARNING;
261 predictor_.reset(new ResourcePrefetchPredictor(config, profile_.get())); 287 predictor_.reset(new ResourcePrefetchPredictor(config, profile_.get()));
262 predictor_->set_mock_tables(mock_tables_); 288 predictor_->set_mock_tables(mock_tables_);
263 } 289 }
264 290
265 void InitializeSampleData(); 291 void InitializeSampleData();
266 292
267 base::MessageLoop loop_; 293 base::MessageLoop loop_;
268 content::TestBrowserThread ui_thread_; 294 content::TestBrowserThread ui_thread_;
269 content::TestBrowserThread db_thread_; 295 content::TestBrowserThread db_thread_;
270 std::unique_ptr<TestingProfile> profile_; 296 std::unique_ptr<TestingProfile> profile_;
271 net::TestURLRequestContext url_request_context_; 297 net::TestURLRequestContext url_request_context_;
272 298
273 std::unique_ptr<ResourcePrefetchPredictor> predictor_; 299 std::unique_ptr<ResourcePrefetchPredictor> predictor_;
274 scoped_refptr<StrictMock<MockResourcePrefetchPredictorTables> > mock_tables_; 300 scoped_refptr<StrictMock<MockResourcePrefetchPredictorTables> > mock_tables_;
275 301
276 PrefetchDataMap test_url_data_; 302 PrefetchDataMap test_url_data_;
277 PrefetchDataMap test_host_data_; 303 PrefetchDataMap test_host_data_;
304 RedirectDataMap test_url_redirect_data_;
305 RedirectDataMap test_host_redirect_data_;
278 PrefetchData empty_url_data_; 306 PrefetchData empty_url_data_;
279 PrefetchData empty_host_data_; 307 PrefetchData empty_host_data_;
308 RedirectData empty_url_redirect_data_;
309 RedirectData empty_host_redirect_data_;
280 310
281 MockURLRequestJobFactory url_request_job_factory_; 311 MockURLRequestJobFactory url_request_job_factory_;
282 EmptyURLRequestDelegate url_request_delegate_; 312 EmptyURLRequestDelegate url_request_delegate_;
283 }; 313 };
284 314
285 ResourcePrefetchPredictorTest::ResourcePrefetchPredictorTest() 315 ResourcePrefetchPredictorTest::ResourcePrefetchPredictorTest()
286 : loop_(base::MessageLoop::TYPE_DEFAULT), 316 : loop_(base::MessageLoop::TYPE_DEFAULT),
287 ui_thread_(content::BrowserThread::UI, &loop_), 317 ui_thread_(content::BrowserThread::UI, &loop_),
288 db_thread_(content::BrowserThread::DB, &loop_), 318 db_thread_(content::BrowserThread::DB, &loop_),
289 profile_(new TestingProfile()), 319 profile_(new TestingProfile()),
290 mock_tables_(new StrictMock<MockResourcePrefetchPredictorTables>()), 320 mock_tables_(new StrictMock<MockResourcePrefetchPredictorTables>()),
291 empty_url_data_(PREFETCH_KEY_TYPE_URL, std::string()), 321 empty_url_data_(PREFETCH_KEY_TYPE_URL, std::string()),
292 empty_host_data_(PREFETCH_KEY_TYPE_HOST, std::string()) {} 322 empty_host_data_(PREFETCH_KEY_TYPE_HOST, std::string()),
323 empty_url_redirect_data_(PREFETCH_KEY_TYPE_URL, std::string()),
324 empty_host_redirect_data_(PREFETCH_KEY_TYPE_HOST, std::string()) {}
293 325
294 ResourcePrefetchPredictorTest::~ResourcePrefetchPredictorTest() { 326 ResourcePrefetchPredictorTest::~ResourcePrefetchPredictorTest() {
295 profile_.reset(NULL); 327 profile_.reset(NULL);
296 base::RunLoop().RunUntilIdle(); 328 base::RunLoop().RunUntilIdle();
297 } 329 }
298 330
299 void ResourcePrefetchPredictorTest::SetUp() { 331 void ResourcePrefetchPredictorTest::SetUp() {
300 InitializeSampleData(); 332 InitializeSampleData();
301 333
302 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); 334 ASSERT_TRUE(profile_->CreateHistoryService(true, false));
303 profile_->BlockUntilHistoryProcessesPendingRequests(); 335 profile_->BlockUntilHistoryProcessesPendingRequests();
304 EXPECT_TRUE(HistoryServiceFactory::GetForProfile( 336 EXPECT_TRUE(HistoryServiceFactory::GetForProfile(
305 profile_.get(), ServiceAccessType::EXPLICIT_ACCESS)); 337 profile_.get(), ServiceAccessType::EXPLICIT_ACCESS));
306 // Initialize the predictor with empty data. 338 // Initialize the predictor with empty data.
307 ResetPredictor(); 339 ResetPredictor();
308 EXPECT_EQ(predictor_->initialization_state_, 340 EXPECT_EQ(predictor_->initialization_state_,
309 ResourcePrefetchPredictor::NOT_INITIALIZED); 341 ResourcePrefetchPredictor::NOT_INITIALIZED);
310 EXPECT_CALL(*mock_tables_.get(), 342 EXPECT_CALL(*mock_tables_.get(),
311 GetAllData(Pointee(ContainerEq(PrefetchDataMap())), 343 GetAllData(Pointee(ContainerEq(PrefetchDataMap())),
312 Pointee(ContainerEq(PrefetchDataMap())))); 344 Pointee(ContainerEq(PrefetchDataMap())),
345 Pointee(ContainerEq(RedirectDataMap())),
346 Pointee(ContainerEq(RedirectDataMap()))));
313 InitializePredictor(); 347 InitializePredictor();
314 EXPECT_TRUE(predictor_->inflight_navigations_.empty()); 348 EXPECT_TRUE(predictor_->inflight_navigations_.empty());
315 EXPECT_EQ(predictor_->initialization_state_, 349 EXPECT_EQ(predictor_->initialization_state_,
316 ResourcePrefetchPredictor::INITIALIZED); 350 ResourcePrefetchPredictor::INITIALIZED);
317 351
318 url_request_context_.set_job_factory(&url_request_job_factory_); 352 url_request_context_.set_job_factory(&url_request_job_factory_);
319 } 353 }
320 354
321 void ResourcePrefetchPredictorTest::TearDown() { 355 void ResourcePrefetchPredictorTest::TearDown() {
322 predictor_.reset(NULL); 356 predictor_.reset(NULL);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 PrefetchData yahoo(PREFETCH_KEY_TYPE_HOST, "www.yahoo.com"); 421 PrefetchData yahoo(PREFETCH_KEY_TYPE_HOST, "www.yahoo.com");
388 yahoo.last_visit = base::Time::FromInternalValue(5); 422 yahoo.last_visit = base::Time::FromInternalValue(5);
389 yahoo.resources.push_back(ResourceRow("http://google.com/image.png", 423 yahoo.resources.push_back(ResourceRow("http://google.com/image.png",
390 content::RESOURCE_TYPE_IMAGE, 20, 1, 424 content::RESOURCE_TYPE_IMAGE, 20, 1,
391 0, 10.0, net::MEDIUM, false, false)); 425 0, 10.0, net::MEDIUM, false, false));
392 426
393 test_host_data_.clear(); 427 test_host_data_.clear();
394 test_host_data_.insert(std::make_pair("www.facebook.com", facebook)); 428 test_host_data_.insert(std::make_pair("www.facebook.com", facebook));
395 test_host_data_.insert(std::make_pair("www.yahoo.com", yahoo)); 429 test_host_data_.insert(std::make_pair("www.yahoo.com", yahoo));
396 } 430 }
431
432 { // Url redirect data.
433 RedirectData facebook(PREFETCH_KEY_TYPE_URL, "http://fb.com/google");
434 facebook.last_visit = base::Time::FromInternalValue(6);
435 facebook.redirects.push_back(
436 RedirectRow("https://facebook.com/google", 5, 1, 0));
437 facebook.redirects.push_back(
438 RedirectRow("https://facebook.com/login", 3, 5, 1));
439
440 RedirectData nytimes(PREFETCH_KEY_TYPE_URL, "http://nyt.com");
441 nytimes.last_visit = base::Time::FromInternalValue(7);
442 nytimes.redirects.push_back(RedirectRow("https://nytimes.com", 2, 0, 0));
443
444 RedirectData google(PREFETCH_KEY_TYPE_URL, "http://google.com");
445 google.last_visit = base::Time::FromInternalValue(8);
446 google.redirects.push_back(RedirectRow("https://google.com", 3, 0, 0));
447
448 test_url_redirect_data_.clear();
449 test_url_redirect_data_.insert(
450 std::make_pair(facebook.primary_key, facebook));
451 test_url_redirect_data_.insert(
452 std::make_pair(nytimes.primary_key, nytimes));
453 test_url_redirect_data_.insert(std::make_pair(google.primary_key, google));
454 }
455
456 { // Host redirect data.
457 RedirectData bbc(PREFETCH_KEY_TYPE_HOST, "bbc.com");
458 bbc.last_visit = base::Time::FromInternalValue(9);
459 bbc.redirects.push_back(RedirectRow("www.bbc.com", 8, 4, 1));
460 bbc.redirects.push_back(RedirectRow("m.bbc.com", 5, 8, 0));
461 bbc.redirects.push_back(RedirectRow("bbc.co.uk", 1, 3, 0));
462
463 RedirectData microsoft(PREFETCH_KEY_TYPE_HOST, "microsoft.com");
464 microsoft.last_visit = base::Time::FromInternalValue(10);
465 microsoft.redirects.push_back(RedirectRow("www.microsoft.com", 10, 0, 0));
466
467 test_host_redirect_data_.clear();
468 test_host_redirect_data_.insert(std::make_pair(bbc.primary_key, bbc));
469 test_host_redirect_data_.insert(
470 std::make_pair(microsoft.primary_key, microsoft));
471 }
397 } 472 }
398 473
399 TEST_F(ResourcePrefetchPredictorTest, LazilyInitializeEmpty) { 474 TEST_F(ResourcePrefetchPredictorTest, LazilyInitializeEmpty) {
400 // Tests that the predictor initializes correctly without any data. 475 // Tests that the predictor initializes correctly without any data.
401 EXPECT_TRUE(predictor_->url_table_cache_->empty()); 476 EXPECT_TRUE(predictor_->url_table_cache_->empty());
402 EXPECT_TRUE(predictor_->host_table_cache_->empty()); 477 EXPECT_TRUE(predictor_->host_table_cache_->empty());
478 EXPECT_TRUE(predictor_->url_redirect_table_cache_->empty());
479 EXPECT_TRUE(predictor_->host_redirect_table_cache_->empty());
403 } 480 }
404 481
405 TEST_F(ResourcePrefetchPredictorTest, LazilyInitializeWithData) { 482 TEST_F(ResourcePrefetchPredictorTest, LazilyInitializeWithData) {
406 // Tests that the history and the db tables data are loaded correctly. 483 // Tests that the history and the db tables data are loaded correctly.
407 AddUrlToHistory("http://www.google.com/", 4); 484 AddUrlToHistory("http://www.google.com/", 4);
408 AddUrlToHistory("http://www.yahoo.com/", 2); 485 AddUrlToHistory("http://www.yahoo.com/", 2);
409 486
410 EXPECT_CALL(*mock_tables_.get(), 487 EXPECT_CALL(*mock_tables_.get(),
411 GetAllData(Pointee(ContainerEq(PrefetchDataMap())), 488 GetAllData(Pointee(ContainerEq(PrefetchDataMap())),
412 Pointee(ContainerEq(PrefetchDataMap())))) 489 Pointee(ContainerEq(PrefetchDataMap())),
490 Pointee(ContainerEq(RedirectDataMap())),
491 Pointee(ContainerEq(RedirectDataMap()))))
413 .WillOnce(DoAll(SetArgPointee<0>(test_url_data_), 492 .WillOnce(DoAll(SetArgPointee<0>(test_url_data_),
414 SetArgPointee<1>(test_host_data_))); 493 SetArgPointee<1>(test_host_data_),
494 SetArgPointee<2>(test_url_redirect_data_),
495 SetArgPointee<3>(test_host_redirect_data_)));
415 496
416 ResetPredictor(); 497 ResetPredictor();
417 InitializePredictor(); 498 InitializePredictor();
418 499
419 // Test that the internal variables correctly initialized. 500 // Test that the internal variables correctly initialized.
420 EXPECT_EQ(predictor_->initialization_state_, 501 EXPECT_EQ(predictor_->initialization_state_,
421 ResourcePrefetchPredictor::INITIALIZED); 502 ResourcePrefetchPredictor::INITIALIZED);
422 EXPECT_TRUE(predictor_->inflight_navigations_.empty()); 503 EXPECT_TRUE(predictor_->inflight_navigations_.empty());
423 504
424 EXPECT_EQ(test_url_data_, *predictor_->url_table_cache_); 505 EXPECT_EQ(test_url_data_, *predictor_->url_table_cache_);
425 EXPECT_EQ(test_host_data_, *predictor_->host_table_cache_); 506 EXPECT_EQ(test_host_data_, *predictor_->host_table_cache_);
507 EXPECT_EQ(test_url_redirect_data_, *predictor_->url_redirect_table_cache_);
508 EXPECT_EQ(test_host_redirect_data_, *predictor_->host_redirect_table_cache_);
426 } 509 }
427 510
428 TEST_F(ResourcePrefetchPredictorTest, NavigationNotRecorded) { 511 TEST_F(ResourcePrefetchPredictorTest, NavigationNotRecorded) {
429 // Single navigation but history count is low, so should not record. 512 // Single navigation but history count is low, so should not record.
430 AddUrlToHistory("http://www.google.com", 1); 513 AddUrlToHistory("http://www.google.com", 1);
431 514
432 URLRequestSummary main_frame = CreateURLRequestSummary( 515 URLRequestSummary main_frame =
433 1, 1, "http://www.google.com", "http://www.google.com", 516 CreateURLRequestSummary(1, 1, "http://www.google.com");
434 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false);
435 predictor_->RecordURLRequest(main_frame); 517 predictor_->RecordURLRequest(main_frame);
436 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 518 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
437 519
520 URLRequestSummary main_frame_redirect = CreateRedirectRequestSummary(
521 1, 1, "http://www.google.com", "https://www.google.com");
522 predictor_->RecordURLRedirect(main_frame_redirect);
523 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
524 main_frame = CreateURLRequestSummary(1, 1, "https://www.google.com");
525
438 // Now add a few subresources. 526 // Now add a few subresources.
439 URLRequestSummary resource1 = CreateURLRequestSummary( 527 URLRequestSummary resource1 = CreateURLRequestSummary(
440 1, 1, "http://www.google.com", "http://google.com/style1.css", 528 1, 1, "https://www.google.com", "https://google.com/style1.css",
441 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false); 529 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false);
442 predictor_->RecordURLResponse(resource1); 530 predictor_->RecordURLResponse(resource1);
443 URLRequestSummary resource2 = CreateURLRequestSummary( 531 URLRequestSummary resource2 = CreateURLRequestSummary(
444 1, 1, "http://www.google.com", "http://google.com/script1.js", 532 1, 1, "https://www.google.com", "https://google.com/script1.js",
445 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false); 533 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false);
446 predictor_->RecordURLResponse(resource2); 534 predictor_->RecordURLResponse(resource2);
447 URLRequestSummary resource3 = CreateURLRequestSummary( 535 URLRequestSummary resource3 = CreateURLRequestSummary(
448 1, 1, "http://www.google.com", "http://google.com/script2.js", 536 1, 1, "https://www.google.com", "https://google.com/script2.js",
449 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false); 537 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false);
450 predictor_->RecordURLResponse(resource3); 538 predictor_->RecordURLResponse(resource3);
451 539
452 PrefetchData host_data(PREFETCH_KEY_TYPE_HOST, "www.google.com"); 540 PrefetchData host_data(PREFETCH_KEY_TYPE_HOST, "www.google.com");
453 host_data.resources.push_back(ResourceRow( 541 host_data.resources.push_back(ResourceRow(
454 "http://google.com/style1.css", content::RESOURCE_TYPE_STYLESHEET, 1, 0, 542 "https://google.com/style1.css", content::RESOURCE_TYPE_STYLESHEET, 1, 0,
455 0, 1.0, net::MEDIUM, false, false)); 543 0, 1.0, net::MEDIUM, false, false));
456 host_data.resources.push_back(ResourceRow("http://google.com/script1.js", 544 host_data.resources.push_back(ResourceRow("https://google.com/script1.js",
457 content::RESOURCE_TYPE_SCRIPT, 1, 0, 545 content::RESOURCE_TYPE_SCRIPT, 1, 0,
458 0, 2.0, net::MEDIUM, false, false)); 546 0, 2.0, net::MEDIUM, false, false));
459 host_data.resources.push_back(ResourceRow("http://google.com/script2.js", 547 host_data.resources.push_back(ResourceRow("https://google.com/script2.js",
460 content::RESOURCE_TYPE_SCRIPT, 1, 0, 548 content::RESOURCE_TYPE_SCRIPT, 1, 0,
461 0, 3.0, net::MEDIUM, false, false)); 549 0, 3.0, net::MEDIUM, false, false));
462 EXPECT_CALL(*mock_tables_.get(), UpdateData(empty_url_data_, host_data)); 550 EXPECT_CALL(*mock_tables_.get(),
551 UpdateData(empty_url_data_, host_data, empty_url_redirect_data_,
552 empty_host_redirect_data_));
463 553
464 predictor_->OnNavigationComplete(main_frame.navigation_id); 554 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id);
465 profile_->BlockUntilHistoryProcessesPendingRequests(); 555 profile_->BlockUntilHistoryProcessesPendingRequests();
466 } 556 }
467 557
468 TEST_F(ResourcePrefetchPredictorTest, NavigationUrlNotInDB) { 558 TEST_F(ResourcePrefetchPredictorTest, NavigationUrlNotInDB) {
469 // Single navigation that will be recorded. Will check for duplicate 559 // Single navigation that will be recorded. Will check for duplicate
470 // resources and also for number of resources saved. 560 // resources and also for number of resources saved.
471 AddUrlToHistory("http://www.google.com", 4); 561 AddUrlToHistory("http://www.google.com", 4);
472 562
473 URLRequestSummary main_frame = CreateURLRequestSummary( 563 URLRequestSummary main_frame =
474 1, 1, "http://www.google.com", "http://www.google.com", 564 CreateURLRequestSummary(1, 1, "http://www.google.com");
475 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false);
476 predictor_->RecordURLRequest(main_frame); 565 predictor_->RecordURLRequest(main_frame);
477 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 566 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
478 567
479 URLRequestSummary resource1 = CreateURLRequestSummary( 568 URLRequestSummary resource1 = CreateURLRequestSummary(
480 1, 1, "http://www.google.com", "http://google.com/style1.css", 569 1, 1, "http://www.google.com", "http://google.com/style1.css",
481 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false); 570 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false);
482 predictor_->RecordURLResponse(resource1); 571 predictor_->RecordURLResponse(resource1);
483 URLRequestSummary resource2 = CreateURLRequestSummary( 572 URLRequestSummary resource2 = CreateURLRequestSummary(
484 1, 1, "http://www.google.com", "http://google.com/script1.js", 573 1, 1, "http://www.google.com", "http://google.com/script1.js",
485 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false); 574 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false);
(...skipping 25 matching lines...) Expand all
511 0, 1.0, net::MEDIUM, false, false)); 600 0, 1.0, net::MEDIUM, false, false));
512 url_data.resources.push_back(ResourceRow("http://google.com/script1.js", 601 url_data.resources.push_back(ResourceRow("http://google.com/script1.js",
513 content::RESOURCE_TYPE_SCRIPT, 1, 0, 602 content::RESOURCE_TYPE_SCRIPT, 1, 0,
514 0, 2.0, net::MEDIUM, false, false)); 603 0, 2.0, net::MEDIUM, false, false));
515 url_data.resources.push_back(ResourceRow("http://google.com/script2.js", 604 url_data.resources.push_back(ResourceRow("http://google.com/script2.js",
516 content::RESOURCE_TYPE_SCRIPT, 1, 0, 605 content::RESOURCE_TYPE_SCRIPT, 1, 0,
517 0, 3.0, net::MEDIUM, false, false)); 606 0, 3.0, net::MEDIUM, false, false));
518 url_data.resources.push_back(ResourceRow( 607 url_data.resources.push_back(ResourceRow(
519 "http://google.com/style2.css", content::RESOURCE_TYPE_STYLESHEET, 1, 0, 608 "http://google.com/style2.css", content::RESOURCE_TYPE_STYLESHEET, 1, 0,
520 0, 7.0, net::MEDIUM, false, false)); 609 0, 7.0, net::MEDIUM, false, false));
521 EXPECT_CALL(*mock_tables_.get(), UpdateData(url_data, empty_host_data_)); 610 EXPECT_CALL(*mock_tables_.get(),
611 UpdateData(url_data, empty_host_data_, empty_url_redirect_data_,
612 empty_host_redirect_data_));
522 613
523 PrefetchData host_data(PREFETCH_KEY_TYPE_HOST, "www.google.com"); 614 PrefetchData host_data(PREFETCH_KEY_TYPE_HOST, "www.google.com");
524 host_data.resources = url_data.resources; 615 host_data.resources = url_data.resources;
525 EXPECT_CALL(*mock_tables_.get(), UpdateData(empty_url_data_, host_data)); 616 EXPECT_CALL(*mock_tables_.get(),
617 UpdateData(empty_url_data_, host_data, empty_url_redirect_data_,
618 empty_host_redirect_data_));
526 619
527 predictor_->OnNavigationComplete(main_frame.navigation_id); 620 predictor_->OnNavigationComplete(main_frame.navigation_id);
528 profile_->BlockUntilHistoryProcessesPendingRequests(); 621 profile_->BlockUntilHistoryProcessesPendingRequests();
529 } 622 }
530 623
531 TEST_F(ResourcePrefetchPredictorTest, NavigationUrlInDB) { 624 TEST_F(ResourcePrefetchPredictorTest, NavigationUrlInDB) {
532 // Tests that navigation is recorded correctly for URL already present in 625 // Tests that navigation is recorded correctly for URL already present in
533 // the database cache. 626 // the database cache.
534 AddUrlToHistory("http://www.google.com", 4); 627 AddUrlToHistory("http://www.google.com", 4);
535 628
536 EXPECT_CALL(*mock_tables_.get(), 629 EXPECT_CALL(*mock_tables_.get(),
537 GetAllData(Pointee(ContainerEq(PrefetchDataMap())), 630 GetAllData(Pointee(ContainerEq(PrefetchDataMap())),
538 Pointee(ContainerEq(PrefetchDataMap())))) 631 Pointee(ContainerEq(PrefetchDataMap())),
632 Pointee(ContainerEq(RedirectDataMap())),
633 Pointee(ContainerEq(RedirectDataMap()))))
539 .WillOnce(DoAll(SetArgPointee<0>(test_url_data_), 634 .WillOnce(DoAll(SetArgPointee<0>(test_url_data_),
540 SetArgPointee<1>(test_host_data_))); 635 SetArgPointee<1>(test_host_data_)));
541 ResetPredictor(); 636 ResetPredictor();
542 InitializePredictor(); 637 InitializePredictor();
543 EXPECT_EQ(3U, predictor_->url_table_cache_->size()); 638 EXPECT_EQ(3U, predictor_->url_table_cache_->size());
544 EXPECT_EQ(2U, predictor_->host_table_cache_->size()); 639 EXPECT_EQ(2U, predictor_->host_table_cache_->size());
545 640
546 URLRequestSummary main_frame = CreateURLRequestSummary( 641 URLRequestSummary main_frame = CreateURLRequestSummary(
547 1, 1, "http://www.google.com", "http://www.google.com", 642 1, 1, "http://www.google.com", "http://www.google.com",
548 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false); 643 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 0, 1.0, net::MEDIUM, false, false)); 679 0, 1.0, net::MEDIUM, false, false));
585 url_data.resources.push_back(ResourceRow("http://google.com/script1.js", 680 url_data.resources.push_back(ResourceRow("http://google.com/script1.js",
586 content::RESOURCE_TYPE_SCRIPT, 1, 0, 681 content::RESOURCE_TYPE_SCRIPT, 1, 0,
587 0, 2.0, net::MEDIUM, false, false)); 682 0, 2.0, net::MEDIUM, false, false));
588 url_data.resources.push_back(ResourceRow("http://google.com/script4.js", 683 url_data.resources.push_back(ResourceRow("http://google.com/script4.js",
589 content::RESOURCE_TYPE_SCRIPT, 11, 1, 684 content::RESOURCE_TYPE_SCRIPT, 11, 1,
590 1, 2.1, net::MEDIUM, false, false)); 685 1, 2.1, net::MEDIUM, false, false));
591 url_data.resources.push_back(ResourceRow("http://google.com/script2.js", 686 url_data.resources.push_back(ResourceRow("http://google.com/script2.js",
592 content::RESOURCE_TYPE_SCRIPT, 1, 0, 687 content::RESOURCE_TYPE_SCRIPT, 1, 0,
593 0, 3.0, net::MEDIUM, false, false)); 688 0, 3.0, net::MEDIUM, false, false));
594 EXPECT_CALL(*mock_tables_.get(), UpdateData(url_data, empty_host_data_)); 689 EXPECT_CALL(*mock_tables_.get(),
690 UpdateData(url_data, empty_host_data_, empty_url_redirect_data_,
691 empty_host_redirect_data_));
595 692
596 EXPECT_CALL( 693 EXPECT_CALL(*mock_tables_.get(),
597 *mock_tables_.get(), 694 DeleteSingleResourceDataPoint("www.facebook.com",
598 DeleteSingleDataPoint("www.facebook.com", PREFETCH_KEY_TYPE_HOST)); 695 PREFETCH_KEY_TYPE_HOST));
599 696
600 PrefetchData host_data(PREFETCH_KEY_TYPE_HOST, "www.google.com"); 697 PrefetchData host_data(PREFETCH_KEY_TYPE_HOST, "www.google.com");
601 host_data.resources.push_back(ResourceRow( 698 host_data.resources.push_back(ResourceRow(
602 "http://google.com/style1.css", content::RESOURCE_TYPE_STYLESHEET, 1, 0, 699 "http://google.com/style1.css", content::RESOURCE_TYPE_STYLESHEET, 1, 0,
603 0, 1.0, net::MEDIUM, false, false)); 700 0, 1.0, net::MEDIUM, false, false));
604 host_data.resources.push_back(ResourceRow("http://google.com/script1.js", 701 host_data.resources.push_back(ResourceRow("http://google.com/script1.js",
605 content::RESOURCE_TYPE_SCRIPT, 1, 0, 702 content::RESOURCE_TYPE_SCRIPT, 1, 0,
606 0, 2.0, net::MEDIUM, false, false)); 703 0, 2.0, net::MEDIUM, false, false));
607 host_data.resources.push_back(ResourceRow("http://google.com/script2.js", 704 host_data.resources.push_back(ResourceRow("http://google.com/script2.js",
608 content::RESOURCE_TYPE_SCRIPT, 1, 0, 705 content::RESOURCE_TYPE_SCRIPT, 1, 0,
609 0, 3.0, net::MEDIUM, false, false)); 706 0, 3.0, net::MEDIUM, false, false));
610 host_data.resources.push_back(ResourceRow( 707 host_data.resources.push_back(ResourceRow(
611 "http://google.com/style2.css", content::RESOURCE_TYPE_STYLESHEET, 1, 0, 708 "http://google.com/style2.css", content::RESOURCE_TYPE_STYLESHEET, 1, 0,
612 0, 7.0, net::MEDIUM, false, false)); 709 0, 7.0, net::MEDIUM, false, false));
613 EXPECT_CALL(*mock_tables_.get(), UpdateData(empty_url_data_, host_data)); 710 EXPECT_CALL(*mock_tables_.get(),
711 UpdateData(empty_url_data_, host_data, empty_url_redirect_data_,
712 empty_host_redirect_data_));
614 713
615 predictor_->OnNavigationComplete(main_frame.navigation_id); 714 predictor_->OnNavigationComplete(main_frame.navigation_id);
616 profile_->BlockUntilHistoryProcessesPendingRequests(); 715 profile_->BlockUntilHistoryProcessesPendingRequests();
617 } 716 }
618 717
619 TEST_F(ResourcePrefetchPredictorTest, NavigationUrlNotInDBAndDBFull) { 718 TEST_F(ResourcePrefetchPredictorTest, NavigationUrlNotInDBAndDBFull) {
620 // Tests that a URL is deleted before another is added if the cache is full. 719 // Tests that a URL is deleted before another is added if the cache is full.
621 AddUrlToHistory("http://www.nike.com/", 4); 720 AddUrlToHistory("http://www.nike.com/", 4);
622 721
623 EXPECT_CALL(*mock_tables_.get(), 722 EXPECT_CALL(*mock_tables_.get(),
624 GetAllData(Pointee(ContainerEq(PrefetchDataMap())), 723 GetAllData(Pointee(ContainerEq(PrefetchDataMap())),
625 Pointee(ContainerEq(PrefetchDataMap())))) 724 Pointee(ContainerEq(PrefetchDataMap())),
725 Pointee(ContainerEq(RedirectDataMap())),
726 Pointee(ContainerEq(RedirectDataMap()))))
626 .WillOnce(DoAll(SetArgPointee<0>(test_url_data_), 727 .WillOnce(DoAll(SetArgPointee<0>(test_url_data_),
627 SetArgPointee<1>(test_host_data_))); 728 SetArgPointee<1>(test_host_data_)));
628 ResetPredictor(); 729 ResetPredictor();
629 InitializePredictor(); 730 InitializePredictor();
630 EXPECT_EQ(3U, predictor_->url_table_cache_->size()); 731 EXPECT_EQ(3U, predictor_->url_table_cache_->size());
631 EXPECT_EQ(2U, predictor_->host_table_cache_->size()); 732 EXPECT_EQ(2U, predictor_->host_table_cache_->size());
632 733
633 URLRequestSummary main_frame = CreateURLRequestSummary( 734 URLRequestSummary main_frame = CreateURLRequestSummary(
634 1, 1, "http://www.nike.com", "http://www.nike.com", 735 1, 1, "http://www.nike.com", "http://www.nike.com",
635 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false); 736 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false);
636 predictor_->RecordURLRequest(main_frame); 737 predictor_->RecordURLRequest(main_frame);
637 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 738 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
638 739
639 URLRequestSummary resource1 = CreateURLRequestSummary( 740 URLRequestSummary resource1 = CreateURLRequestSummary(
640 1, 1, "http://www.nike.com", "http://nike.com/style1.css", 741 1, 1, "http://www.nike.com", "http://nike.com/style1.css",
641 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false); 742 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false);
642 predictor_->RecordURLResponse(resource1); 743 predictor_->RecordURLResponse(resource1);
643 URLRequestSummary resource2 = CreateURLRequestSummary( 744 URLRequestSummary resource2 = CreateURLRequestSummary(
644 1, 1, "http://www.nike.com", "http://nike.com/image2.png", 745 1, 1, "http://www.nike.com", "http://nike.com/image2.png",
645 content::RESOURCE_TYPE_IMAGE, net::MEDIUM, "image/png", false); 746 content::RESOURCE_TYPE_IMAGE, net::MEDIUM, "image/png", false);
646 predictor_->RecordURLResponse(resource2); 747 predictor_->RecordURLResponse(resource2);
647 748
648 EXPECT_CALL( 749 EXPECT_CALL(*mock_tables_.get(),
649 *mock_tables_.get(), 750 DeleteSingleResourceDataPoint("http://www.google.com/",
650 DeleteSingleDataPoint("http://www.google.com/", PREFETCH_KEY_TYPE_URL)); 751 PREFETCH_KEY_TYPE_URL));
651 EXPECT_CALL( 752 EXPECT_CALL(*mock_tables_.get(),
652 *mock_tables_.get(), 753 DeleteSingleResourceDataPoint("www.facebook.com",
653 DeleteSingleDataPoint("www.facebook.com", PREFETCH_KEY_TYPE_HOST)); 754 PREFETCH_KEY_TYPE_HOST));
654 755
655 PrefetchData url_data(PREFETCH_KEY_TYPE_URL, "http://www.nike.com/"); 756 PrefetchData url_data(PREFETCH_KEY_TYPE_URL, "http://www.nike.com/");
656 url_data.resources.push_back(ResourceRow( 757 url_data.resources.push_back(ResourceRow(
657 "http://nike.com/style1.css", content::RESOURCE_TYPE_STYLESHEET, 1, 0, 0, 758 "http://nike.com/style1.css", content::RESOURCE_TYPE_STYLESHEET, 1, 0, 0,
658 1.0, net::MEDIUM, false, false)); 759 1.0, net::MEDIUM, false, false));
659 url_data.resources.push_back(ResourceRow("http://nike.com/image2.png", 760 url_data.resources.push_back(ResourceRow("http://nike.com/image2.png",
660 content::RESOURCE_TYPE_IMAGE, 1, 0, 761 content::RESOURCE_TYPE_IMAGE, 1, 0,
661 0, 2.0, net::MEDIUM, false, false)); 762 0, 2.0, net::MEDIUM, false, false));
662 EXPECT_CALL(*mock_tables_.get(), UpdateData(url_data, empty_host_data_)); 763 EXPECT_CALL(*mock_tables_.get(),
764 UpdateData(url_data, empty_host_data_, empty_url_redirect_data_,
765 empty_host_redirect_data_));
663 766
664 PrefetchData host_data(PREFETCH_KEY_TYPE_HOST, "www.nike.com"); 767 PrefetchData host_data(PREFETCH_KEY_TYPE_HOST, "www.nike.com");
665 host_data.resources = url_data.resources; 768 host_data.resources = url_data.resources;
666 EXPECT_CALL(*mock_tables_.get(), UpdateData(empty_url_data_, host_data)); 769 EXPECT_CALL(*mock_tables_.get(),
770 UpdateData(empty_url_data_, host_data, empty_url_redirect_data_,
771 empty_host_redirect_data_));
667 772
668 predictor_->OnNavigationComplete(main_frame.navigation_id); 773 predictor_->OnNavigationComplete(main_frame.navigation_id);
669 profile_->BlockUntilHistoryProcessesPendingRequests(); 774 profile_->BlockUntilHistoryProcessesPendingRequests();
670 } 775 }
671 776
777 TEST_F(ResourcePrefetchPredictorTest, RedirectUrlNotInDB) {
778 AddUrlToHistory("https://facebook.com/google", 4);
779
780 URLRequestSummary fb1 = CreateURLRequestSummary(1, 1, "http://fb.com/google");
781 predictor_->RecordURLRequest(fb1);
782 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
783
784 URLRequestSummary fb2 = CreateRedirectRequestSummary(
785 1, 1, "http://fb.com/google", "http://facebook.com/google");
786 predictor_->RecordURLRedirect(fb2);
787 URLRequestSummary fb3 = CreateRedirectRequestSummary(
788 1, 1, "http://facebook.com/google", "https://facebook.com/google");
789 predictor_->RecordURLRedirect(fb3);
790 NavigationID fb_end = CreateNavigationID(1, 1, "https://facebook.com/google");
791
792 // Since the navigation hasn't resources, corresponding entry
793 // in resource table will be deleted
794 EXPECT_CALL(*mock_tables_.get(),
795 DeleteSingleResourceDataPoint("https://facebook.com/google",
796 PREFETCH_KEY_TYPE_URL));
797 EXPECT_CALL(*mock_tables_.get(), DeleteSingleResourceDataPoint(
798 "facebook.com", PREFETCH_KEY_TYPE_HOST));
799
800 RedirectData url_redirect_data(PREFETCH_KEY_TYPE_URL, "http://fb.com/google");
801 url_redirect_data.redirects.push_back(
802 RedirectRow("https://facebook.com/google", 1, 0, 0));
803 EXPECT_CALL(*mock_tables_.get(),
804 UpdateData(empty_url_data_, empty_host_data_, url_redirect_data,
805 empty_host_redirect_data_));
806
807 RedirectData host_redirect_data(PREFETCH_KEY_TYPE_HOST, "fb.com");
808 host_redirect_data.redirects.push_back(RedirectRow("facebook.com", 1, 0, 0));
809 EXPECT_CALL(*mock_tables_.get(),
810 UpdateData(empty_url_data_, empty_host_data_,
811 empty_url_redirect_data_, host_redirect_data));
812
813 predictor_->RecordMainFrameLoadComplete(fb_end);
814 profile_->BlockUntilHistoryProcessesPendingRequests();
815 }
816
817 TEST_F(ResourcePrefetchPredictorTest, RedirectUrlInDB) {
818 // Tests that redirect is recorded correctly for URL already present in
819 // the database cache.
820 AddUrlToHistory("https://facebook.com/google", 4);
821
822 EXPECT_CALL(*mock_tables_.get(),
823 GetAllData(Pointee(ContainerEq(PrefetchDataMap())),
824 Pointee(ContainerEq(PrefetchDataMap())),
825 Pointee(ContainerEq(RedirectDataMap())),
826 Pointee(ContainerEq(RedirectDataMap()))))
827 .WillOnce(DoAll(SetArgPointee<2>(test_url_redirect_data_),
828 SetArgPointee<3>(test_host_redirect_data_)));
829 ResetPredictor();
830 InitializePredictor();
831 EXPECT_EQ(3U, predictor_->url_redirect_table_cache_->size());
832 EXPECT_EQ(2U, predictor_->host_redirect_table_cache_->size());
833
834 URLRequestSummary fb1 = CreateURLRequestSummary(1, 1, "http://fb.com/google");
835 predictor_->RecordURLRequest(fb1);
836 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
837
838 URLRequestSummary fb2 = CreateRedirectRequestSummary(
839 1, 1, "http://fb.com/google", "http://facebook.com/google");
840 predictor_->RecordURLRedirect(fb2);
841 URLRequestSummary fb3 = CreateRedirectRequestSummary(
842 1, 1, "http://facebook.com/google", "https://facebook.com/google");
843 predictor_->RecordURLRedirect(fb3);
844 NavigationID fb_end = CreateNavigationID(1, 1, "https://facebook.com/google");
845
846 // Oldest entries in tables will be superseded and deleted
847 EXPECT_CALL(*mock_tables_.get(),
848 DeleteSingleRedirectDataPoint("bbc.com", PREFETCH_KEY_TYPE_HOST));
849
850 // Since the navigation hasn't resources, corresponding entry
851 // in resource table will be deleted
852 EXPECT_CALL(*mock_tables_.get(),
853 DeleteSingleResourceDataPoint("https://facebook.com/google",
854 PREFETCH_KEY_TYPE_URL));
855 EXPECT_CALL(*mock_tables_.get(), DeleteSingleResourceDataPoint(
856 "facebook.com", PREFETCH_KEY_TYPE_HOST));
857
858 RedirectData url_redirect_data(PREFETCH_KEY_TYPE_URL, "http://fb.com/google");
859 url_redirect_data.redirects.push_back(
860 RedirectRow("https://facebook.com/google", 6, 1, 0));
861 // Exising redirect to https://facebook.com/login will be deleted because of
862 // too many consecutive misses.
863 EXPECT_CALL(*mock_tables_.get(),
864 UpdateData(empty_url_data_, empty_host_data_, url_redirect_data,
865 empty_host_redirect_data_));
866
867 RedirectData host_redirect_data(PREFETCH_KEY_TYPE_HOST, "fb.com");
868 host_redirect_data.redirects.push_back(RedirectRow("facebook.com", 1, 0, 0));
869 EXPECT_CALL(*mock_tables_.get(),
870 UpdateData(empty_url_data_, empty_host_data_,
871 empty_url_redirect_data_, host_redirect_data));
872
873 predictor_->RecordMainFrameLoadComplete(fb_end);
874 profile_->BlockUntilHistoryProcessesPendingRequests();
875 }
876
672 TEST_F(ResourcePrefetchPredictorTest, DeleteUrls) { 877 TEST_F(ResourcePrefetchPredictorTest, DeleteUrls) {
673 // Add some dummy entries to cache. 878 // Add some dummy entries to cache.
674 predictor_->url_table_cache_->insert(std::make_pair( 879 predictor_->url_table_cache_->insert(std::make_pair(
675 "http://www.google.com/page1.html", 880 "http://www.google.com/page1.html",
676 PrefetchData(PREFETCH_KEY_TYPE_URL, "http://www.google.com/page1.html"))); 881 PrefetchData(PREFETCH_KEY_TYPE_URL, "http://www.google.com/page1.html")));
677 predictor_->url_table_cache_->insert(std::make_pair( 882 predictor_->url_table_cache_->insert(std::make_pair(
678 "http://www.google.com/page2.html", 883 "http://www.google.com/page2.html",
679 PrefetchData(PREFETCH_KEY_TYPE_URL, "http://www.google.com/page2.html"))); 884 PrefetchData(PREFETCH_KEY_TYPE_URL, "http://www.google.com/page2.html")));
680 predictor_->url_table_cache_->insert(std::make_pair( 885 predictor_->url_table_cache_->insert(std::make_pair(
681 "http://www.yahoo.com/", 886 "http://www.yahoo.com/",
(...skipping 20 matching lines...) Expand all
702 rows.push_back(history::URLRow(GURL("http://www.apple.com"))); 907 rows.push_back(history::URLRow(GURL("http://www.apple.com")));
703 rows.push_back(history::URLRow(GURL("http://www.nike.com"))); 908 rows.push_back(history::URLRow(GURL("http://www.nike.com")));
704 909
705 std::vector<std::string> urls_to_delete, hosts_to_delete; 910 std::vector<std::string> urls_to_delete, hosts_to_delete;
706 urls_to_delete.push_back("http://www.google.com/page2.html"); 911 urls_to_delete.push_back("http://www.google.com/page2.html");
707 urls_to_delete.push_back("http://www.apple.com/"); 912 urls_to_delete.push_back("http://www.apple.com/");
708 urls_to_delete.push_back("http://www.nike.com/"); 913 urls_to_delete.push_back("http://www.nike.com/");
709 hosts_to_delete.push_back("www.google.com"); 914 hosts_to_delete.push_back("www.google.com");
710 hosts_to_delete.push_back("www.apple.com"); 915 hosts_to_delete.push_back("www.apple.com");
711 916
712 EXPECT_CALL( 917 EXPECT_CALL(*mock_tables_.get(),
713 *mock_tables_.get(), 918 DeleteResourceData(ContainerEq(urls_to_delete),
714 DeleteData(ContainerEq(urls_to_delete), ContainerEq(hosts_to_delete))); 919 ContainerEq(hosts_to_delete)));
715 920
716 predictor_->DeleteUrls(rows); 921 predictor_->DeleteUrls(rows);
717 EXPECT_EQ(2U, predictor_->url_table_cache_->size()); 922 EXPECT_EQ(2U, predictor_->url_table_cache_->size());
718 EXPECT_EQ(1U, predictor_->host_table_cache_->size()); 923 EXPECT_EQ(1U, predictor_->host_table_cache_->size());
719 924
720 EXPECT_CALL(*mock_tables_.get(), DeleteAllData()); 925 EXPECT_CALL(*mock_tables_.get(), DeleteAllData());
721 926
722 predictor_->DeleteAllUrls(); 927 predictor_->DeleteAllUrls();
723 EXPECT_TRUE(predictor_->url_table_cache_->empty()); 928 EXPECT_TRUE(predictor_->url_table_cache_->empty());
724 EXPECT_TRUE(predictor_->host_table_cache_->empty()); 929 EXPECT_TRUE(predictor_->host_table_cache_->empty());
(...skipping 10 matching lines...) Expand all
735 2, 1, "http://www.yahoo.com", "http://www.yahoo.com", 940 2, 1, "http://www.yahoo.com", "http://www.yahoo.com",
736 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false); 941 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false);
737 942
738 predictor_->OnMainFrameRequest(summary1); 943 predictor_->OnMainFrameRequest(summary1);
739 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 944 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
740 predictor_->OnMainFrameRequest(summary2); 945 predictor_->OnMainFrameRequest(summary2);
741 EXPECT_EQ(2U, predictor_->inflight_navigations_.size()); 946 EXPECT_EQ(2U, predictor_->inflight_navigations_.size());
742 predictor_->OnMainFrameRequest(summary3); 947 predictor_->OnMainFrameRequest(summary3);
743 EXPECT_EQ(3U, predictor_->inflight_navigations_.size()); 948 EXPECT_EQ(3U, predictor_->inflight_navigations_.size());
744 949
745 // Insert anther with same navigation id. It should replace. 950 // Insert another with same navigation id. It should replace.
746 URLRequestSummary summary4 = CreateURLRequestSummary( 951 URLRequestSummary summary4 = CreateURLRequestSummary(
747 1, 1, "http://www.nike.com", "http://www.nike.com", 952 1, 1, "http://www.nike.com", "http://www.nike.com",
748 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false); 953 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false);
749 URLRequestSummary summary5 = CreateURLRequestSummary( 954 URLRequestSummary summary5 = CreateURLRequestSummary(
750 1, 2, "http://www.google.com", "http://www.google.com", 955 1, 2, "http://www.google.com", "http://www.google.com",
751 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false); 956 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false);
752 957
753 predictor_->OnMainFrameRequest(summary4); 958 predictor_->OnMainFrameRequest(summary4);
754 EXPECT_EQ(3U, predictor_->inflight_navigations_.size()); 959 EXPECT_EQ(3U, predictor_->inflight_navigations_.size());
755 960
(...skipping 11 matching lines...) Expand all
767 972
768 EXPECT_TRUE(predictor_->inflight_navigations_.find(summary3.navigation_id) != 973 EXPECT_TRUE(predictor_->inflight_navigations_.find(summary3.navigation_id) !=
769 predictor_->inflight_navigations_.end()); 974 predictor_->inflight_navigations_.end());
770 EXPECT_TRUE(predictor_->inflight_navigations_.find(summary4.navigation_id) != 975 EXPECT_TRUE(predictor_->inflight_navigations_.find(summary4.navigation_id) !=
771 predictor_->inflight_navigations_.end()); 976 predictor_->inflight_navigations_.end());
772 EXPECT_TRUE(predictor_->inflight_navigations_.find(summary6.navigation_id) != 977 EXPECT_TRUE(predictor_->inflight_navigations_.find(summary6.navigation_id) !=
773 predictor_->inflight_navigations_.end()); 978 predictor_->inflight_navigations_.end());
774 } 979 }
775 980
776 TEST_F(ResourcePrefetchPredictorTest, OnMainFrameRedirect) { 981 TEST_F(ResourcePrefetchPredictorTest, OnMainFrameRedirect) {
777 URLRequestSummary summary1 = CreateURLRequestSummary( 982 URLRequestSummary yahoo = CreateURLRequestSummary(1, 1, "http://yahoo.com");
778 1, 1, "http://www.google.com", "http://www.google.com",
779 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false);
780 URLRequestSummary summary2 = CreateURLRequestSummary(
781 1, 2, "http://www.google.com", "http://www.google.com",
782 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false);
783 URLRequestSummary summary3 = CreateURLRequestSummary(
784 2, 1, "http://www.yahoo.com", "http://www.yahoo.com",
785 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false);
786 983
787 predictor_->OnMainFrameRedirect(summary1); 984 URLRequestSummary bbc1 = CreateURLRequestSummary(2, 2, "http://bbc.com");
985 URLRequestSummary bbc2 = CreateRedirectRequestSummary(2, 2, "http://bbc.com",
986 "https://www.bbc.com");
987 NavigationID bbc_end = CreateNavigationID(2, 2, "https://www.bbc.com");
988
989 URLRequestSummary youtube1 =
990 CreateURLRequestSummary(1, 2, "http://youtube.com");
991 URLRequestSummary youtube2 = CreateRedirectRequestSummary(
992 1, 2, "http://youtube.com", "https://youtube.com");
993 NavigationID youtube_end = CreateNavigationID(1, 2, "https://youtube.com");
994
995 URLRequestSummary nyt1 = CreateURLRequestSummary(2, 1, "http://nyt.com");
996 URLRequestSummary nyt2 = CreateRedirectRequestSummary(2, 1, "http://nyt.com",
997 "http://nytimes.com");
998 URLRequestSummary nyt3 = CreateRedirectRequestSummary(
999 2, 1, "http://nytimes.com", "http://m.nytimes.com");
1000 NavigationID nyt_end = CreateNavigationID(2, 1, "http://m.nytimes.com");
1001
1002 URLRequestSummary fb1 = CreateURLRequestSummary(1, 3, "http://fb.com");
1003 URLRequestSummary fb2 = CreateRedirectRequestSummary(1, 3, "http://fb.com",
1004 "http://facebook.com");
1005 URLRequestSummary fb3 = CreateRedirectRequestSummary(
1006 1, 3, "http://facebook.com", "https://facebook.com");
1007 URLRequestSummary fb4 = CreateRedirectRequestSummary(
1008 1, 3, "https://facebook.com",
1009 "https://m.facebook.com/?refsrc=https%3A%2F%2Fwww.facebook.com%2F&_rdr");
1010 NavigationID fb_end = CreateNavigationID(
1011 1, 3,
1012 "https://m.facebook.com/?refsrc=https%3A%2F%2Fwww.facebook.com%2F&_rdr");
1013
1014 // Redirect with empty redirect_url will be deleted
1015 predictor_->OnMainFrameRequest(yahoo);
1016 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
1017 predictor_->OnMainFrameRedirect(yahoo);
788 EXPECT_TRUE(predictor_->inflight_navigations_.empty()); 1018 EXPECT_TRUE(predictor_->inflight_navigations_.empty());
789 1019
790 predictor_->OnMainFrameRequest(summary1); 1020 // Redirect without previous request works fine
1021 // predictor_->OnMainFrameRequest(bbc1) missing
1022 predictor_->OnMainFrameRedirect(bbc2);
791 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 1023 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
792 predictor_->OnMainFrameRequest(summary2); 1024 EXPECT_EQ(bbc1.navigation_id.main_frame_url,
1025 predictor_->inflight_navigations_[bbc_end]->initial_url);
1026
1027 // http://youtube.com -> https://youtube.com
1028 predictor_->OnMainFrameRequest(youtube1);
793 EXPECT_EQ(2U, predictor_->inflight_navigations_.size()); 1029 EXPECT_EQ(2U, predictor_->inflight_navigations_.size());
1030 predictor_->OnMainFrameRedirect(youtube2);
1031 EXPECT_EQ(2U, predictor_->inflight_navigations_.size());
1032 EXPECT_EQ(youtube1.navigation_id.main_frame_url,
1033 predictor_->inflight_navigations_[youtube_end]->initial_url);
794 1034
795 predictor_->OnMainFrameRedirect(summary3); 1035 // http://nyt.com -> http://nytimes.com -> http://m.nytimes.com
796 EXPECT_EQ(2U, predictor_->inflight_navigations_.size()); 1036 predictor_->OnMainFrameRequest(nyt1);
797 predictor_->OnMainFrameRedirect(summary1); 1037 EXPECT_EQ(3U, predictor_->inflight_navigations_.size());
798 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 1038 predictor_->OnMainFrameRedirect(nyt2);
799 predictor_->OnMainFrameRedirect(summary2); 1039 predictor_->OnMainFrameRedirect(nyt3);
800 EXPECT_TRUE(predictor_->inflight_navigations_.empty()); 1040 EXPECT_EQ(3U, predictor_->inflight_navigations_.size());
1041 EXPECT_EQ(nyt1.navigation_id.main_frame_url,
1042 predictor_->inflight_navigations_[nyt_end]->initial_url);
1043
1044 // http://fb.com -> http://facebook.com -> https://facebook.com ->
1045 // https://m.facebook.com/?refsrc=https%3A%2F%2Fwww.facebook.com%2F&_rdr
1046 predictor_->OnMainFrameRequest(fb1);
1047 EXPECT_EQ(4U, predictor_->inflight_navigations_.size());
1048 predictor_->OnMainFrameRedirect(fb2);
1049 predictor_->OnMainFrameRedirect(fb3);
1050 predictor_->OnMainFrameRedirect(fb4);
1051 EXPECT_EQ(4U, predictor_->inflight_navigations_.size());
1052 EXPECT_EQ(fb1.navigation_id.main_frame_url,
1053 predictor_->inflight_navigations_[fb_end]->initial_url);
801 } 1054 }
802 1055
803 TEST_F(ResourcePrefetchPredictorTest, OnSubresourceResponse) { 1056 TEST_F(ResourcePrefetchPredictorTest, OnSubresourceResponse) {
804 // If there is no inflight navigation, nothing happens. 1057 // If there is no inflight navigation, nothing happens.
805 URLRequestSummary resource1 = CreateURLRequestSummary( 1058 URLRequestSummary resource1 = CreateURLRequestSummary(
806 1, 1, "http://www.google.com", "http://google.com/style1.css", 1059 1, 1, "http://www.google.com", "http://google.com/style1.css",
807 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false); 1060 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false);
808 predictor_->OnSubresourceResponse(resource1); 1061 predictor_->OnSubresourceResponse(resource1);
809 EXPECT_TRUE(predictor_->inflight_navigations_.empty()); 1062 EXPECT_TRUE(predictor_->inflight_navigations_.empty());
810 1063
811 // Add an inflight navigation. 1064 // Add an inflight navigation.
812 URLRequestSummary main_frame1 = CreateURLRequestSummary( 1065 URLRequestSummary main_frame1 = CreateURLRequestSummary(
813 1, 1, "http://www.google.com", "http://www.google.com", 1066 1, 1, "http://www.google.com", "http://www.google.com",
814 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false); 1067 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false);
815 predictor_->OnMainFrameRequest(main_frame1); 1068 predictor_->OnMainFrameRequest(main_frame1);
816 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 1069 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
817 1070
818 // Now add a few subresources. 1071 // Now add a few subresources.
819 URLRequestSummary resource2 = CreateURLRequestSummary( 1072 URLRequestSummary resource2 = CreateURLRequestSummary(
820 1, 1, "http://www.google.com", "http://google.com/script1.js", 1073 1, 1, "http://www.google.com", "http://google.com/script1.js",
821 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false); 1074 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false);
822 URLRequestSummary resource3 = CreateURLRequestSummary( 1075 URLRequestSummary resource3 = CreateURLRequestSummary(
823 1, 1, "http://www.google.com", "http://google.com/script2.js", 1076 1, 1, "http://www.google.com", "http://google.com/script2.js",
824 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false); 1077 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false);
825 predictor_->OnSubresourceResponse(resource1); 1078 predictor_->OnSubresourceResponse(resource1);
826 predictor_->OnSubresourceResponse(resource2); 1079 predictor_->OnSubresourceResponse(resource2);
827 predictor_->OnSubresourceResponse(resource3); 1080 predictor_->OnSubresourceResponse(resource3);
828 1081
829 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 1082 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
830 EXPECT_EQ(3U, 1083 EXPECT_EQ(3U, predictor_->inflight_navigations_[main_frame1.navigation_id]
831 predictor_->inflight_navigations_[main_frame1.navigation_id]->size()); 1084 ->requests.size());
832 EXPECT_TRUE(URLRequestSummaryAreEqual( 1085 EXPECT_TRUE(URLRequestSummaryAreEqual(
833 resource1, 1086 resource1, predictor_->inflight_navigations_[main_frame1.navigation_id]
834 predictor_->inflight_navigations_[main_frame1.navigation_id]->at(0))); 1087 ->requests[0]));
835 EXPECT_TRUE(URLRequestSummaryAreEqual( 1088 EXPECT_TRUE(URLRequestSummaryAreEqual(
836 resource2, 1089 resource2, predictor_->inflight_navigations_[main_frame1.navigation_id]
837 predictor_->inflight_navigations_[main_frame1.navigation_id]->at(1))); 1090 ->requests[1]));
838 EXPECT_TRUE(URLRequestSummaryAreEqual( 1091 EXPECT_TRUE(URLRequestSummaryAreEqual(
839 resource3, 1092 resource3, predictor_->inflight_navigations_[main_frame1.navigation_id]
840 predictor_->inflight_navigations_[main_frame1.navigation_id]->at(2))); 1093 ->requests[2]));
841 } 1094 }
842 1095
843 TEST_F(ResourcePrefetchPredictorTest, HandledResourceTypes) { 1096 TEST_F(ResourcePrefetchPredictorTest, HandledResourceTypes) {
844 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType( 1097 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType(
845 content::RESOURCE_TYPE_STYLESHEET, "bogus/mime-type")); 1098 content::RESOURCE_TYPE_STYLESHEET, "bogus/mime-type"));
846 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType( 1099 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType(
847 content::RESOURCE_TYPE_STYLESHEET, "")); 1100 content::RESOURCE_TYPE_STYLESHEET, ""));
848 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType( 1101 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType(
849 content::RESOURCE_TYPE_WORKER, "text/css")); 1102 content::RESOURCE_TYPE_WORKER, "text/css"));
850 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType( 1103 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType(
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 url_request_job_factory_.set_response_info(response_info); 1317 url_request_job_factory_.set_response_info(response_info);
1065 std::unique_ptr<net::URLRequest> request_etag = 1318 std::unique_ptr<net::URLRequest> request_etag =
1066 CreateURLRequest(GURL("http://www.google.com/cat.png"), net::MEDIUM, 1319 CreateURLRequest(GURL("http://www.google.com/cat.png"), net::MEDIUM,
1067 content::RESOURCE_TYPE_PREFETCH, 1, 1, true); 1320 content::RESOURCE_TYPE_PREFETCH, 1, 1, true);
1068 EXPECT_TRUE(URLRequestSummary::SummarizeResponse(*request_etag, &summary)); 1321 EXPECT_TRUE(URLRequestSummary::SummarizeResponse(*request_etag, &summary));
1069 EXPECT_TRUE(summary.has_validators); 1322 EXPECT_TRUE(summary.has_validators);
1070 EXPECT_TRUE(summary.always_revalidate); 1323 EXPECT_TRUE(summary.always_revalidate);
1071 } 1324 }
1072 1325
1073 } // namespace predictors 1326 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698