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 <list> | 7 #include <list> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 std::multiset<GURL> requested_urls_; | 82 std::multiset<GURL> requested_urls_; |
83 }; | 83 }; |
84 | 84 |
85 class FakeURLListProvider : public URLListProvider { | 85 class FakeURLListProvider : public URLListProvider { |
86 public: | 86 public: |
87 FakeURLListProvider(const std::list<GURL>& urls, bool run_immediately) | 87 FakeURLListProvider(const std::list<GURL>& urls, bool run_immediately) |
88 : urls_(urls), | 88 : urls_(urls), |
89 run_immediately_(run_immediately), | 89 run_immediately_(run_immediately), |
90 was_get_urls_called_(false) {} | 90 was_get_urls_called_(false) {} |
91 | 91 |
92 virtual void GetURLs(const GetURLsCallback& callback) OVERRIDE { | 92 virtual void GetURLs(const GetURLsCallback& callback) override { |
93 was_get_urls_called_ = true; | 93 was_get_urls_called_ = true; |
94 | 94 |
95 if (run_immediately_) { | 95 if (run_immediately_) { |
96 callback.Run(urls_); | 96 callback.Run(urls_); |
97 } else { | 97 } else { |
98 // Post the callback to be run later in the message loop. | 98 // Post the callback to be run later in the message loop. |
99 base::MessageLoop::current()->PostTask(FROM_HERE, | 99 base::MessageLoop::current()->PostTask(FROM_HERE, |
100 base::Bind(callback, urls_)); | 100 base::Bind(callback, urls_)); |
101 } | 101 } |
102 } | 102 } |
(...skipping 30 matching lines...) Expand all Loading... |
133 }; | 133 }; |
134 | 134 |
135 class PrecacheManagerTest : public testing::Test { | 135 class PrecacheManagerTest : public testing::Test { |
136 public: | 136 public: |
137 PrecacheManagerTest() | 137 PrecacheManagerTest() |
138 : precache_manager_(&browser_context_), | 138 : precache_manager_(&browser_context_), |
139 factory_(NULL, base::Bind(&TestURLFetcherCallback::CreateURLFetcher, | 139 factory_(NULL, base::Bind(&TestURLFetcherCallback::CreateURLFetcher, |
140 base::Unretained(&url_callback_))) {} | 140 base::Unretained(&url_callback_))) {} |
141 | 141 |
142 protected: | 142 protected: |
143 virtual void SetUp() OVERRIDE { | 143 virtual void SetUp() override { |
144 base::StatisticsRecorder::Initialize(); | 144 base::StatisticsRecorder::Initialize(); |
145 | 145 |
146 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 146 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
147 switches::kPrecacheConfigSettingsURL, kConfigURL); | 147 switches::kPrecacheConfigSettingsURL, kConfigURL); |
148 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 148 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
149 switches::kPrecacheManifestURLPrefix, kManifestURLPrefix); | 149 switches::kPrecacheManifestURLPrefix, kManifestURLPrefix); |
150 | 150 |
151 // Make the fetch of the precache configuration settings fail. Precaching | 151 // Make the fetch of the precache configuration settings fail. Precaching |
152 // should still complete normally in this case. | 152 // should still complete normally in this case. |
153 factory_.SetFakeResponse(GURL(kConfigURL), "", | 153 factory_.SetFakeResponse(GURL(kConfigURL), "", |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 kCurrentTime, 1000, true); | 349 kCurrentTime, 1000, true); |
350 expected_histogram_count_map["Precache.Saved"] += 2; | 350 expected_histogram_count_map["Precache.Saved"] += 2; |
351 | 351 |
352 base::MessageLoop::current()->RunUntilIdle(); | 352 base::MessageLoop::current()->RunUntilIdle(); |
353 EXPECT_EQ(expected_histogram_count_map, GetHistogramCountMap()); | 353 EXPECT_EQ(expected_histogram_count_map, GetHistogramCountMap()); |
354 } | 354 } |
355 | 355 |
356 } // namespace | 356 } // namespace |
357 | 357 |
358 } // namespace precache | 358 } // namespace precache |
OLD | NEW |