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

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

Issue 2440723002: predictors: Make ResourcePrefetchPredictor observable. (Closed)
Patch Set: Move TestObserver outside ResourcePrefetchPredictor class. Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_predictor_test_util.cc ('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 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 #include <utility> 9 #include <utility>
10 10
(...skipping 17 matching lines...) Expand all
28 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
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 using testing::UnorderedElementsAre; 34 using testing::UnorderedElementsAre;
35 35
36 namespace predictors { 36 namespace predictors {
37 37
38 typedef ResourcePrefetchPredictor::URLRequestSummary URLRequestSummary; 38 using URLRequestSummary = ResourcePrefetchPredictor::URLRequestSummary;
39 typedef ResourcePrefetchPredictorTables::PrefetchDataMap PrefetchDataMap; 39 using PageRequestSummary = ResourcePrefetchPredictor::PageRequestSummary;
40 typedef ResourcePrefetchPredictorTables::RedirectDataMap RedirectDataMap; 40 using PrefetchDataMap = ResourcePrefetchPredictorTables::PrefetchDataMap;
41 using RedirectDataMap = ResourcePrefetchPredictorTables::RedirectDataMap;
41 42
42 scoped_refptr<net::HttpResponseHeaders> MakeResponseHeaders( 43 scoped_refptr<net::HttpResponseHeaders> MakeResponseHeaders(
43 const char* headers) { 44 const char* headers) {
44 return make_scoped_refptr(new net::HttpResponseHeaders( 45 return make_scoped_refptr(new net::HttpResponseHeaders(
45 net::HttpUtil::AssembleRawHeaders(headers, strlen(headers)))); 46 net::HttpUtil::AssembleRawHeaders(headers, strlen(headers))));
46 } 47 }
47 48
48 class EmptyURLRequestDelegate : public net::URLRequest::Delegate { 49 class EmptyURLRequestDelegate : public net::URLRequest::Delegate {
49 void OnResponseStarted(net::URLRequest* request, int net_error) override {} 50 void OnResponseStarted(net::URLRequest* request, int net_error) override {}
50 void OnReadCompleted(net::URLRequest* request, int bytes_read) override {} 51 void OnReadCompleted(net::URLRequest* request, int bytes_read) override {}
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 void(const std::vector<std::string>& urls, 147 void(const std::vector<std::string>& urls,
147 const std::vector<std::string>& hosts)); 148 const std::vector<std::string>& hosts));
148 MOCK_METHOD2(DeleteSingleRedirectDataPoint, 149 MOCK_METHOD2(DeleteSingleRedirectDataPoint,
149 void(const std::string& key, PrefetchKeyType key_type)); 150 void(const std::string& key, PrefetchKeyType key_type));
150 MOCK_METHOD0(DeleteAllData, void()); 151 MOCK_METHOD0(DeleteAllData, void());
151 152
152 protected: 153 protected:
153 ~MockResourcePrefetchPredictorTables() { } 154 ~MockResourcePrefetchPredictorTables() { }
154 }; 155 };
155 156
157 class MockResourcePrefetchPredictorObserver : public TestObserver {
158 public:
159 explicit MockResourcePrefetchPredictorObserver(
160 ResourcePrefetchPredictor* predictor)
161 : TestObserver(predictor) {}
162
163 MOCK_METHOD2(
164 OnNavigationLearned,
165 void(size_t url_visit_count,
166 const ResourcePrefetchPredictor::PageRequestSummary& summary));
167 };
168
156 class ResourcePrefetchPredictorTest : public testing::Test { 169 class ResourcePrefetchPredictorTest : public testing::Test {
157 public: 170 public:
158 ResourcePrefetchPredictorTest(); 171 ResourcePrefetchPredictorTest();
159 ~ResourcePrefetchPredictorTest() override; 172 ~ResourcePrefetchPredictorTest() override;
160 void SetUp() override; 173 void SetUp() override;
161 void TearDown() override; 174 void TearDown() override;
162 175
163 protected: 176 protected:
164 void AddUrlToHistory(const std::string& url, int visit_count) { 177 void AddUrlToHistory(const std::string& url, int visit_count) {
165 HistoryServiceFactory::GetForProfile(profile_.get(), 178 HistoryServiceFactory::GetForProfile(profile_.get(),
(...skipping 11 matching lines...) Expand all
177 190
178 NavigationID CreateNavigationID(int process_id, 191 NavigationID CreateNavigationID(int process_id,
179 int render_frame_id, 192 int render_frame_id,
180 const std::string& main_frame_url) { 193 const std::string& main_frame_url) {
181 NavigationID navigation_id(process_id, render_frame_id, 194 NavigationID navigation_id(process_id, render_frame_id,
182 GURL(main_frame_url)); 195 GURL(main_frame_url));
183 navigation_id.creation_time = base::TimeTicks::Now(); 196 navigation_id.creation_time = base::TimeTicks::Now();
184 return navigation_id; 197 return navigation_id;
185 } 198 }
186 199
200 PageRequestSummary CreatePageRequestSummary(
201 const std::string& main_frame_url,
202 const std::string& initial_url,
203 const std::vector<URLRequestSummary>& subresource_requests) {
204 GURL main_frame_gurl(main_frame_url);
205 PageRequestSummary summary(main_frame_gurl);
206 summary.initial_url = GURL(initial_url);
207 summary.subresource_requests = subresource_requests;
208 return summary;
209 }
210
187 URLRequestSummary CreateURLRequestSummary( 211 URLRequestSummary CreateURLRequestSummary(
188 int process_id, 212 int process_id,
189 int render_frame_id, 213 int render_frame_id,
190 const std::string& main_frame_url, 214 const std::string& main_frame_url,
191 const std::string& resource_url = std::string(), 215 const std::string& resource_url = std::string(),
192 content::ResourceType resource_type = content::RESOURCE_TYPE_MAIN_FRAME, 216 content::ResourceType resource_type = content::RESOURCE_TYPE_MAIN_FRAME,
193 net::RequestPriority priority = net::MEDIUM, 217 net::RequestPriority priority = net::MEDIUM,
194 const std::string& mime_type = std::string(), 218 const std::string& mime_type = std::string(),
195 bool was_cached = false) { 219 bool was_cached = false) {
196 URLRequestSummary summary; 220 URLRequestSummary summary;
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 EXPECT_TRUE(predictor_->inflight_navigations_.empty()); 496 EXPECT_TRUE(predictor_->inflight_navigations_.empty());
473 497
474 EXPECT_EQ(test_url_data_, *predictor_->url_table_cache_); 498 EXPECT_EQ(test_url_data_, *predictor_->url_table_cache_);
475 EXPECT_EQ(test_host_data_, *predictor_->host_table_cache_); 499 EXPECT_EQ(test_host_data_, *predictor_->host_table_cache_);
476 EXPECT_EQ(test_url_redirect_data_, *predictor_->url_redirect_table_cache_); 500 EXPECT_EQ(test_url_redirect_data_, *predictor_->url_redirect_table_cache_);
477 EXPECT_EQ(test_host_redirect_data_, *predictor_->host_redirect_table_cache_); 501 EXPECT_EQ(test_host_redirect_data_, *predictor_->host_redirect_table_cache_);
478 } 502 }
479 503
480 // Single navigation but history count is low, so should not record. 504 // Single navigation but history count is low, so should not record.
481 TEST_F(ResourcePrefetchPredictorTest, NavigationNotRecorded) { 505 TEST_F(ResourcePrefetchPredictorTest, NavigationNotRecorded) {
482 AddUrlToHistory("http://www.google.com", 1); 506 const int kVisitCount = 1;
507 AddUrlToHistory("https://www.google.com", kVisitCount);
483 508
484 URLRequestSummary main_frame = 509 URLRequestSummary main_frame =
485 CreateURLRequestSummary(1, 1, "http://www.google.com"); 510 CreateURLRequestSummary(1, 1, "http://www.google.com");
486 predictor_->RecordURLRequest(main_frame); 511 predictor_->RecordURLRequest(main_frame);
487 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 512 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
488 513
489 URLRequestSummary main_frame_redirect = CreateRedirectRequestSummary( 514 URLRequestSummary main_frame_redirect = CreateRedirectRequestSummary(
490 1, 1, "http://www.google.com", "https://www.google.com"); 515 1, 1, "http://www.google.com", "https://www.google.com");
491 predictor_->RecordURLRedirect(main_frame_redirect); 516 predictor_->RecordURLRedirect(main_frame_redirect);
492 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 517 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
493 main_frame = CreateURLRequestSummary(1, 1, "https://www.google.com"); 518 main_frame = CreateURLRequestSummary(1, 1, "https://www.google.com");
494 519
495 // Now add a few subresources. 520 // Now add a few subresources.
496 URLRequestSummary resource1 = CreateURLRequestSummary( 521 URLRequestSummary resource1 = CreateURLRequestSummary(
497 1, 1, "https://www.google.com", "https://google.com/style1.css", 522 1, 1, "https://www.google.com", "https://google.com/style1.css",
498 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false); 523 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false);
499 predictor_->RecordURLResponse(resource1); 524 predictor_->RecordURLResponse(resource1);
500 URLRequestSummary resource2 = CreateURLRequestSummary( 525 URLRequestSummary resource2 = CreateURLRequestSummary(
501 1, 1, "https://www.google.com", "https://google.com/script1.js", 526 1, 1, "https://www.google.com", "https://google.com/script1.js",
502 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false); 527 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false);
503 predictor_->RecordURLResponse(resource2); 528 predictor_->RecordURLResponse(resource2);
504 URLRequestSummary resource3 = CreateURLRequestSummary( 529 URLRequestSummary resource3 = CreateURLRequestSummary(
505 1, 1, "https://www.google.com", "https://google.com/script2.js", 530 1, 1, "https://www.google.com", "https://google.com/script2.js",
506 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false); 531 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false);
507 predictor_->RecordURLResponse(resource3); 532 predictor_->RecordURLResponse(resource3);
508 533
534 StrictMock<MockResourcePrefetchPredictorObserver> mock_observer(
535 predictor_.get());
536 EXPECT_CALL(
537 mock_observer,
538 OnNavigationLearned(kVisitCount,
539 CreatePageRequestSummary(
540 "https://www.google.com", "http://www.google.com",
541 {resource1, resource2, resource3})));
542
509 PrefetchData host_data = CreatePrefetchData("www.google.com"); 543 PrefetchData host_data = CreatePrefetchData("www.google.com");
510 InitializeResourceData(host_data.add_resources(), 544 InitializeResourceData(host_data.add_resources(),
511 "https://google.com/style1.css", 545 "https://google.com/style1.css",
512 content::RESOURCE_TYPE_STYLESHEET, 1, 0, 0, 1.0, 546 content::RESOURCE_TYPE_STYLESHEET, 1, 0, 0, 1.0,
513 net::MEDIUM, false, false); 547 net::MEDIUM, false, false);
514 InitializeResourceData( 548 InitializeResourceData(
515 host_data.add_resources(), "https://google.com/script1.js", 549 host_data.add_resources(), "https://google.com/script1.js",
516 content::RESOURCE_TYPE_SCRIPT, 1, 0, 0, 2.0, net::MEDIUM, false, false); 550 content::RESOURCE_TYPE_SCRIPT, 1, 0, 0, 2.0, net::MEDIUM, false, false);
517 InitializeResourceData( 551 InitializeResourceData(
518 host_data.add_resources(), "https://google.com/script2.js", 552 host_data.add_resources(), "https://google.com/script2.js",
519 content::RESOURCE_TYPE_SCRIPT, 1, 0, 0, 3.0, net::MEDIUM, false, false); 553 content::RESOURCE_TYPE_SCRIPT, 1, 0, 0, 3.0, net::MEDIUM, false, false);
520 EXPECT_CALL(*mock_tables_.get(), 554 EXPECT_CALL(*mock_tables_.get(),
521 UpdateData(empty_resource_data_, host_data, empty_redirect_data_, 555 UpdateData(empty_resource_data_, host_data, empty_redirect_data_,
522 empty_redirect_data_)); 556 empty_redirect_data_));
523 557
524 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id); 558 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id);
525 profile_->BlockUntilHistoryProcessesPendingRequests(); 559 profile_->BlockUntilHistoryProcessesPendingRequests();
526 } 560 }
527 561
528 // Single navigation that will be recorded. Will check for duplicate 562 // Single navigation that will be recorded. Will check for duplicate
529 // resources and also for number of resources saved. 563 // resources and also for number of resources saved.
530 TEST_F(ResourcePrefetchPredictorTest, NavigationUrlNotInDB) { 564 TEST_F(ResourcePrefetchPredictorTest, NavigationUrlNotInDB) {
531 AddUrlToHistory("http://www.google.com", 4); 565 const int kVisitCount = 4;
566 AddUrlToHistory("http://www.google.com", kVisitCount);
532 567
533 URLRequestSummary main_frame = 568 URLRequestSummary main_frame =
534 CreateURLRequestSummary(1, 1, "http://www.google.com"); 569 CreateURLRequestSummary(1, 1, "http://www.google.com");
535 predictor_->RecordURLRequest(main_frame); 570 predictor_->RecordURLRequest(main_frame);
536 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 571 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
537 572
538 URLRequestSummary resource1 = CreateURLRequestSummary( 573 std::vector<URLRequestSummary> resources;
574 resources.push_back(CreateURLRequestSummary(
539 1, 1, "http://www.google.com", "http://google.com/style1.css", 575 1, 1, "http://www.google.com", "http://google.com/style1.css",
540 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false); 576 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false));
541 predictor_->RecordURLResponse(resource1); 577 predictor_->RecordURLResponse(resources.back());
542 URLRequestSummary resource2 = CreateURLRequestSummary( 578 resources.push_back(CreateURLRequestSummary(
543 1, 1, "http://www.google.com", "http://google.com/script1.js", 579 1, 1, "http://www.google.com", "http://google.com/script1.js",
544 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false); 580 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false));
545 predictor_->RecordURLResponse(resource2); 581 predictor_->RecordURLResponse(resources.back());
546 URLRequestSummary resource3 = CreateURLRequestSummary( 582 resources.push_back(CreateURLRequestSummary(
547 1, 1, "http://www.google.com", "http://google.com/script2.js", 583 1, 1, "http://www.google.com", "http://google.com/script2.js",
548 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false); 584 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false));
549 predictor_->RecordURLResponse(resource3); 585 predictor_->RecordURLResponse(resources.back());
550 URLRequestSummary resource4 = CreateURLRequestSummary( 586 resources.push_back(CreateURLRequestSummary(
551 1, 1, "http://www.google.com", "http://google.com/script1.js", 587 1, 1, "http://www.google.com", "http://google.com/script1.js",
552 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", true); 588 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", true));
553 predictor_->RecordURLResponse(resource4); 589 predictor_->RecordURLResponse(resources.back());
554 URLRequestSummary resource5 = CreateURLRequestSummary( 590 resources.push_back(CreateURLRequestSummary(
555 1, 1, "http://www.google.com", "http://google.com/image1.png", 591 1, 1, "http://www.google.com", "http://google.com/image1.png",
556 content::RESOURCE_TYPE_IMAGE, net::MEDIUM, "image/png", false); 592 content::RESOURCE_TYPE_IMAGE, net::MEDIUM, "image/png", false));
557 predictor_->RecordURLResponse(resource5); 593 predictor_->RecordURLResponse(resources.back());
558 URLRequestSummary resource6 = CreateURLRequestSummary( 594 resources.push_back(CreateURLRequestSummary(
559 1, 1, "http://www.google.com", "http://google.com/image2.png", 595 1, 1, "http://www.google.com", "http://google.com/image2.png",
560 content::RESOURCE_TYPE_IMAGE, net::MEDIUM, "image/png", false); 596 content::RESOURCE_TYPE_IMAGE, net::MEDIUM, "image/png", false));
561 predictor_->RecordURLResponse(resource6); 597 predictor_->RecordURLResponse(resources.back());
562 URLRequestSummary resource7 = CreateURLRequestSummary( 598 resources.push_back(CreateURLRequestSummary(
563 1, 1, "http://www.google.com", "http://google.com/style2.css", 599 1, 1, "http://www.google.com", "http://google.com/style2.css",
564 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", true); 600 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", true));
565 predictor_->RecordURLResponse(resource7); 601 predictor_->RecordURLResponse(resources.back());
602
603 StrictMock<MockResourcePrefetchPredictorObserver> mock_observer(
604 predictor_.get());
605 EXPECT_CALL(mock_observer,
606 OnNavigationLearned(
607 kVisitCount, CreatePageRequestSummary("http://www.google.com",
608 "http://www.google.com",
609 resources)));
566 610
567 PrefetchData url_data = CreatePrefetchData("http://www.google.com/"); 611 PrefetchData url_data = CreatePrefetchData("http://www.google.com/");
568 InitializeResourceData(url_data.add_resources(), 612 InitializeResourceData(url_data.add_resources(),
569 "http://google.com/style1.css", 613 "http://google.com/style1.css",
570 content::RESOURCE_TYPE_STYLESHEET, 1, 0, 0, 1.0, 614 content::RESOURCE_TYPE_STYLESHEET, 1, 0, 0, 1.0,
571 net::MEDIUM, false, false); 615 net::MEDIUM, false, false);
572 InitializeResourceData( 616 InitializeResourceData(
573 url_data.add_resources(), "http://google.com/script1.js", 617 url_data.add_resources(), "http://google.com/script1.js",
574 content::RESOURCE_TYPE_SCRIPT, 1, 0, 0, 2.0, net::MEDIUM, false, false); 618 content::RESOURCE_TYPE_SCRIPT, 1, 0, 0, 2.0, net::MEDIUM, false, false);
575 InitializeResourceData( 619 InitializeResourceData(
576 url_data.add_resources(), "http://google.com/script2.js", 620 url_data.add_resources(), "http://google.com/script2.js",
577 content::RESOURCE_TYPE_SCRIPT, 1, 0, 0, 3.0, net::MEDIUM, false, false); 621 content::RESOURCE_TYPE_SCRIPT, 1, 0, 0, 3.0, net::MEDIUM, false, false);
578 InitializeResourceData(url_data.add_resources(), 622 InitializeResourceData(url_data.add_resources(),
579 "http://google.com/style2.css", 623 "http://google.com/style2.css",
580 content::RESOURCE_TYPE_STYLESHEET, 1, 0, 0, 7.0, 624 content::RESOURCE_TYPE_STYLESHEET, 1, 0, 0, 7.0,
581 net::MEDIUM, false, false); 625 net::MEDIUM, false, false);
582 EXPECT_CALL(*mock_tables_.get(), 626 EXPECT_CALL(*mock_tables_.get(),
583 UpdateData(url_data, empty_resource_data_, empty_redirect_data_, 627 UpdateData(url_data, empty_resource_data_, empty_redirect_data_,
584 empty_redirect_data_)); 628 empty_redirect_data_));
585 629
586 PrefetchData host_data = CreatePrefetchData("www.google.com"); 630 PrefetchData host_data = CreatePrefetchData("www.google.com");
587 host_data.mutable_resources()->CopyFrom(url_data.resources()); 631 host_data.mutable_resources()->CopyFrom(url_data.resources());
588 EXPECT_CALL(*mock_tables_.get(), 632 EXPECT_CALL(*mock_tables_.get(),
589 UpdateData(empty_resource_data_, host_data, empty_redirect_data_, 633 UpdateData(empty_resource_data_, host_data, empty_redirect_data_,
590 empty_redirect_data_)); 634 empty_redirect_data_));
591 635
592 predictor_->OnNavigationComplete(main_frame.navigation_id); 636 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id);
593 profile_->BlockUntilHistoryProcessesPendingRequests(); 637 profile_->BlockUntilHistoryProcessesPendingRequests();
594 } 638 }
595 639
596 // Tests that navigation is recorded correctly for URL already present in 640 // Tests that navigation is recorded correctly for URL already present in
597 // the database cache. 641 // the database cache.
598 TEST_F(ResourcePrefetchPredictorTest, NavigationUrlInDB) { 642 TEST_F(ResourcePrefetchPredictorTest, NavigationUrlInDB) {
599 AddUrlToHistory("http://www.google.com", 4); 643 const int kVisitCount = 4;
644 AddUrlToHistory("http://www.google.com", kVisitCount);
600 645
601 EXPECT_CALL(*mock_tables_.get(), 646 EXPECT_CALL(*mock_tables_.get(),
602 GetAllData(Pointee(ContainerEq(PrefetchDataMap())), 647 GetAllData(Pointee(ContainerEq(PrefetchDataMap())),
603 Pointee(ContainerEq(PrefetchDataMap())), 648 Pointee(ContainerEq(PrefetchDataMap())),
604 Pointee(ContainerEq(RedirectDataMap())), 649 Pointee(ContainerEq(RedirectDataMap())),
605 Pointee(ContainerEq(RedirectDataMap())))) 650 Pointee(ContainerEq(RedirectDataMap()))))
606 .WillOnce(DoAll(SetArgPointee<0>(test_url_data_), 651 .WillOnce(DoAll(SetArgPointee<0>(test_url_data_),
607 SetArgPointee<1>(test_host_data_))); 652 SetArgPointee<1>(test_host_data_)));
608 ResetPredictor(); 653 ResetPredictor();
609 InitializePredictor(); 654 InitializePredictor();
610 EXPECT_EQ(3U, predictor_->url_table_cache_->size()); 655 EXPECT_EQ(3U, predictor_->url_table_cache_->size());
611 EXPECT_EQ(2U, predictor_->host_table_cache_->size()); 656 EXPECT_EQ(2U, predictor_->host_table_cache_->size());
612 657
613 URLRequestSummary main_frame = CreateURLRequestSummary( 658 URLRequestSummary main_frame = CreateURLRequestSummary(
614 1, 1, "http://www.google.com", "http://www.google.com", 659 1, 1, "http://www.google.com", "http://www.google.com",
615 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false); 660 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false);
616 predictor_->RecordURLRequest(main_frame); 661 predictor_->RecordURLRequest(main_frame);
617 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 662 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
618 663
619 URLRequestSummary resource1 = CreateURLRequestSummary( 664 std::vector<URLRequestSummary> resources;
665 resources.push_back(CreateURLRequestSummary(
620 1, 1, "http://www.google.com", "http://google.com/style1.css", 666 1, 1, "http://www.google.com", "http://google.com/style1.css",
621 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false); 667 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false));
622 predictor_->RecordURLResponse(resource1); 668 predictor_->RecordURLResponse(resources.back());
623 URLRequestSummary resource2 = CreateURLRequestSummary( 669 resources.push_back(CreateURLRequestSummary(
624 1, 1, "http://www.google.com", "http://google.com/script1.js", 670 1, 1, "http://www.google.com", "http://google.com/script1.js",
625 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false); 671 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false));
626 predictor_->RecordURLResponse(resource2); 672 predictor_->RecordURLResponse(resources.back());
627 URLRequestSummary resource3 = CreateURLRequestSummary( 673 resources.push_back(CreateURLRequestSummary(
628 1, 1, "http://www.google.com", "http://google.com/script2.js", 674 1, 1, "http://www.google.com", "http://google.com/script2.js",
629 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false); 675 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false));
630 predictor_->RecordURLResponse(resource3); 676 predictor_->RecordURLResponse(resources.back());
631 URLRequestSummary resource4 = CreateURLRequestSummary( 677 resources.push_back(CreateURLRequestSummary(
632 1, 1, "http://www.google.com", "http://google.com/script1.js", 678 1, 1, "http://www.google.com", "http://google.com/script1.js",
633 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", true); 679 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", true));
634 predictor_->RecordURLResponse(resource4); 680 predictor_->RecordURLResponse(resources.back());
635 URLRequestSummary resource5 = CreateURLRequestSummary( 681 resources.push_back(CreateURLRequestSummary(
636 1, 1, "http://www.google.com", "http://google.com/image1.png", 682 1, 1, "http://www.google.com", "http://google.com/image1.png",
637 content::RESOURCE_TYPE_IMAGE, net::MEDIUM, "image/png", false); 683 content::RESOURCE_TYPE_IMAGE, net::MEDIUM, "image/png", false));
638 predictor_->RecordURLResponse(resource5); 684 predictor_->RecordURLResponse(resources.back());
639 URLRequestSummary resource6 = CreateURLRequestSummary( 685 resources.push_back(CreateURLRequestSummary(
640 1, 1, "http://www.google.com", "http://google.com/image2.png", 686 1, 1, "http://www.google.com", "http://google.com/image2.png",
641 content::RESOURCE_TYPE_IMAGE, net::MEDIUM, "image/png", false); 687 content::RESOURCE_TYPE_IMAGE, net::MEDIUM, "image/png", false));
642 predictor_->RecordURLResponse(resource6); 688 predictor_->RecordURLResponse(resources.back());
643 URLRequestSummary resource7 = CreateURLRequestSummary( 689 resources.push_back(CreateURLRequestSummary(
644 1, 1, "http://www.google.com", "http://google.com/style2.css", 690 1, 1, "http://www.google.com", "http://google.com/style2.css",
645 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", true); 691 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", true));
646 predictor_->RecordURLResponse(resource7); 692 predictor_->RecordURLResponse(resources.back());
693
694 StrictMock<MockResourcePrefetchPredictorObserver> mock_observer(
695 predictor_.get());
696 EXPECT_CALL(mock_observer,
697 OnNavigationLearned(
698 kVisitCount, CreatePageRequestSummary("http://www.google.com",
699 "http://www.google.com",
700 resources)));
647 701
648 PrefetchData url_data = CreatePrefetchData("http://www.google.com/"); 702 PrefetchData url_data = CreatePrefetchData("http://www.google.com/");
649 InitializeResourceData(url_data.add_resources(), 703 InitializeResourceData(url_data.add_resources(),
650 "http://google.com/style1.css", 704 "http://google.com/style1.css",
651 content::RESOURCE_TYPE_STYLESHEET, 4, 2, 0, 1.0, 705 content::RESOURCE_TYPE_STYLESHEET, 4, 2, 0, 1.0,
652 net::MEDIUM, false, false); 706 net::MEDIUM, false, false);
653 InitializeResourceData( 707 InitializeResourceData(
654 url_data.add_resources(), "http://google.com/script1.js", 708 url_data.add_resources(), "http://google.com/script1.js",
655 content::RESOURCE_TYPE_SCRIPT, 1, 0, 0, 2.0, net::MEDIUM, false, false); 709 content::RESOURCE_TYPE_SCRIPT, 1, 0, 0, 2.0, net::MEDIUM, false, false);
656 InitializeResourceData( 710 InitializeResourceData(
(...skipping 21 matching lines...) Expand all
678 host_data.add_resources(), "http://google.com/script2.js", 732 host_data.add_resources(), "http://google.com/script2.js",
679 content::RESOURCE_TYPE_SCRIPT, 1, 0, 0, 3.0, net::MEDIUM, false, false); 733 content::RESOURCE_TYPE_SCRIPT, 1, 0, 0, 3.0, net::MEDIUM, false, false);
680 InitializeResourceData(host_data.add_resources(), 734 InitializeResourceData(host_data.add_resources(),
681 "http://google.com/style2.css", 735 "http://google.com/style2.css",
682 content::RESOURCE_TYPE_STYLESHEET, 1, 0, 0, 7.0, 736 content::RESOURCE_TYPE_STYLESHEET, 1, 0, 0, 7.0,
683 net::MEDIUM, false, false); 737 net::MEDIUM, false, false);
684 EXPECT_CALL(*mock_tables_.get(), 738 EXPECT_CALL(*mock_tables_.get(),
685 UpdateData(empty_resource_data_, host_data, empty_redirect_data_, 739 UpdateData(empty_resource_data_, host_data, empty_redirect_data_,
686 empty_redirect_data_)); 740 empty_redirect_data_));
687 741
688 predictor_->OnNavigationComplete(main_frame.navigation_id); 742 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id);
689 profile_->BlockUntilHistoryProcessesPendingRequests(); 743 profile_->BlockUntilHistoryProcessesPendingRequests();
690 } 744 }
691 745
692 // Tests that a URL is deleted before another is added if the cache is full. 746 // Tests that a URL is deleted before another is added if the cache is full.
693 TEST_F(ResourcePrefetchPredictorTest, NavigationUrlNotInDBAndDBFull) { 747 TEST_F(ResourcePrefetchPredictorTest, NavigationUrlNotInDBAndDBFull) {
694 AddUrlToHistory("http://www.nike.com/", 4); 748 const int kVisitCount = 4;
749 AddUrlToHistory("http://www.nike.com/", kVisitCount);
695 750
696 EXPECT_CALL(*mock_tables_.get(), 751 EXPECT_CALL(*mock_tables_.get(),
697 GetAllData(Pointee(ContainerEq(PrefetchDataMap())), 752 GetAllData(Pointee(ContainerEq(PrefetchDataMap())),
698 Pointee(ContainerEq(PrefetchDataMap())), 753 Pointee(ContainerEq(PrefetchDataMap())),
699 Pointee(ContainerEq(RedirectDataMap())), 754 Pointee(ContainerEq(RedirectDataMap())),
700 Pointee(ContainerEq(RedirectDataMap())))) 755 Pointee(ContainerEq(RedirectDataMap()))))
701 .WillOnce(DoAll(SetArgPointee<0>(test_url_data_), 756 .WillOnce(DoAll(SetArgPointee<0>(test_url_data_),
702 SetArgPointee<1>(test_host_data_))); 757 SetArgPointee<1>(test_host_data_)));
703 ResetPredictor(); 758 ResetPredictor();
704 InitializePredictor(); 759 InitializePredictor();
705 EXPECT_EQ(3U, predictor_->url_table_cache_->size()); 760 EXPECT_EQ(3U, predictor_->url_table_cache_->size());
706 EXPECT_EQ(2U, predictor_->host_table_cache_->size()); 761 EXPECT_EQ(2U, predictor_->host_table_cache_->size());
707 762
708 URLRequestSummary main_frame = CreateURLRequestSummary( 763 URLRequestSummary main_frame = CreateURLRequestSummary(
709 1, 1, "http://www.nike.com", "http://www.nike.com", 764 1, 1, "http://www.nike.com", "http://www.nike.com",
710 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false); 765 content::RESOURCE_TYPE_MAIN_FRAME, net::MEDIUM, std::string(), false);
711 predictor_->RecordURLRequest(main_frame); 766 predictor_->RecordURLRequest(main_frame);
712 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 767 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
713 768
714 URLRequestSummary resource1 = CreateURLRequestSummary( 769 URLRequestSummary resource1 = CreateURLRequestSummary(
715 1, 1, "http://www.nike.com", "http://nike.com/style1.css", 770 1, 1, "http://www.nike.com", "http://nike.com/style1.css",
716 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false); 771 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false);
717 predictor_->RecordURLResponse(resource1); 772 predictor_->RecordURLResponse(resource1);
718 URLRequestSummary resource2 = CreateURLRequestSummary( 773 URLRequestSummary resource2 = CreateURLRequestSummary(
719 1, 1, "http://www.nike.com", "http://nike.com/image2.png", 774 1, 1, "http://www.nike.com", "http://nike.com/image2.png",
720 content::RESOURCE_TYPE_IMAGE, net::MEDIUM, "image/png", false); 775 content::RESOURCE_TYPE_IMAGE, net::MEDIUM, "image/png", false);
721 predictor_->RecordURLResponse(resource2); 776 predictor_->RecordURLResponse(resource2);
722 777
778 StrictMock<MockResourcePrefetchPredictorObserver> mock_observer(
779 predictor_.get());
780 EXPECT_CALL(mock_observer,
781 OnNavigationLearned(
782 kVisitCount, CreatePageRequestSummary(
783 "http://www.nike.com", "http://www.nike.com",
784 {resource1, resource2})));
785
723 EXPECT_CALL(*mock_tables_.get(), 786 EXPECT_CALL(*mock_tables_.get(),
724 DeleteSingleResourceDataPoint("http://www.google.com/", 787 DeleteSingleResourceDataPoint("http://www.google.com/",
725 PREFETCH_KEY_TYPE_URL)); 788 PREFETCH_KEY_TYPE_URL));
726 EXPECT_CALL(*mock_tables_.get(), 789 EXPECT_CALL(*mock_tables_.get(),
727 DeleteSingleResourceDataPoint("www.facebook.com", 790 DeleteSingleResourceDataPoint("www.facebook.com",
728 PREFETCH_KEY_TYPE_HOST)); 791 PREFETCH_KEY_TYPE_HOST));
729 792
730 PrefetchData url_data = CreatePrefetchData("http://www.nike.com/"); 793 PrefetchData url_data = CreatePrefetchData("http://www.nike.com/");
731 InitializeResourceData(url_data.add_resources(), "http://nike.com/style1.css", 794 InitializeResourceData(url_data.add_resources(), "http://nike.com/style1.css",
732 content::RESOURCE_TYPE_STYLESHEET, 1, 0, 0, 1.0, 795 content::RESOURCE_TYPE_STYLESHEET, 1, 0, 0, 1.0,
733 net::MEDIUM, false, false); 796 net::MEDIUM, false, false);
734 InitializeResourceData(url_data.add_resources(), "http://nike.com/image2.png", 797 InitializeResourceData(url_data.add_resources(), "http://nike.com/image2.png",
735 content::RESOURCE_TYPE_IMAGE, 1, 0, 0, 2.0, 798 content::RESOURCE_TYPE_IMAGE, 1, 0, 0, 2.0,
736 net::MEDIUM, false, false); 799 net::MEDIUM, false, false);
737 EXPECT_CALL(*mock_tables_.get(), 800 EXPECT_CALL(*mock_tables_.get(),
738 UpdateData(url_data, empty_resource_data_, empty_redirect_data_, 801 UpdateData(url_data, empty_resource_data_, empty_redirect_data_,
739 empty_redirect_data_)); 802 empty_redirect_data_));
740 803
741 PrefetchData host_data = CreatePrefetchData("www.nike.com"); 804 PrefetchData host_data = CreatePrefetchData("www.nike.com");
742 host_data.mutable_resources()->CopyFrom(url_data.resources()); 805 host_data.mutable_resources()->CopyFrom(url_data.resources());
743 EXPECT_CALL(*mock_tables_.get(), 806 EXPECT_CALL(*mock_tables_.get(),
744 UpdateData(empty_resource_data_, host_data, empty_redirect_data_, 807 UpdateData(empty_resource_data_, host_data, empty_redirect_data_,
745 empty_redirect_data_)); 808 empty_redirect_data_));
746 809
747 predictor_->OnNavigationComplete(main_frame.navigation_id); 810 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id);
748 profile_->BlockUntilHistoryProcessesPendingRequests(); 811 profile_->BlockUntilHistoryProcessesPendingRequests();
749 } 812 }
750 813
751 TEST_F(ResourcePrefetchPredictorTest, RedirectUrlNotInDB) { 814 TEST_F(ResourcePrefetchPredictorTest, RedirectUrlNotInDB) {
752 AddUrlToHistory("https://facebook.com/google", 4); 815 const int kVisitCount = 4;
816 AddUrlToHistory("https://facebook.com/google", kVisitCount);
753 817
754 URLRequestSummary fb1 = CreateURLRequestSummary(1, 1, "http://fb.com/google"); 818 URLRequestSummary fb1 = CreateURLRequestSummary(1, 1, "http://fb.com/google");
755 predictor_->RecordURLRequest(fb1); 819 predictor_->RecordURLRequest(fb1);
756 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 820 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
757 821
758 URLRequestSummary fb2 = CreateRedirectRequestSummary( 822 URLRequestSummary fb2 = CreateRedirectRequestSummary(
759 1, 1, "http://fb.com/google", "http://facebook.com/google"); 823 1, 1, "http://fb.com/google", "http://facebook.com/google");
760 predictor_->RecordURLRedirect(fb2); 824 predictor_->RecordURLRedirect(fb2);
761 URLRequestSummary fb3 = CreateRedirectRequestSummary( 825 URLRequestSummary fb3 = CreateRedirectRequestSummary(
762 1, 1, "http://facebook.com/google", "https://facebook.com/google"); 826 1, 1, "http://facebook.com/google", "https://facebook.com/google");
763 predictor_->RecordURLRedirect(fb3); 827 predictor_->RecordURLRedirect(fb3);
764 NavigationID fb_end = CreateNavigationID(1, 1, "https://facebook.com/google"); 828 NavigationID fb_end = CreateNavigationID(1, 1, "https://facebook.com/google");
765 829
830 StrictMock<MockResourcePrefetchPredictorObserver> mock_observer(
831 predictor_.get());
832 EXPECT_CALL(
833 mock_observer,
834 OnNavigationLearned(kVisitCount, CreatePageRequestSummary(
835 "https://facebook.com/google",
836 "http://fb.com/google",
837 std::vector<URLRequestSummary>())));
838
766 // Since the navigation hasn't resources, corresponding entry 839 // Since the navigation hasn't resources, corresponding entry
767 // in resource table will be deleted. 840 // in resource table will be deleted.
768 EXPECT_CALL(*mock_tables_.get(), 841 EXPECT_CALL(*mock_tables_.get(),
769 DeleteSingleResourceDataPoint("https://facebook.com/google", 842 DeleteSingleResourceDataPoint("https://facebook.com/google",
770 PREFETCH_KEY_TYPE_URL)); 843 PREFETCH_KEY_TYPE_URL));
771 EXPECT_CALL(*mock_tables_.get(), DeleteSingleResourceDataPoint( 844 EXPECT_CALL(*mock_tables_.get(), DeleteSingleResourceDataPoint(
772 "facebook.com", PREFETCH_KEY_TYPE_HOST)); 845 "facebook.com", PREFETCH_KEY_TYPE_HOST));
773 846
774 RedirectData url_redirect_data = CreateRedirectData("http://fb.com/google"); 847 RedirectData url_redirect_data = CreateRedirectData("http://fb.com/google");
775 InitializeRedirectStat(url_redirect_data.add_redirect_endpoints(), 848 InitializeRedirectStat(url_redirect_data.add_redirect_endpoints(),
776 "https://facebook.com/google", 1, 0, 0); 849 "https://facebook.com/google", 1, 0, 0);
777 EXPECT_CALL(*mock_tables_.get(), 850 EXPECT_CALL(*mock_tables_.get(),
778 UpdateData(empty_resource_data_, empty_resource_data_, 851 UpdateData(empty_resource_data_, empty_resource_data_,
779 url_redirect_data, empty_redirect_data_)); 852 url_redirect_data, empty_redirect_data_));
780 853
781 RedirectData host_redirect_data = CreateRedirectData("fb.com"); 854 RedirectData host_redirect_data = CreateRedirectData("fb.com");
782 InitializeRedirectStat(host_redirect_data.add_redirect_endpoints(), 855 InitializeRedirectStat(host_redirect_data.add_redirect_endpoints(),
783 "facebook.com", 1, 0, 0); 856 "facebook.com", 1, 0, 0);
784 EXPECT_CALL(*mock_tables_.get(), 857 EXPECT_CALL(*mock_tables_.get(),
785 UpdateData(empty_resource_data_, empty_resource_data_, 858 UpdateData(empty_resource_data_, empty_resource_data_,
786 empty_redirect_data_, host_redirect_data)); 859 empty_redirect_data_, host_redirect_data));
787 860
788 predictor_->RecordMainFrameLoadComplete(fb_end); 861 predictor_->RecordMainFrameLoadComplete(fb_end);
789 profile_->BlockUntilHistoryProcessesPendingRequests(); 862 profile_->BlockUntilHistoryProcessesPendingRequests();
790 } 863 }
791 864
792 // Tests that redirect is recorded correctly for URL already present in 865 // Tests that redirect is recorded correctly for URL already present in
793 // the database cache. 866 // the database cache.
794 TEST_F(ResourcePrefetchPredictorTest, RedirectUrlInDB) { 867 TEST_F(ResourcePrefetchPredictorTest, RedirectUrlInDB) {
795 AddUrlToHistory("https://facebook.com/google", 4); 868 const int kVisitCount = 7;
869 AddUrlToHistory("https://facebook.com/google", kVisitCount);
796 870
797 EXPECT_CALL(*mock_tables_.get(), 871 EXPECT_CALL(*mock_tables_.get(),
798 GetAllData(Pointee(ContainerEq(PrefetchDataMap())), 872 GetAllData(Pointee(ContainerEq(PrefetchDataMap())),
799 Pointee(ContainerEq(PrefetchDataMap())), 873 Pointee(ContainerEq(PrefetchDataMap())),
800 Pointee(ContainerEq(RedirectDataMap())), 874 Pointee(ContainerEq(RedirectDataMap())),
801 Pointee(ContainerEq(RedirectDataMap())))) 875 Pointee(ContainerEq(RedirectDataMap()))))
802 .WillOnce(DoAll(SetArgPointee<2>(test_url_redirect_data_), 876 .WillOnce(DoAll(SetArgPointee<2>(test_url_redirect_data_),
803 SetArgPointee<3>(test_host_redirect_data_))); 877 SetArgPointee<3>(test_host_redirect_data_)));
804 ResetPredictor(); 878 ResetPredictor();
805 InitializePredictor(); 879 InitializePredictor();
806 EXPECT_EQ(3U, predictor_->url_redirect_table_cache_->size()); 880 EXPECT_EQ(3U, predictor_->url_redirect_table_cache_->size());
807 EXPECT_EQ(2U, predictor_->host_redirect_table_cache_->size()); 881 EXPECT_EQ(2U, predictor_->host_redirect_table_cache_->size());
808 882
809 URLRequestSummary fb1 = CreateURLRequestSummary(1, 1, "http://fb.com/google"); 883 URLRequestSummary fb1 = CreateURLRequestSummary(1, 1, "http://fb.com/google");
810 predictor_->RecordURLRequest(fb1); 884 predictor_->RecordURLRequest(fb1);
811 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 885 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
812 886
813 URLRequestSummary fb2 = CreateRedirectRequestSummary( 887 URLRequestSummary fb2 = CreateRedirectRequestSummary(
814 1, 1, "http://fb.com/google", "http://facebook.com/google"); 888 1, 1, "http://fb.com/google", "http://facebook.com/google");
815 predictor_->RecordURLRedirect(fb2); 889 predictor_->RecordURLRedirect(fb2);
816 URLRequestSummary fb3 = CreateRedirectRequestSummary( 890 URLRequestSummary fb3 = CreateRedirectRequestSummary(
817 1, 1, "http://facebook.com/google", "https://facebook.com/google"); 891 1, 1, "http://facebook.com/google", "https://facebook.com/google");
818 predictor_->RecordURLRedirect(fb3); 892 predictor_->RecordURLRedirect(fb3);
819 NavigationID fb_end = CreateNavigationID(1, 1, "https://facebook.com/google"); 893 NavigationID fb_end = CreateNavigationID(1, 1, "https://facebook.com/google");
820 894
895 StrictMock<MockResourcePrefetchPredictorObserver> mock_observer(
896 predictor_.get());
897 EXPECT_CALL(
898 mock_observer,
899 OnNavigationLearned(kVisitCount, CreatePageRequestSummary(
900 "https://facebook.com/google",
901 "http://fb.com/google",
902 std::vector<URLRequestSummary>())));
903
821 // Oldest entries in tables will be superseded and deleted. 904 // Oldest entries in tables will be superseded and deleted.
822 EXPECT_CALL(*mock_tables_.get(), 905 EXPECT_CALL(*mock_tables_.get(),
823 DeleteSingleRedirectDataPoint("bbc.com", PREFETCH_KEY_TYPE_HOST)); 906 DeleteSingleRedirectDataPoint("bbc.com", PREFETCH_KEY_TYPE_HOST));
824 907
825 // Since the navigation hasn't resources, corresponding entry 908 // Since the navigation hasn't resources, corresponding entry
826 // in resource table will be deleted. 909 // in resource table will be deleted.
827 EXPECT_CALL(*mock_tables_.get(), 910 EXPECT_CALL(*mock_tables_.get(),
828 DeleteSingleResourceDataPoint("https://facebook.com/google", 911 DeleteSingleResourceDataPoint("https://facebook.com/google",
829 PREFETCH_KEY_TYPE_URL)); 912 PREFETCH_KEY_TYPE_URL));
830 EXPECT_CALL(*mock_tables_.get(), DeleteSingleResourceDataPoint( 913 EXPECT_CALL(*mock_tables_.get(), DeleteSingleResourceDataPoint(
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 net::MEDIUM, false, false); 1575 net::MEDIUM, false, false);
1493 predictor_->url_table_cache_->insert( 1576 predictor_->url_table_cache_->insert(
1494 std::make_pair(www_google_url.primary_key(), www_google_url)); 1577 std::make_pair(www_google_url.primary_key(), www_google_url));
1495 1578
1496 urls.clear(); 1579 urls.clear();
1497 EXPECT_TRUE(predictor_->GetPrefetchData(main_frame_url, &urls)); 1580 EXPECT_TRUE(predictor_->GetPrefetchData(main_frame_url, &urls));
1498 EXPECT_THAT(urls, UnorderedElementsAre(GURL(font_url))); 1581 EXPECT_THAT(urls, UnorderedElementsAre(GURL(font_url)));
1499 } 1582 }
1500 1583
1501 } // namespace predictors 1584 } // namespace predictors
OLDNEW
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_predictor_test_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698