OLD | NEW |
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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 void SetUp() override { | 171 void SetUp() override { |
172 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 172 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
173 switches::kPrecacheConfigSettingsURL, kConfigURL); | 173 switches::kPrecacheConfigSettingsURL, kConfigURL); |
174 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 174 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
175 switches::kPrecacheManifestURLPrefix, kManifestURLPrefix); | 175 switches::kPrecacheManifestURLPrefix, kManifestURLPrefix); |
176 std::unique_ptr<PrecacheDatabase> precache_database( | 176 std::unique_ptr<PrecacheDatabase> precache_database( |
177 new PrecacheDatabase()); | 177 new PrecacheDatabase()); |
178 precache_database_ = precache_database.get(); | 178 precache_database_ = precache_database.get(); |
179 | 179 |
180 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); | 180 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); |
181 base::FilePath db_path = scoped_temp_dir_.path().Append( | 181 base::FilePath db_path = scoped_temp_dir_.GetPath().Append( |
182 base::FilePath(FILE_PATH_LITERAL("precache_database"))); | 182 base::FilePath(FILE_PATH_LITERAL("precache_database"))); |
183 | 183 |
184 // Make the fetch of the precache configuration settings fail. Precaching | 184 // Make the fetch of the precache configuration settings fail. Precaching |
185 // should still complete normally in this case. | 185 // should still complete normally in this case. |
186 factory_.SetFakeResponse(GURL(kConfigURL), "", | 186 factory_.SetFakeResponse(GURL(kConfigURL), "", |
187 net::HTTP_INTERNAL_SERVER_ERROR, | 187 net::HTTP_INTERNAL_SERVER_ERROR, |
188 net::URLRequestStatus::FAILED); | 188 net::URLRequestStatus::FAILED); |
189 precache_manager_.reset( | 189 precache_manager_.reset( |
190 new PrecacheManagerUnderTest( | 190 new PrecacheManagerUnderTest( |
191 &browser_context_, nullptr /* sync_service */, | 191 &browser_context_, nullptr /* sync_service */, |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 expected_histogram_count_map["Precache.Saved"] += 2; | 561 expected_histogram_count_map["Precache.Saved"] += 2; |
562 expected_histogram_count_map["Precache.TimeSinceLastPrecache"] += 2; | 562 expected_histogram_count_map["Precache.TimeSinceLastPrecache"] += 2; |
563 expected_histogram_count_map["Precache.Saved.Freshness"] = 2; | 563 expected_histogram_count_map["Precache.Saved.Freshness"] = 2; |
564 | 564 |
565 base::RunLoop().RunUntilIdle(); | 565 base::RunLoop().RunUntilIdle(); |
566 EXPECT_THAT(histograms_.GetTotalCountsForPrefix("Precache."), | 566 EXPECT_THAT(histograms_.GetTotalCountsForPrefix("Precache."), |
567 ContainerEq(expected_histogram_count_map)); | 567 ContainerEq(expected_histogram_count_map)); |
568 } | 568 } |
569 | 569 |
570 } // namespace precache | 570 } // namespace precache |
OLD | NEW |