| 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 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 246 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 |