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

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

Issue 2896713003: Create LoadingDataCollector class and have observers rely on it instead of ResourcePrefetchPredictor (Closed)
Patch Set: Rebase, merge loading_stats_collector. Created 3 years, 6 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 #include <utility> 9 #include <utility>
10 10
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/test/histogram_tester.h" 14 #include "base/test/histogram_tester.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "chrome/browser/history/history_service_factory.h" 16 #include "chrome/browser/history/history_service_factory.h"
17 #include "chrome/browser/predictors/loading_predictor.h" 17 #include "chrome/browser/predictors/loading_predictor.h"
18 #include "chrome/browser/predictors/loading_test_util.h"
18 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" 19 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h"
19 #include "chrome/browser/predictors/resource_prefetch_predictor_test_util.h"
20 #include "chrome/browser/predictors/resource_prefetcher_manager.h" 20 #include "chrome/browser/predictors/resource_prefetcher_manager.h"
21 #include "chrome/test/base/testing_profile.h" 21 #include "chrome/test/base/testing_profile.h"
22 #include "components/history/core/browser/history_service.h" 22 #include "components/history/core/browser/history_service.h"
23 #include "components/history/core/browser/history_types.h" 23 #include "components/history/core/browser/history_types.h"
24 #include "components/sessions/core/session_id.h" 24 #include "components/sessions/core/session_id.h"
25 #include "content/public/browser/resource_request_info.h"
26 #include "content/public/test/test_browser_thread_bundle.h" 25 #include "content/public/test/test_browser_thread_bundle.h"
27 #include "net/http/http_response_headers.h" 26 #include "net/http/http_response_headers.h"
28 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" 27 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
29 #include "net/url_request/url_request_context.h" 28 #include "net/url_request/url_request_context.h"
30 #include "net/url_request/url_request_job.h" 29 #include "net/url_request/url_request_job.h"
31 #include "net/url_request/url_request_test_util.h"
32 #include "testing/gmock/include/gmock/gmock.h" 30 #include "testing/gmock/include/gmock/gmock.h"
33 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
34 32
35 using testing::StrictMock; 33 using testing::StrictMock;
36 using testing::UnorderedElementsAre; 34 using testing::UnorderedElementsAre;
37 35
38 namespace predictors { 36 namespace predictors {
39 37
40 using URLRequestSummary = ResourcePrefetchPredictor::URLRequestSummary; 38 using URLRequestSummary = ResourcePrefetchPredictor::URLRequestSummary;
41 using PageRequestSummary = ResourcePrefetchPredictor::PageRequestSummary; 39 using PageRequestSummary = ResourcePrefetchPredictor::PageRequestSummary;
42 using PrefetchDataMap = std::map<std::string, PrefetchData>; 40 using PrefetchDataMap = std::map<std::string, PrefetchData>;
43 using RedirectDataMap = std::map<std::string, RedirectData>; 41 using RedirectDataMap = std::map<std::string, RedirectData>;
44 using OriginDataMap = std::map<std::string, OriginData>; 42 using OriginDataMap = std::map<std::string, OriginData>;
45 using ManifestDataMap = std::map<std::string, precache::PrecacheManifest>; 43 using ManifestDataMap = std::map<std::string, precache::PrecacheManifest>;
46 44
47 scoped_refptr<net::HttpResponseHeaders> MakeResponseHeaders(
48 const char* headers) {
49 return make_scoped_refptr(new net::HttpResponseHeaders(
50 net::HttpUtil::AssembleRawHeaders(headers, strlen(headers))));
51 }
52
53 class EmptyURLRequestDelegate : public net::URLRequest::Delegate {
54 void OnResponseStarted(net::URLRequest* request, int net_error) override {}
55 void OnReadCompleted(net::URLRequest* request, int bytes_read) override {}
56 };
57
58 class MockURLRequestJob : public net::URLRequestJob {
59 public:
60 MockURLRequestJob(net::URLRequest* request,
61 const net::HttpResponseInfo& response_info,
62 const std::string& mime_type)
63 : net::URLRequestJob(request, nullptr),
64 response_info_(response_info),
65 mime_type_(mime_type) {}
66
67 bool GetMimeType(std::string* mime_type) const override {
68 *mime_type = mime_type_;
69 return true;
70 }
71
72 protected:
73 void Start() override { NotifyHeadersComplete(); }
74 void GetResponseInfo(net::HttpResponseInfo* info) override {
75 *info = response_info_;
76 }
77
78 private:
79 net::HttpResponseInfo response_info_;
80 std::string mime_type_;
81 };
82
83 class MockURLRequestJobFactory : public net::URLRequestJobFactory {
84 public:
85 MockURLRequestJobFactory() {}
86 ~MockURLRequestJobFactory() override {}
87
88 net::URLRequestJob* MaybeCreateJobWithProtocolHandler(
89 const std::string& scheme,
90 net::URLRequest* request,
91 net::NetworkDelegate* network_delegate) const override {
92 return new MockURLRequestJob(request, response_info_, mime_type_);
93 }
94
95 net::URLRequestJob* MaybeInterceptRedirect(
96 net::URLRequest* request,
97 net::NetworkDelegate* network_delegate,
98 const GURL& location) const override {
99 return nullptr;
100 }
101
102 net::URLRequestJob* MaybeInterceptResponse(
103 net::URLRequest* request,
104 net::NetworkDelegate* network_delegate) const override {
105 return nullptr;
106 }
107
108 bool IsHandledProtocol(const std::string& scheme) const override {
109 return true;
110 }
111
112 bool IsSafeRedirectTarget(const GURL& location) const override {
113 return true;
114 }
115
116 void set_response_info(const net::HttpResponseInfo& response_info) {
117 response_info_ = response_info;
118 }
119
120 void set_mime_type(const std::string& mime_type) { mime_type_ = mime_type; }
121
122 private:
123 net::HttpResponseInfo response_info_;
124 std::string mime_type_;
125 };
126
127 template <typename T> 45 template <typename T>
128 class FakeGlowplugKeyValueTable : public GlowplugKeyValueTable<T> { 46 class FakeGlowplugKeyValueTable : public GlowplugKeyValueTable<T> {
129 public: 47 public:
130 FakeGlowplugKeyValueTable() : GlowplugKeyValueTable<T>("") {} 48 FakeGlowplugKeyValueTable() : GlowplugKeyValueTable<T>("") {}
131 void GetAllData(std::map<std::string, T>* data_map, 49 void GetAllData(std::map<std::string, T>* data_map,
132 sql::Connection* db) const override { 50 sql::Connection* db) const override {
133 *data_map = data_; 51 *data_map = data_;
134 } 52 }
135 void UpdateData(const std::string& key, 53 void UpdateData(const std::string& key,
136 const T& data, 54 const T& data,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 FakeGlowplugKeyValueTable<RedirectData> url_redirect_table_; 107 FakeGlowplugKeyValueTable<RedirectData> url_redirect_table_;
190 FakeGlowplugKeyValueTable<PrefetchData> host_resource_table_; 108 FakeGlowplugKeyValueTable<PrefetchData> host_resource_table_;
191 FakeGlowplugKeyValueTable<RedirectData> host_redirect_table_; 109 FakeGlowplugKeyValueTable<RedirectData> host_redirect_table_;
192 FakeGlowplugKeyValueTable<precache::PrecacheManifest> manifest_table_; 110 FakeGlowplugKeyValueTable<precache::PrecacheManifest> manifest_table_;
193 FakeGlowplugKeyValueTable<OriginData> origin_table_; 111 FakeGlowplugKeyValueTable<OriginData> origin_table_;
194 112
195 protected: 113 protected:
196 ~MockResourcePrefetchPredictorTables() override = default; 114 ~MockResourcePrefetchPredictorTables() override = default;
197 }; 115 };
198 116
199 class MockResourcePrefetchPredictorObserver : public TestObserver { 117 class MockLoadingPredictorObserver : public TestObserver {
alexilin 2017/06/07 12:37:31 nit: It seems that this renaming wasn't really int
trevordixon 2017/06/07 13:17:55 Oops! As easy as it is, I might as well rename it
200 public: 118 public:
201 explicit MockResourcePrefetchPredictorObserver( 119 explicit MockLoadingPredictorObserver(ResourcePrefetchPredictor* predictor)
202 ResourcePrefetchPredictor* predictor)
203 : TestObserver(predictor) {} 120 : TestObserver(predictor) {}
204 121
205 MOCK_METHOD2( 122 MOCK_METHOD2(
206 OnNavigationLearned, 123 OnNavigationLearned,
207 void(size_t url_visit_count, 124 void(size_t url_visit_count,
208 const ResourcePrefetchPredictor::PageRequestSummary& summary)); 125 const ResourcePrefetchPredictor::PageRequestSummary& summary));
209 }; 126 };
210 127
211 class ResourcePrefetchPredictorTest : public testing::Test { 128 class ResourcePrefetchPredictorTest : public testing::Test {
212 public: 129 public:
(...skipping 20 matching lines...) Expand all
233 URLRequestSummary CreateRedirectRequestSummary( 150 URLRequestSummary CreateRedirectRequestSummary(
234 SessionID::id_type session_id, 151 SessionID::id_type session_id,
235 const std::string& main_frame_url, 152 const std::string& main_frame_url,
236 const std::string& redirect_url) { 153 const std::string& redirect_url) {
237 URLRequestSummary summary = 154 URLRequestSummary summary =
238 CreateURLRequestSummary(session_id, main_frame_url); 155 CreateURLRequestSummary(session_id, main_frame_url);
239 summary.redirect_url = GURL(redirect_url); 156 summary.redirect_url = GURL(redirect_url);
240 return summary; 157 return summary;
241 } 158 }
242 159
243 std::unique_ptr<net::URLRequest> CreateURLRequest(
244 const GURL& url,
245 net::RequestPriority priority,
246 content::ResourceType resource_type,
247 bool is_main_frame) {
248 std::unique_ptr<net::URLRequest> request =
249 url_request_context_.CreateRequest(url, priority,
250 &url_request_delegate_,
251 TRAFFIC_ANNOTATION_FOR_TESTS);
252 request->set_first_party_for_cookies(url);
253 content::ResourceRequestInfo::AllocateForTesting(
254 request.get(), resource_type, nullptr, -1, -1, -1, is_main_frame, false,
255 false, true, content::PREVIEWS_OFF);
256 request->Start();
257 return request;
258 }
259
260 void InitializePredictor() { 160 void InitializePredictor() {
261 loading_predictor_->StartInitialization(); 161 loading_predictor_->StartInitialization();
262 base::RunLoop loop; 162 base::RunLoop loop;
263 loop.RunUntilIdle(); // Runs the DB lookup. 163 loop.RunUntilIdle(); // Runs the DB lookup.
264 profile_->BlockUntilHistoryProcessesPendingRequests(); 164 profile_->BlockUntilHistoryProcessesPendingRequests();
265 } 165 }
266 166
267 void ResetPredictor(bool small_db = true) { 167 void ResetPredictor(bool small_db = true) {
268 LoadingPredictorConfig config; 168 LoadingPredictorConfig config;
269 PopulateTestConfig(&config, small_db); 169 PopulateTestConfig(&config, small_db);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 profile_.get(), ServiceAccessType::EXPLICIT_ACCESS)); 214 profile_.get(), ServiceAccessType::EXPLICIT_ACCESS));
315 // Initialize the predictor with empty data. 215 // Initialize the predictor with empty data.
316 ResetPredictor(); 216 ResetPredictor();
317 EXPECT_EQ(predictor_->initialization_state_, 217 EXPECT_EQ(predictor_->initialization_state_,
318 ResourcePrefetchPredictor::NOT_INITIALIZED); 218 ResourcePrefetchPredictor::NOT_INITIALIZED);
319 InitializePredictor(); 219 InitializePredictor();
320 EXPECT_TRUE(predictor_->inflight_navigations_.empty()); 220 EXPECT_TRUE(predictor_->inflight_navigations_.empty());
321 EXPECT_EQ(predictor_->initialization_state_, 221 EXPECT_EQ(predictor_->initialization_state_,
322 ResourcePrefetchPredictor::INITIALIZED); 222 ResourcePrefetchPredictor::INITIALIZED);
323 223
224 url_request_job_factory_.Reset();
324 url_request_context_.set_job_factory(&url_request_job_factory_); 225 url_request_context_.set_job_factory(&url_request_job_factory_);
325 226
326 histogram_tester_.reset(new base::HistogramTester()); 227 histogram_tester_.reset(new base::HistogramTester());
327 } 228 }
328 229
329 void ResourcePrefetchPredictorTest::TearDown() { 230 void ResourcePrefetchPredictorTest::TearDown() {
330 EXPECT_EQ(*predictor_->url_resource_data_->data_cache_, 231 EXPECT_EQ(*predictor_->url_resource_data_->data_cache_,
331 mock_tables_->url_resource_table_.data_); 232 mock_tables_->url_resource_table_.data_);
332 EXPECT_EQ(*predictor_->url_redirect_data_->data_cache_, 233 EXPECT_EQ(*predictor_->url_redirect_data_->data_cache_,
333 mock_tables_->url_redirect_table_.data_); 234 mock_tables_->url_redirect_table_.data_);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 predictor_->RecordURLResponse(resource1); 455 predictor_->RecordURLResponse(resource1);
555 URLRequestSummary resource2 = CreateURLRequestSummary( 456 URLRequestSummary resource2 = CreateURLRequestSummary(
556 1, "https://www.google.com", "https://google.com/script1.js", 457 1, "https://www.google.com", "https://google.com/script1.js",
557 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false); 458 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false);
558 predictor_->RecordURLResponse(resource2); 459 predictor_->RecordURLResponse(resource2);
559 URLRequestSummary resource3 = CreateURLRequestSummary( 460 URLRequestSummary resource3 = CreateURLRequestSummary(
560 1, "https://www.google.com", "https://google.com/script2.js", 461 1, "https://www.google.com", "https://google.com/script2.js",
561 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false); 462 content::RESOURCE_TYPE_SCRIPT, net::MEDIUM, "text/javascript", false);
562 predictor_->RecordURLResponse(resource3); 463 predictor_->RecordURLResponse(resource3);
563 464
564 StrictMock<MockResourcePrefetchPredictorObserver> mock_observer(predictor_); 465 StrictMock<MockLoadingPredictorObserver> mock_observer(predictor_);
565 EXPECT_CALL( 466 EXPECT_CALL(
566 mock_observer, 467 mock_observer,
567 OnNavigationLearned(kVisitCount, 468 OnNavigationLearned(kVisitCount,
568 CreatePageRequestSummary( 469 CreatePageRequestSummary(
569 "https://www.google.com", "http://www.google.com", 470 "https://www.google.com", "http://www.google.com",
570 {resource1, resource2, resource3}))); 471 {resource1, resource2, resource3})));
571 472
572 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id); 473 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id);
573 profile_->BlockUntilHistoryProcessesPendingRequests(); 474 profile_->BlockUntilHistoryProcessesPendingRequests();
574 475
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", true); 554 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", true);
654 redirected.redirect_url = GURL("http://dev.null.google.com/style.css"); 555 redirected.redirect_url = GURL("http://dev.null.google.com/style.css");
655 556
656 predictor_->RecordURLRedirect(redirected); 557 predictor_->RecordURLRedirect(redirected);
657 redirected.is_no_store = true; 558 redirected.is_no_store = true;
658 redirected.request_url = redirected.redirect_url; 559 redirected.request_url = redirected.redirect_url;
659 redirected.redirect_url = GURL(); 560 redirected.redirect_url = GURL();
660 561
661 predictor_->RecordURLResponse(redirected); 562 predictor_->RecordURLResponse(redirected);
662 563
663 StrictMock<MockResourcePrefetchPredictorObserver> mock_observer(predictor_); 564 StrictMock<MockLoadingPredictorObserver> mock_observer(predictor_);
664 EXPECT_CALL(mock_observer, 565 EXPECT_CALL(mock_observer,
665 OnNavigationLearned( 566 OnNavigationLearned(
666 kVisitCount, CreatePageRequestSummary("http://www.google.com", 567 kVisitCount, CreatePageRequestSummary("http://www.google.com",
667 "http://www.google.com", 568 "http://www.google.com",
668 resources))); 569 resources)));
669 570
670 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id); 571 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id);
671 profile_->BlockUntilHistoryProcessesPendingRequests(); 572 profile_->BlockUntilHistoryProcessesPendingRequests();
672 573
673 PrefetchData url_data = CreatePrefetchData("http://www.google.com/"); 574 PrefetchData url_data = CreatePrefetchData("http://www.google.com/");
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 1, "http://www.google.com", "http://google.com/style2.css", 668 1, "http://www.google.com", "http://google.com/style2.css",
768 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", true)); 669 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", true));
769 predictor_->RecordURLResponse(resources.back()); 670 predictor_->RecordURLResponse(resources.back());
770 auto no_store = CreateURLRequestSummary( 671 auto no_store = CreateURLRequestSummary(
771 1, "http://www.google.com", 672 1, "http://www.google.com",
772 "http://static.google.com/style2-no-store.css", 673 "http://static.google.com/style2-no-store.css",
773 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", true); 674 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", true);
774 no_store.is_no_store = true; 675 no_store.is_no_store = true;
775 predictor_->RecordURLResponse(no_store); 676 predictor_->RecordURLResponse(no_store);
776 677
777 StrictMock<MockResourcePrefetchPredictorObserver> mock_observer(predictor_); 678 StrictMock<MockLoadingPredictorObserver> mock_observer(predictor_);
778 EXPECT_CALL(mock_observer, 679 EXPECT_CALL(mock_observer,
779 OnNavigationLearned( 680 OnNavigationLearned(
780 kVisitCount, CreatePageRequestSummary("http://www.google.com", 681 kVisitCount, CreatePageRequestSummary("http://www.google.com",
781 "http://www.google.com", 682 "http://www.google.com",
782 resources))); 683 resources)));
783 684
784 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id); 685 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id);
785 profile_->BlockUntilHistoryProcessesPendingRequests(); 686 profile_->BlockUntilHistoryProcessesPendingRequests();
786 687
787 PrefetchData url_data = CreatePrefetchData("http://www.google.com/"); 688 PrefetchData url_data = CreatePrefetchData("http://www.google.com/");
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 770
870 URLRequestSummary resource1 = CreateURLRequestSummary( 771 URLRequestSummary resource1 = CreateURLRequestSummary(
871 1, "http://www.nike.com", "http://nike.com/style1.css", 772 1, "http://www.nike.com", "http://nike.com/style1.css",
872 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false); 773 content::RESOURCE_TYPE_STYLESHEET, net::MEDIUM, "text/css", false);
873 predictor_->RecordURLResponse(resource1); 774 predictor_->RecordURLResponse(resource1);
874 URLRequestSummary resource2 = CreateURLRequestSummary( 775 URLRequestSummary resource2 = CreateURLRequestSummary(
875 1, "http://www.nike.com", "http://nike.com/image2.png", 776 1, "http://www.nike.com", "http://nike.com/image2.png",
876 content::RESOURCE_TYPE_IMAGE, net::MEDIUM, "image/png", false); 777 content::RESOURCE_TYPE_IMAGE, net::MEDIUM, "image/png", false);
877 predictor_->RecordURLResponse(resource2); 778 predictor_->RecordURLResponse(resource2);
878 779
879 StrictMock<MockResourcePrefetchPredictorObserver> mock_observer(predictor_); 780 StrictMock<MockLoadingPredictorObserver> mock_observer(predictor_);
880 EXPECT_CALL(mock_observer, 781 EXPECT_CALL(mock_observer,
881 OnNavigationLearned( 782 OnNavigationLearned(
882 kVisitCount, CreatePageRequestSummary( 783 kVisitCount, CreatePageRequestSummary(
883 "http://www.nike.com", "http://www.nike.com", 784 "http://www.nike.com", "http://www.nike.com",
884 {resource1, resource2}))); 785 {resource1, resource2})));
885 786
886 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id); 787 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id);
887 profile_->BlockUntilHistoryProcessesPendingRequests(); 788 profile_->BlockUntilHistoryProcessesPendingRequests();
888 789
889 PrefetchData url_data = CreatePrefetchData("http://www.nike.com/"); 790 PrefetchData url_data = CreatePrefetchData("http://www.nike.com/");
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 840 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
940 841
941 URLRequestSummary fb2 = CreateRedirectRequestSummary( 842 URLRequestSummary fb2 = CreateRedirectRequestSummary(
942 1, "http://fb.com/google", "http://facebook.com/google"); 843 1, "http://fb.com/google", "http://facebook.com/google");
943 predictor_->RecordURLRedirect(fb2); 844 predictor_->RecordURLRedirect(fb2);
944 URLRequestSummary fb3 = CreateRedirectRequestSummary( 845 URLRequestSummary fb3 = CreateRedirectRequestSummary(
945 1, "http://facebook.com/google", "https://facebook.com/google"); 846 1, "http://facebook.com/google", "https://facebook.com/google");
946 predictor_->RecordURLRedirect(fb3); 847 predictor_->RecordURLRedirect(fb3);
947 NavigationID fb_end = CreateNavigationID(1, "https://facebook.com/google"); 848 NavigationID fb_end = CreateNavigationID(1, "https://facebook.com/google");
948 849
949 StrictMock<MockResourcePrefetchPredictorObserver> mock_observer(predictor_); 850 StrictMock<MockLoadingPredictorObserver> mock_observer(predictor_);
950 EXPECT_CALL( 851 EXPECT_CALL(
951 mock_observer, 852 mock_observer,
952 OnNavigationLearned(kVisitCount, CreatePageRequestSummary( 853 OnNavigationLearned(kVisitCount, CreatePageRequestSummary(
953 "https://facebook.com/google", 854 "https://facebook.com/google",
954 "http://fb.com/google", 855 "http://fb.com/google",
955 std::vector<URLRequestSummary>()))); 856 std::vector<URLRequestSummary>())));
956 857
957 predictor_->RecordMainFrameLoadComplete(fb_end); 858 predictor_->RecordMainFrameLoadComplete(fb_end);
958 profile_->BlockUntilHistoryProcessesPendingRequests(); 859 profile_->BlockUntilHistoryProcessesPendingRequests();
959 860
(...skipping 29 matching lines...) Expand all
989 EXPECT_EQ(1U, predictor_->inflight_navigations_.size()); 890 EXPECT_EQ(1U, predictor_->inflight_navigations_.size());
990 891
991 URLRequestSummary fb2 = CreateRedirectRequestSummary( 892 URLRequestSummary fb2 = CreateRedirectRequestSummary(
992 1, "http://fb.com/google", "http://facebook.com/google"); 893 1, "http://fb.com/google", "http://facebook.com/google");
993 predictor_->RecordURLRedirect(fb2); 894 predictor_->RecordURLRedirect(fb2);
994 URLRequestSummary fb3 = CreateRedirectRequestSummary( 895 URLRequestSummary fb3 = CreateRedirectRequestSummary(
995 1, "http://facebook.com/google", "https://facebook.com/google"); 896 1, "http://facebook.com/google", "https://facebook.com/google");
996 predictor_->RecordURLRedirect(fb3); 897 predictor_->RecordURLRedirect(fb3);
997 NavigationID fb_end = CreateNavigationID(1, "https://facebook.com/google"); 898 NavigationID fb_end = CreateNavigationID(1, "https://facebook.com/google");
998 899
999 StrictMock<MockResourcePrefetchPredictorObserver> mock_observer(predictor_); 900 StrictMock<MockLoadingPredictorObserver> mock_observer(predictor_);
1000 EXPECT_CALL( 901 EXPECT_CALL(
1001 mock_observer, 902 mock_observer,
1002 OnNavigationLearned(kVisitCount, CreatePageRequestSummary( 903 OnNavigationLearned(kVisitCount, CreatePageRequestSummary(
1003 "https://facebook.com/google", 904 "https://facebook.com/google",
1004 "http://fb.com/google", 905 "http://fb.com/google",
1005 std::vector<URLRequestSummary>()))); 906 std::vector<URLRequestSummary>())));
1006 907
1007 predictor_->RecordMainFrameLoadComplete(fb_end); 908 predictor_->RecordMainFrameLoadComplete(fb_end);
1008 profile_->BlockUntilHistoryProcessesPendingRequests(); 909 profile_->BlockUntilHistoryProcessesPendingRequests();
1009 910
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 predictor_->inflight_navigations_[main_frame1.navigation_id] 1307 predictor_->inflight_navigations_[main_frame1.navigation_id]
1407 ->subresource_requests[0]); 1308 ->subresource_requests[0]);
1408 EXPECT_EQ(resource2, 1309 EXPECT_EQ(resource2,
1409 predictor_->inflight_navigations_[main_frame1.navigation_id] 1310 predictor_->inflight_navigations_[main_frame1.navigation_id]
1410 ->subresource_requests[1]); 1311 ->subresource_requests[1]);
1411 EXPECT_EQ(resource3, 1312 EXPECT_EQ(resource3,
1412 predictor_->inflight_navigations_[main_frame1.navigation_id] 1313 predictor_->inflight_navigations_[main_frame1.navigation_id]
1413 ->subresource_requests[2]); 1314 ->subresource_requests[2]);
1414 } 1315 }
1415 1316
1416 TEST_F(ResourcePrefetchPredictorTest, HandledResourceTypes) {
1417 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType(
1418 content::RESOURCE_TYPE_STYLESHEET, "bogus/mime-type"));
1419 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType(
1420 content::RESOURCE_TYPE_STYLESHEET, ""));
1421 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType(
1422 content::RESOURCE_TYPE_WORKER, "text/css"));
1423 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType(
1424 content::RESOURCE_TYPE_WORKER, ""));
1425 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType(
1426 content::RESOURCE_TYPE_PREFETCH, "text/css"));
1427 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType(
1428 content::RESOURCE_TYPE_PREFETCH, "bogus/mime-type"));
1429 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType(
1430 content::RESOURCE_TYPE_PREFETCH, ""));
1431 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType(
1432 content::RESOURCE_TYPE_PREFETCH, "application/font-woff"));
1433 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType(
1434 content::RESOURCE_TYPE_PREFETCH, "font/woff2"));
1435 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType(
1436 content::RESOURCE_TYPE_XHR, ""));
1437 EXPECT_FALSE(ResourcePrefetchPredictor::IsHandledResourceType(
1438 content::RESOURCE_TYPE_XHR, "bogus/mime-type"));
1439 EXPECT_TRUE(ResourcePrefetchPredictor::IsHandledResourceType(
1440 content::RESOURCE_TYPE_XHR, "application/javascript"));
1441 }
1442
1443 TEST_F(ResourcePrefetchPredictorTest, ShouldRecordRequestMainFrame) {
1444 std::unique_ptr<net::URLRequest> http_request =
1445 CreateURLRequest(GURL("http://www.google.com"), net::MEDIUM,
1446 content::RESOURCE_TYPE_IMAGE, true);
1447 EXPECT_TRUE(ResourcePrefetchPredictor::ShouldRecordRequest(
1448 http_request.get(), content::RESOURCE_TYPE_MAIN_FRAME));
1449
1450 std::unique_ptr<net::URLRequest> https_request =
1451 CreateURLRequest(GURL("https://www.google.com"), net::MEDIUM,
1452 content::RESOURCE_TYPE_IMAGE, true);
1453 EXPECT_TRUE(ResourcePrefetchPredictor::ShouldRecordRequest(
1454 https_request.get(), content::RESOURCE_TYPE_MAIN_FRAME));
1455
1456 std::unique_ptr<net::URLRequest> file_request =
1457 CreateURLRequest(GURL("file://www.google.com"), net::MEDIUM,
1458 content::RESOURCE_TYPE_IMAGE, true);
1459 EXPECT_FALSE(ResourcePrefetchPredictor::ShouldRecordRequest(
1460 file_request.get(), content::RESOURCE_TYPE_MAIN_FRAME));
1461
1462 std::unique_ptr<net::URLRequest> https_request_with_port =
1463 CreateURLRequest(GURL("https://www.google.com:666"), net::MEDIUM,
1464 content::RESOURCE_TYPE_IMAGE, true);
1465 EXPECT_FALSE(ResourcePrefetchPredictor::ShouldRecordRequest(
1466 https_request_with_port.get(), content::RESOURCE_TYPE_MAIN_FRAME));
1467 }
1468
1469 TEST_F(ResourcePrefetchPredictorTest, ShouldRecordRequestSubResource) {
1470 std::unique_ptr<net::URLRequest> http_request =
1471 CreateURLRequest(GURL("http://www.google.com/cat.png"), net::MEDIUM,
1472 content::RESOURCE_TYPE_IMAGE, false);
1473 EXPECT_FALSE(ResourcePrefetchPredictor::ShouldRecordRequest(
1474 http_request.get(), content::RESOURCE_TYPE_IMAGE));
1475
1476 std::unique_ptr<net::URLRequest> https_request =
1477 CreateURLRequest(GURL("https://www.google.com/cat.png"), net::MEDIUM,
1478 content::RESOURCE_TYPE_IMAGE, false);
1479 EXPECT_FALSE(ResourcePrefetchPredictor::ShouldRecordRequest(
1480 https_request.get(), content::RESOURCE_TYPE_IMAGE));
1481
1482 std::unique_ptr<net::URLRequest> file_request =
1483 CreateURLRequest(GURL("file://www.google.com/cat.png"), net::MEDIUM,
1484 content::RESOURCE_TYPE_IMAGE, false);
1485 EXPECT_FALSE(ResourcePrefetchPredictor::ShouldRecordRequest(
1486 file_request.get(), content::RESOURCE_TYPE_IMAGE));
1487
1488 std::unique_ptr<net::URLRequest> https_request_with_port =
1489 CreateURLRequest(GURL("https://www.google.com:666/cat.png"), net::MEDIUM,
1490 content::RESOURCE_TYPE_IMAGE, false);
1491 EXPECT_FALSE(ResourcePrefetchPredictor::ShouldRecordRequest(
1492 https_request_with_port.get(), content::RESOURCE_TYPE_IMAGE));
1493 }
1494
1495 TEST_F(ResourcePrefetchPredictorTest, ShouldRecordResponseMainFrame) {
1496 net::HttpResponseInfo response_info;
1497 response_info.headers = MakeResponseHeaders("");
1498 url_request_job_factory_.set_response_info(response_info);
1499
1500 std::unique_ptr<net::URLRequest> http_request =
1501 CreateURLRequest(GURL("http://www.google.com"), net::MEDIUM,
1502 content::RESOURCE_TYPE_MAIN_FRAME, true);
1503 EXPECT_TRUE(
1504 ResourcePrefetchPredictor::ShouldRecordResponse(http_request.get()));
1505
1506 std::unique_ptr<net::URLRequest> https_request =
1507 CreateURLRequest(GURL("https://www.google.com"), net::MEDIUM,
1508 content::RESOURCE_TYPE_MAIN_FRAME, true);
1509 EXPECT_TRUE(
1510 ResourcePrefetchPredictor::ShouldRecordResponse(https_request.get()));
1511
1512 std::unique_ptr<net::URLRequest> file_request =
1513 CreateURLRequest(GURL("file://www.google.com"), net::MEDIUM,
1514 content::RESOURCE_TYPE_MAIN_FRAME, true);
1515 EXPECT_FALSE(
1516 ResourcePrefetchPredictor::ShouldRecordResponse(file_request.get()));
1517
1518 std::unique_ptr<net::URLRequest> https_request_with_port =
1519 CreateURLRequest(GURL("https://www.google.com:666"), net::MEDIUM,
1520 content::RESOURCE_TYPE_MAIN_FRAME, true);
1521 EXPECT_FALSE(ResourcePrefetchPredictor::ShouldRecordResponse(
1522 https_request_with_port.get()));
1523 }
1524
1525 TEST_F(ResourcePrefetchPredictorTest, ShouldRecordResponseSubresource) {
1526 net::HttpResponseInfo response_info;
1527 response_info.headers =
1528 MakeResponseHeaders("HTTP/1.1 200 OK\n\nSome: Headers\n");
1529 response_info.was_cached = true;
1530 url_request_job_factory_.set_response_info(response_info);
1531
1532 // Protocol.
1533 std::unique_ptr<net::URLRequest> http_image_request =
1534 CreateURLRequest(GURL("http://www.google.com/cat.png"), net::MEDIUM,
1535 content::RESOURCE_TYPE_IMAGE, true);
1536 EXPECT_TRUE(ResourcePrefetchPredictor::ShouldRecordResponse(
1537 http_image_request.get()));
1538
1539 std::unique_ptr<net::URLRequest> https_image_request =
1540 CreateURLRequest(GURL("https://www.google.com/cat.png"), net::MEDIUM,
1541 content::RESOURCE_TYPE_IMAGE, true);
1542 EXPECT_TRUE(ResourcePrefetchPredictor::ShouldRecordResponse(
1543 https_image_request.get()));
1544
1545 std::unique_ptr<net::URLRequest> https_image_request_with_port =
1546 CreateURLRequest(GURL("https://www.google.com:666/cat.png"), net::MEDIUM,
1547 content::RESOURCE_TYPE_IMAGE, true);
1548 EXPECT_FALSE(ResourcePrefetchPredictor::ShouldRecordResponse(
1549 https_image_request_with_port.get()));
1550
1551 std::unique_ptr<net::URLRequest> file_image_request =
1552 CreateURLRequest(GURL("file://www.google.com/cat.png"), net::MEDIUM,
1553 content::RESOURCE_TYPE_IMAGE, true);
1554 EXPECT_FALSE(ResourcePrefetchPredictor::ShouldRecordResponse(
1555 file_image_request.get()));
1556
1557 // ResourceType.
1558 std::unique_ptr<net::URLRequest> sub_frame_request =
1559 CreateURLRequest(GURL("http://www.google.com/frame.html"), net::MEDIUM,
1560 content::RESOURCE_TYPE_SUB_FRAME, true);
1561 EXPECT_FALSE(
1562 ResourcePrefetchPredictor::ShouldRecordResponse(sub_frame_request.get()));
1563
1564 std::unique_ptr<net::URLRequest> font_request =
1565 CreateURLRequest(GURL("http://www.google.com/comic-sans-ms.woff"),
1566 net::MEDIUM, content::RESOURCE_TYPE_FONT_RESOURCE, true);
1567 EXPECT_TRUE(
1568 ResourcePrefetchPredictor::ShouldRecordResponse(font_request.get()));
1569
1570 // From MIME Type.
1571 url_request_job_factory_.set_mime_type("image/png");
1572 std::unique_ptr<net::URLRequest> prefetch_image_request =
1573 CreateURLRequest(GURL("http://www.google.com/cat.png"), net::MEDIUM,
1574 content::RESOURCE_TYPE_PREFETCH, true);
1575 EXPECT_TRUE(ResourcePrefetchPredictor::ShouldRecordResponse(
1576 prefetch_image_request.get()));
1577
1578 url_request_job_factory_.set_mime_type("image/my-wonderful-format");
1579 std::unique_ptr<net::URLRequest> prefetch_unknown_image_request =
1580 CreateURLRequest(GURL("http://www.google.com/cat.png"), net::MEDIUM,
1581 content::RESOURCE_TYPE_PREFETCH, true);
1582 EXPECT_FALSE(ResourcePrefetchPredictor::ShouldRecordResponse(
1583 prefetch_unknown_image_request.get()));
1584
1585 url_request_job_factory_.set_mime_type("font/woff");
1586 std::unique_ptr<net::URLRequest> prefetch_font_request =
1587 CreateURLRequest(GURL("http://www.google.com/comic-sans-ms.woff"),
1588 net::MEDIUM, content::RESOURCE_TYPE_PREFETCH, true);
1589 EXPECT_TRUE(ResourcePrefetchPredictor::ShouldRecordResponse(
1590 prefetch_font_request.get()));
1591
1592 url_request_job_factory_.set_mime_type("font/woff-woff");
1593 std::unique_ptr<net::URLRequest> prefetch_unknown_font_request =
1594 CreateURLRequest(GURL("http://www.google.com/comic-sans-ms.woff"),
1595 net::MEDIUM, content::RESOURCE_TYPE_PREFETCH, true);
1596 EXPECT_FALSE(ResourcePrefetchPredictor::ShouldRecordResponse(
1597 prefetch_unknown_font_request.get()));
1598
1599 // Not main frame.
1600 std::unique_ptr<net::URLRequest> font_request_sub_frame = CreateURLRequest(
1601 GURL("http://www.google.com/comic-sans-ms.woff"), net::MEDIUM,
1602 content::RESOURCE_TYPE_FONT_RESOURCE, false);
1603 EXPECT_FALSE(ResourcePrefetchPredictor::ShouldRecordResponse(
1604 font_request_sub_frame.get()));
1605 }
1606
1607 TEST_F(ResourcePrefetchPredictorTest, SummarizeResponse) { 1317 TEST_F(ResourcePrefetchPredictorTest, SummarizeResponse) {
1608 net::HttpResponseInfo response_info; 1318 net::HttpResponseInfo response_info;
1609 response_info.headers = 1319 response_info.headers =
1610 MakeResponseHeaders("HTTP/1.1 200 OK\n\nSome: Headers\n"); 1320 MakeResponseHeaders("HTTP/1.1 200 OK\n\nSome: Headers\n");
1611 response_info.was_cached = true; 1321 response_info.was_cached = true;
1612 url_request_job_factory_.set_response_info(response_info); 1322 url_request_job_factory_.set_response_info(response_info);
1613 1323
1614 GURL url("http://www.google.com/cat.png"); 1324 GURL url("http://www.google.com/cat.png");
1615 std::unique_ptr<net::URLRequest> request = 1325 std::unique_ptr<net::URLRequest> request =
1616 CreateURLRequest(url, net::MEDIUM, content::RESOURCE_TYPE_IMAGE, true); 1326 CreateURLRequest(url_request_context_, url, net::MEDIUM,
1327 content::RESOURCE_TYPE_IMAGE, true);
1617 URLRequestSummary summary; 1328 URLRequestSummary summary;
1618 EXPECT_TRUE(URLRequestSummary::SummarizeResponse(*request, &summary)); 1329 EXPECT_TRUE(URLRequestSummary::SummarizeResponse(*request, &summary));
1619 EXPECT_EQ(url, summary.resource_url); 1330 EXPECT_EQ(url, summary.resource_url);
1620 EXPECT_EQ(content::RESOURCE_TYPE_IMAGE, summary.resource_type); 1331 EXPECT_EQ(content::RESOURCE_TYPE_IMAGE, summary.resource_type);
1621 EXPECT_TRUE(summary.was_cached); 1332 EXPECT_TRUE(summary.was_cached);
1622 EXPECT_FALSE(summary.has_validators); 1333 EXPECT_FALSE(summary.has_validators);
1623 EXPECT_FALSE(summary.always_revalidate); 1334 EXPECT_FALSE(summary.always_revalidate);
1624 1335
1625 // Navigation_id elements should be unset by default. 1336 // Navigation_id elements should be unset by default.
1626 EXPECT_EQ(-1, summary.navigation_id.tab_id); 1337 EXPECT_EQ(-1, summary.navigation_id.tab_id);
1627 EXPECT_EQ(GURL(), summary.navigation_id.main_frame_url); 1338 EXPECT_EQ(GURL(), summary.navigation_id.main_frame_url);
1628 } 1339 }
1629 1340
1630 TEST_F(ResourcePrefetchPredictorTest, SummarizeResponseContentType) { 1341 TEST_F(ResourcePrefetchPredictorTest, SummarizeResponseContentType) {
1631 net::HttpResponseInfo response_info; 1342 net::HttpResponseInfo response_info;
1632 response_info.headers = MakeResponseHeaders( 1343 response_info.headers = MakeResponseHeaders(
1633 "HTTP/1.1 200 OK\n\n" 1344 "HTTP/1.1 200 OK\n\n"
1634 "Some: Headers\n" 1345 "Some: Headers\n"
1635 "Content-Type: image/whatever\n"); 1346 "Content-Type: image/whatever\n");
1636 url_request_job_factory_.set_response_info(response_info); 1347 url_request_job_factory_.set_response_info(response_info);
1637 url_request_job_factory_.set_mime_type("image/png"); 1348 url_request_job_factory_.set_mime_type("image/png");
1638 1349
1639 std::unique_ptr<net::URLRequest> request = 1350 std::unique_ptr<net::URLRequest> request = CreateURLRequest(
1640 CreateURLRequest(GURL("http://www.google.com/cat.png"), net::MEDIUM, 1351 url_request_context_, GURL("http://www.google.com/cat.png"), net::MEDIUM,
1641 content::RESOURCE_TYPE_PREFETCH, true); 1352 content::RESOURCE_TYPE_PREFETCH, true);
1642 URLRequestSummary summary; 1353 URLRequestSummary summary;
1643 EXPECT_TRUE(URLRequestSummary::SummarizeResponse(*request, &summary)); 1354 EXPECT_TRUE(URLRequestSummary::SummarizeResponse(*request, &summary));
1644 EXPECT_EQ(content::RESOURCE_TYPE_IMAGE, summary.resource_type); 1355 EXPECT_EQ(content::RESOURCE_TYPE_IMAGE, summary.resource_type);
1645 } 1356 }
1646 1357
1647 TEST_F(ResourcePrefetchPredictorTest, SummarizeResponseCachePolicy) { 1358 TEST_F(ResourcePrefetchPredictorTest, SummarizeResponseCachePolicy) {
1648 net::HttpResponseInfo response_info; 1359 net::HttpResponseInfo response_info;
1649 response_info.headers = MakeResponseHeaders( 1360 response_info.headers = MakeResponseHeaders(
1650 "HTTP/1.1 200 OK\n" 1361 "HTTP/1.1 200 OK\n"
1651 "Some: Headers\n"); 1362 "Some: Headers\n");
1652 url_request_job_factory_.set_response_info(response_info); 1363 url_request_job_factory_.set_response_info(response_info);
1653 1364
1654 std::unique_ptr<net::URLRequest> request_no_validators = 1365 std::unique_ptr<net::URLRequest> request_no_validators = CreateURLRequest(
1655 CreateURLRequest(GURL("http://www.google.com/cat.png"), net::MEDIUM, 1366 url_request_context_, GURL("http://www.google.com/cat.png"), net::MEDIUM,
1656 content::RESOURCE_TYPE_PREFETCH, true); 1367 content::RESOURCE_TYPE_PREFETCH, true);
1657 1368
1658 URLRequestSummary summary; 1369 URLRequestSummary summary;
1659 EXPECT_TRUE( 1370 EXPECT_TRUE(
1660 URLRequestSummary::SummarizeResponse(*request_no_validators, &summary)); 1371 URLRequestSummary::SummarizeResponse(*request_no_validators, &summary));
1661 EXPECT_FALSE(summary.has_validators); 1372 EXPECT_FALSE(summary.has_validators);
1662 1373
1663 response_info.headers = MakeResponseHeaders( 1374 response_info.headers = MakeResponseHeaders(
1664 "HTTP/1.1 200 OK\n" 1375 "HTTP/1.1 200 OK\n"
1665 "ETag: \"Cr66\"\n" 1376 "ETag: \"Cr66\"\n"
1666 "Cache-Control: no-cache\n"); 1377 "Cache-Control: no-cache\n");
1667 url_request_job_factory_.set_response_info(response_info); 1378 url_request_job_factory_.set_response_info(response_info);
1668 std::unique_ptr<net::URLRequest> request_etag = 1379 std::unique_ptr<net::URLRequest> request_etag = CreateURLRequest(
1669 CreateURLRequest(GURL("http://www.google.com/cat.png"), net::MEDIUM, 1380 url_request_context_, GURL("http://www.google.com/cat.png"), net::MEDIUM,
1670 content::RESOURCE_TYPE_PREFETCH, true); 1381 content::RESOURCE_TYPE_PREFETCH, true);
1671 EXPECT_TRUE(URLRequestSummary::SummarizeResponse(*request_etag, &summary)); 1382 EXPECT_TRUE(URLRequestSummary::SummarizeResponse(*request_etag, &summary));
1672 EXPECT_TRUE(summary.has_validators); 1383 EXPECT_TRUE(summary.has_validators);
1673 EXPECT_TRUE(summary.always_revalidate); 1384 EXPECT_TRUE(summary.always_revalidate);
1674 } 1385 }
1675 1386
1676 TEST_F(ResourcePrefetchPredictorTest, PopulatePrefetcherRequest) { 1387 TEST_F(ResourcePrefetchPredictorTest, PopulatePrefetcherRequest) {
1677 // The data that will be used in populating. 1388 // The data that will be used in populating.
1678 PrefetchData google = CreatePrefetchData("http://www.google.com/", 1); 1389 PrefetchData google = CreatePrefetchData("http://www.google.com/", 1);
1679 InitializeResourceData(google.add_resources(), "http://google.com/image1.png", 1390 InitializeResourceData(google.add_resources(), "http://google.com/image1.png",
1680 content::RESOURCE_TYPE_IMAGE, 10, 0, 0, 2.2, 1391 content::RESOURCE_TYPE_IMAGE, 10, 0, 0, 2.2,
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 ResourceData* resource3_rd = host_data.add_resources(); 1673 ResourceData* resource3_rd = host_data.add_resources();
1963 InitializeResourceData(resource3_rd, "http://google.com/script2.js", 1674 InitializeResourceData(resource3_rd, "http://google.com/script2.js",
1964 content::RESOURCE_TYPE_SCRIPT, 1, 0, 0, 3.0, 1675 content::RESOURCE_TYPE_SCRIPT, 1, 0, 0, 3.0,
1965 net::MEDIUM, false, false); 1676 net::MEDIUM, false, false);
1966 resource3_rd->set_before_first_contentful_paint(false); 1677 resource3_rd->set_before_first_contentful_paint(false);
1967 EXPECT_EQ(mock_tables_->host_resource_table_.data_, 1678 EXPECT_EQ(mock_tables_->host_resource_table_.data_,
1968 PrefetchDataMap({{host_data.primary_key(), host_data}})); 1679 PrefetchDataMap({{host_data.primary_key(), host_data}}));
1969 } 1680 }
1970 1681
1971 } // namespace predictors 1682 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698