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

Side by Side Diff: components/precache/content/precache_manager_unittest.cc

Issue 2544613003: Disable precache if data_reduction_proxy enabled. (Closed)
Patch Set: Rebase. Created 4 years 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 | « components/precache/content/precache_manager.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/precache/content/precache_manager.h" 5 #include "components/precache/content/precache_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 bool was_on_done_called() const { 120 bool was_on_done_called() const {
121 return was_on_done_called_; 121 return was_on_done_called_;
122 } 122 }
123 123
124 private: 124 private:
125 bool was_on_done_called_; 125 bool was_on_done_called_;
126 }; 126 };
127 127
128 class PrecacheManagerUnderTest : public PrecacheManager { 128 class PrecacheManagerUnderTest : public PrecacheManager {
129 public: 129 public:
130 PrecacheManagerUnderTest(content::BrowserContext* browser_context, 130 PrecacheManagerUnderTest(
131 const syncer::SyncService* const sync_service, 131 content::BrowserContext* browser_context,
132 const history::HistoryService* const history_service, 132 const syncer::SyncService* sync_service,
133 const base::FilePath& db_path, 133 const history::HistoryService* history_service,
134 std::unique_ptr<PrecacheDatabase> precache_database) 134 const data_reduction_proxy::DataReductionProxySettings*
135 data_reduction_proxy_settings,
136 const base::FilePath& db_path,
137 std::unique_ptr<PrecacheDatabase> precache_database)
135 : PrecacheManager(browser_context, 138 : PrecacheManager(browser_context,
136 sync_service, 139 sync_service,
137 history_service, 140 history_service,
141 data_reduction_proxy_settings,
138 db_path, 142 db_path,
139 std::move(precache_database)), 143 std::move(precache_database)),
140 control_group_(false) {} 144 control_group_(false) {}
141 bool IsInExperimentGroup() const override { return !control_group_; } 145 bool IsInExperimentGroup() const override { return !control_group_; }
142 bool IsInControlGroup() const override { return control_group_; } 146 bool IsInControlGroup() const override { return control_group_; }
143 bool IsPrecachingAllowed() const override { return true; } 147 bool IsPrecachingAllowed() const override { return true; }
144 void SetInControlGroup(bool in_control_group) { 148 void SetInControlGroup(bool in_control_group) {
145 control_group_ = in_control_group; 149 control_group_ = in_control_group;
146 } 150 }
147 151
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 183
180 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); 184 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir());
181 base::FilePath db_path = scoped_temp_dir_.GetPath().Append( 185 base::FilePath db_path = scoped_temp_dir_.GetPath().Append(
182 base::FilePath(FILE_PATH_LITERAL("precache_database"))); 186 base::FilePath(FILE_PATH_LITERAL("precache_database")));
183 187
184 // Make the fetch of the precache configuration settings fail. Precaching 188 // Make the fetch of the precache configuration settings fail. Precaching
185 // should still complete normally in this case. 189 // should still complete normally in this case.
186 factory_.SetFakeResponse(GURL(kConfigURL), "", 190 factory_.SetFakeResponse(GURL(kConfigURL), "",
187 net::HTTP_INTERNAL_SERVER_ERROR, 191 net::HTTP_INTERNAL_SERVER_ERROR,
188 net::URLRequestStatus::FAILED); 192 net::URLRequestStatus::FAILED);
189 precache_manager_.reset( 193 precache_manager_.reset(new PrecacheManagerUnderTest(
190 new PrecacheManagerUnderTest( 194 &browser_context_, nullptr /* sync_service */, &history_service_,
191 &browser_context_, nullptr /* sync_service */, 195 nullptr /* data_reduction_proxy_settings */, db_path,
192 &history_service_, db_path, std::move(precache_database))); 196 std::move(precache_database)));
193 base::RunLoop().RunUntilIdle(); 197 base::RunLoop().RunUntilIdle();
194 198
195 info_.headers = new net::HttpResponseHeaders(""); 199 info_.headers = new net::HttpResponseHeaders("");
196 } 200 }
197 201
198 void RecordStatsForPrecacheFetch(const GURL& url, 202 void RecordStatsForPrecacheFetch(const GURL& url,
199 const std::string& referrer_host, 203 const std::string& referrer_host,
200 const base::TimeDelta& latency, 204 const base::TimeDelta& latency,
201 const base::Time& fetch_time, 205 const base::Time& fetch_time,
202 const net::HttpResponseInfo& info, 206 const net::HttpResponseInfo& info,
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 expected_histogram_count_map["Precache.Saved"] += 2; 567 expected_histogram_count_map["Precache.Saved"] += 2;
564 expected_histogram_count_map["Precache.TimeSinceLastPrecache"] += 2; 568 expected_histogram_count_map["Precache.TimeSinceLastPrecache"] += 2;
565 expected_histogram_count_map["Precache.Saved.Freshness"] = 2; 569 expected_histogram_count_map["Precache.Saved.Freshness"] = 2;
566 570
567 base::RunLoop().RunUntilIdle(); 571 base::RunLoop().RunUntilIdle();
568 EXPECT_THAT(histograms_.GetTotalCountsForPrefix("Precache."), 572 EXPECT_THAT(histograms_.GetTotalCountsForPrefix("Precache."),
569 ContainerEq(expected_histogram_count_map)); 573 ContainerEq(expected_histogram_count_map));
570 } 574 }
571 575
572 } // namespace precache 576 } // namespace precache
OLDNEW
« no previous file with comments | « components/precache/content/precache_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698