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

Side by Side Diff: components/precache/core/precache_database_unittest.cc

Issue 2586813004: Report downloaded resources at most once (Closed)
Patch Set: Fix race condition in PrecacheFetcherTest due to MaybePost 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
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/core/precache_database.h" 5 #include "components/precache/core/precache_database.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/bind.h"
13 #include "base/bind_helpers.h"
12 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
13 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
14 #include "base/files/scoped_temp_dir.h" 16 #include "base/files/scoped_temp_dir.h"
15 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
16 #include "base/metrics/histogram_base.h" 18 #include "base/metrics/histogram_base.h"
17 #include "base/test/histogram_tester.h" 19 #include "base/test/histogram_tester.h"
18 #include "base/time/time.h" 20 #include "base/time/time.h"
19 #include "components/history/core/browser/history_constants.h" 21 #include "components/history/core/browser/history_constants.h"
20 #include "net/http/http_response_headers.h" 22 #include "net/http/http_response_headers.h"
21 #include "net/http/http_response_info.h" 23 #include "net/http/http_response_info.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 86
85 } // namespace 87 } // namespace
86 88
87 namespace precache { 89 namespace precache {
88 90
89 class PrecacheDatabaseTest : public testing::Test { 91 class PrecacheDatabaseTest : public testing::Test {
90 public: 92 public:
91 PrecacheDatabaseTest() {} 93 PrecacheDatabaseTest() {}
92 ~PrecacheDatabaseTest() override {} 94 ~PrecacheDatabaseTest() override {}
93 95
96 void SqlErrorCallback(int line, sql::Statement* statement) {
97 LOG(INFO) << "SQL error at line " << line << ": "
98 << statement->GetSQLStatement();
99 }
100
94 protected: 101 protected:
95 void SetUp() override { 102 void SetUp() override {
96 precache_database_.reset(new PrecacheDatabase()); 103 precache_database_.reset(new PrecacheDatabase());
97 104
98 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); 105 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir());
99 base::FilePath db_path = scoped_temp_dir_.GetPath().Append( 106 base::FilePath db_path = scoped_temp_dir_.GetPath().Append(
100 base::FilePath(FILE_PATH_LITERAL("precache_database"))); 107 base::FilePath(FILE_PATH_LITERAL("precache_database")));
101 ASSERT_TRUE(precache_database_->Init(db_path)); 108 ASSERT_TRUE(precache_database_->Init(db_path));
109 precache_database_->db_->set_error_callback(base::Bind(
110 &PrecacheDatabaseTest::SqlErrorCallback, base::Unretained(this)));
102 } 111 }
103 112
104 void TearDown() override { precache_url_table()->DeleteAll(); } 113 void TearDown() override { precache_url_table()->DeleteAll(); }
105 114
106 std::map<GURL, base::Time> GetActualURLTableMap() { 115 std::map<GURL, base::Time> GetActualURLTableMap() {
107 // Flush any buffered writes so that the URL table will be up to date. 116 // Flush any buffered writes so that the URL table will be up to date.
108 precache_database_->Flush(); 117 precache_database_->Flush();
109 118
110 std::map<GURL, base::Time> url_table_map; 119 std::map<GURL, base::Time> url_table_map;
111 precache_url_table()->GetAllDataForTesting(&url_table_map); 120 precache_url_table()->GetAllDataForTesting(&url_table_map);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 265
257 EXPECT_EQ(BuildURLTableMap(kURL, kFetchTime), GetActualURLTableMap()); 266 EXPECT_EQ(BuildURLTableMap(kURL, kFetchTime), GetActualURLTableMap());
258 267
259 ExpectNewSample("Precache.DownloadedPrecacheMotivated", kSize); 268 ExpectNewSample("Precache.DownloadedPrecacheMotivated", kSize);
260 ExpectNewSample("Precache.Latency.Prefetch", kLatency.InMilliseconds()); 269 ExpectNewSample("Precache.Latency.Prefetch", kLatency.InMilliseconds());
261 ExpectNewSample("Precache.Freshness.Prefetch", kFreshnessBucket10K); 270 ExpectNewSample("Precache.Freshness.Prefetch", kFreshnessBucket10K);
262 ExpectNoOtherSamples(); 271 ExpectNoOtherSamples();
263 } 272 }
264 273
265 TEST_F(PrecacheDatabaseTest, PrecacheFromCacheWithURLTableEntry) { 274 TEST_F(PrecacheDatabaseTest, PrecacheFromCacheWithURLTableEntry) {
266 precache_url_table()->AddURL(kURL, kReferrerID, true, kOldFetchTime); 275 precache_url_table()->AddURL(kURL, kReferrerID, true, true, kOldFetchTime);
267 RecordPrecacheFromCache(kURL, kFetchTime, kSize); 276 RecordPrecacheFromCache(kURL, kFetchTime, kSize);
268 277
269 // The URL table entry should have been updated to have |kFetchTime| as the 278 // The URL table entry should have been updated to have |kFetchTime| as the
270 // timestamp. 279 // timestamp.
271 EXPECT_EQ(BuildURLTableMap(kURL, kFetchTime), GetActualURLTableMap()); 280 EXPECT_EQ(BuildURLTableMap(kURL, kFetchTime), GetActualURLTableMap());
272 281
273 ExpectNewSample("Precache.Latency.Prefetch", 0); 282 ExpectNewSample("Precache.Latency.Prefetch", 0);
274 ExpectNewSample("Precache.Freshness.Prefetch", kFreshnessBucket10K); 283 ExpectNewSample("Precache.Freshness.Prefetch", kFreshnessBucket10K);
275 ExpectNoOtherSamples(); 284 ExpectNoOtherSamples();
276 } 285 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 ExpectNewSample("Precache.DownloadedNonPrecache", kSize); 328 ExpectNewSample("Precache.DownloadedNonPrecache", kSize);
320 ExpectNewSample("Precache.DownloadedNonPrecache.Cellular", kSize); 329 ExpectNewSample("Precache.DownloadedNonPrecache.Cellular", kSize);
321 ExpectNewSample("Precache.CacheStatus.NonPrefetch", kFromNetwork); 330 ExpectNewSample("Precache.CacheStatus.NonPrefetch", kFromNetwork);
322 ExpectNewSample("Precache.Latency.NonPrefetch", kLatency.InMilliseconds()); 331 ExpectNewSample("Precache.Latency.NonPrefetch", kLatency.InMilliseconds());
323 ExpectNewSample("Precache.Latency.NonPrefetch.NonTopHosts", 332 ExpectNewSample("Precache.Latency.NonPrefetch.NonTopHosts",
324 kLatency.InMilliseconds()); 333 kLatency.InMilliseconds());
325 ExpectNoOtherSamples(); 334 ExpectNoOtherSamples();
326 } 335 }
327 336
328 TEST_F(PrecacheDatabaseTest, FetchOverNetworkWithURLTableEntry) { 337 TEST_F(PrecacheDatabaseTest, FetchOverNetworkWithURLTableEntry) {
329 precache_url_table()->AddURL(kURL, kReferrerID, true, kOldFetchTime); 338 precache_url_table()->AddURL(kURL, kReferrerID, true, true, kOldFetchTime);
330 RecordFetchFromNetwork(kURL, kLatency, kFetchTime, kSize); 339 RecordFetchFromNetwork(kURL, kLatency, kFetchTime, kSize);
331 340
332 // The URL table entry should have been deleted. 341 // The URL table entry should have been deleted.
333 EXPECT_TRUE(GetActualURLTableMap().empty()); 342 EXPECT_TRUE(GetActualURLTableMap().empty());
334 343
335 ExpectNewSample("Precache.DownloadedNonPrecache", kSize); 344 ExpectNewSample("Precache.DownloadedNonPrecache", kSize);
336 ExpectNewSample("Precache.Latency.NonPrefetch", kLatency.InMilliseconds()); 345 ExpectNewSample("Precache.Latency.NonPrefetch", kLatency.InMilliseconds());
337 ExpectNewSample("Precache.Latency.NonPrefetch.NonTopHosts", 346 ExpectNewSample("Precache.Latency.NonPrefetch.NonTopHosts",
338 kLatency.InMilliseconds()); 347 kLatency.InMilliseconds());
339 ExpectNewSample("Precache.CacheStatus.NonPrefetch", kFromNetwork); 348 ExpectNewSample("Precache.CacheStatus.NonPrefetch", kFromNetwork);
340 ExpectNewSample("Precache.CacheStatus.NonPrefetch.FromPrecache", 349 ExpectNewSample("Precache.CacheStatus.NonPrefetch.FromPrecache",
341 kFromNetwork); 350 kFromNetwork);
342 ExpectNoOtherSamples(); 351 ExpectNoOtherSamples();
343 } 352 }
344 353
345 TEST_F(PrecacheDatabaseTest, FetchFromCacheWithURLTableEntry_NonCellular) { 354 TEST_F(PrecacheDatabaseTest, FetchFromCacheWithURLTableEntry_NonCellular) {
346 precache_url_table()->AddURL(kURL, kReferrerID, true, kOldFetchTime); 355 precache_url_table()->AddURL(kURL, kReferrerID, true, true, kOldFetchTime);
347 RecordFetchFromCache(kURL, kFetchTime, kSize); 356 RecordFetchFromCache(kURL, kFetchTime, kSize);
348 357
349 // The URL table entry should have been deleted. 358 // The URL table entry should have been deleted.
350 EXPECT_TRUE(GetActualURLTableMap().empty()); 359 EXPECT_TRUE(GetActualURLTableMap().empty());
351 360
352 ExpectNewSample("Precache.Latency.NonPrefetch", 0); 361 ExpectNewSample("Precache.Latency.NonPrefetch", 0);
353 ExpectNewSample("Precache.Latency.NonPrefetch.NonTopHosts", 0); 362 ExpectNewSample("Precache.Latency.NonPrefetch.NonTopHosts", 0);
354 ExpectNewSample("Precache.CacheStatus.NonPrefetch", 363 ExpectNewSample("Precache.CacheStatus.NonPrefetch",
355 HttpResponseInfo::CacheEntryStatus::ENTRY_USED); 364 HttpResponseInfo::CacheEntryStatus::ENTRY_USED);
356 ExpectNewSample("Precache.CacheStatus.NonPrefetch.FromPrecache", 365 ExpectNewSample("Precache.CacheStatus.NonPrefetch.FromPrecache",
357 HttpResponseInfo::CacheEntryStatus::ENTRY_USED); 366 HttpResponseInfo::CacheEntryStatus::ENTRY_USED);
358 ExpectNewSample("Precache.Saved", kSize); 367 ExpectNewSample("Precache.Saved", kSize);
359 ExpectNewSample("Precache.Saved.Freshness", kFreshnessBucket10K); 368 ExpectNewSample("Precache.Saved.Freshness", kFreshnessBucket10K);
360 ExpectNoOtherSamples(); 369 ExpectNoOtherSamples();
361 } 370 }
362 371
363 TEST_F(PrecacheDatabaseTest, FetchFromCacheWithURLTableEntry_Cellular) { 372 TEST_F(PrecacheDatabaseTest, FetchFromCacheWithURLTableEntry_Cellular) {
364 precache_url_table()->AddURL(kURL, kReferrerID, true, kOldFetchTime); 373 precache_url_table()->AddURL(kURL, kReferrerID, true, true, kOldFetchTime);
365 RecordFetchFromCacheCellular(kURL, kFetchTime, kSize); 374 RecordFetchFromCacheCellular(kURL, kFetchTime, kSize);
366 375
367 // The URL table entry should have been deleted. 376 // The URL table entry should have been deleted.
368 EXPECT_TRUE(GetActualURLTableMap().empty()); 377 EXPECT_TRUE(GetActualURLTableMap().empty());
369 378
370 ExpectNewSample("Precache.Latency.NonPrefetch", 0); 379 ExpectNewSample("Precache.Latency.NonPrefetch", 0);
371 ExpectNewSample("Precache.Latency.NonPrefetch.NonTopHosts", 0); 380 ExpectNewSample("Precache.Latency.NonPrefetch.NonTopHosts", 0);
372 ExpectNewSample("Precache.CacheStatus.NonPrefetch", 381 ExpectNewSample("Precache.CacheStatus.NonPrefetch",
373 HttpResponseInfo::CacheEntryStatus::ENTRY_USED); 382 HttpResponseInfo::CacheEntryStatus::ENTRY_USED);
374 ExpectNewSample("Precache.CacheStatus.NonPrefetch.FromPrecache", 383 ExpectNewSample("Precache.CacheStatus.NonPrefetch.FromPrecache",
(...skipping 15 matching lines...) Expand all
390 HttpResponseInfo::CacheEntryStatus::ENTRY_USED); 399 HttpResponseInfo::CacheEntryStatus::ENTRY_USED);
391 ExpectNoOtherSamples(); 400 ExpectNoOtherSamples();
392 } 401 }
393 402
394 TEST_F(PrecacheDatabaseTest, DeleteExpiredPrecacheHistory) { 403 TEST_F(PrecacheDatabaseTest, DeleteExpiredPrecacheHistory) {
395 const base::Time kToday = base::Time() + base::TimeDelta::FromDays(1000); 404 const base::Time kToday = base::Time() + base::TimeDelta::FromDays(1000);
396 const base::Time k59DaysAgo = kToday - base::TimeDelta::FromDays(59); 405 const base::Time k59DaysAgo = kToday - base::TimeDelta::FromDays(59);
397 const base::Time k61DaysAgo = kToday - base::TimeDelta::FromDays(61); 406 const base::Time k61DaysAgo = kToday - base::TimeDelta::FromDays(61);
398 407
399 precache_url_table()->AddURL(GURL("http://expired-precache.com"), kReferrerID, 408 precache_url_table()->AddURL(GURL("http://expired-precache.com"), kReferrerID,
400 true, k61DaysAgo); 409 true, true, k61DaysAgo);
401 precache_url_table()->AddURL(GURL("http://old-precache.com"), kReferrerID, 410 precache_url_table()->AddURL(GURL("http://old-precache.com"), kReferrerID,
402 true, k59DaysAgo); 411 true, true, k59DaysAgo);
403 412
404 precache_database_->DeleteExpiredPrecacheHistory(kToday); 413 precache_database_->DeleteExpiredPrecacheHistory(kToday);
405 414
406 EXPECT_EQ(BuildURLTableMap(GURL("http://old-precache.com"), k59DaysAgo), 415 EXPECT_EQ(BuildURLTableMap(GURL("http://old-precache.com"), k59DaysAgo),
407 GetActualURLTableMap()); 416 GetActualURLTableMap());
408 } 417 }
409 418
410 TEST_F(PrecacheDatabaseTest, SampleInteraction) { 419 TEST_F(PrecacheDatabaseTest, SampleInteraction) {
411 const GURL kURL1("http://url1.com"); 420 const GURL kURL1("http://url1.com");
412 const int64_t kSize1 = 1; 421 const int64_t kSize1 = 1;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 EXPECT_EQ(kNewFetchTime, actual_entry.time); 535 EXPECT_EQ(kNewFetchTime, actual_entry.time);
527 } 536 }
528 537
529 TEST_F(PrecacheDatabaseTest, GetURLListForReferrerHost) { 538 TEST_F(PrecacheDatabaseTest, GetURLListForReferrerHost) {
530 precache_database_->UpdatePrecacheReferrerHost("foo.com", 1, kFetchTime); 539 precache_database_->UpdatePrecacheReferrerHost("foo.com", 1, kFetchTime);
531 precache_database_->UpdatePrecacheReferrerHost("bar.com", 2, kNewFetchTime); 540 precache_database_->UpdatePrecacheReferrerHost("bar.com", 2, kNewFetchTime);
532 precache_database_->UpdatePrecacheReferrerHost("foobar.com", 3, 541 precache_database_->UpdatePrecacheReferrerHost("foobar.com", 3,
533 kNewFetchTime); 542 kNewFetchTime);
534 precache_database_->UpdatePrecacheReferrerHost("empty.com", 3, kNewFetchTime); 543 precache_database_->UpdatePrecacheReferrerHost("empty.com", 3, kNewFetchTime);
535 544
545 // Add two resources that shouldn't appear in downloaded.
546 Flush(); // We need to write the referrer_host_id.
547 const std::string already_reported_and_not_refetch =
548 "http://foo.com/already-reported-and-not-refetch.js";
549
550 precache_database_->RecordURLPrefetch(GURL(already_reported_and_not_refetch),
551 "foo.com", kPrecacheTime, false, kSize);
552 const std::string already_reported_and_in_cache =
553 "http://foo.com/already-reported-and-in-cache.js";
554 precache_database_->RecordURLPrefetch(GURL(already_reported_and_in_cache),
555 "foo.com", kPrecacheTime, false, kSize);
556 {
557 std::vector<GURL> unused_a, unused_b;
558 auto id = precache_database_->GetReferrerHost("foo.com").id;
559 CHECK_NE(PrecacheReferrerHostEntry::kInvalidId, id);
twifkak 2016/12/20 01:41:59 Per the last bullet of https://chromium.googlesour
jamartin 2016/12/20 21:09:34 Done.
560 precache_database_->GetURLListForReferrerHost(id, &unused_a, &unused_b);
twifkak 2016/12/20 01:41:59 I assume the purpose of this call is to mark the a
jamartin 2016/12/20 21:09:34 Done.
561 }
562
536 struct test_resource_info { 563 struct test_resource_info {
537 std::string url; 564 std::string url;
538 bool is_user_browsed; 565 bool is_user_browsed;
539 bool is_network_fetched; 566 bool is_network_fetched;
540 bool is_cellular_fetched; 567 bool is_cellular_fetched;
541 bool expected_in_used; 568 bool expected_in_used;
542 }; 569 };
543 570
544 const struct { 571 const struct {
545 std::string hostname; 572 std::string hostname;
(...skipping 29 matching lines...) Expand all
575 "empty.com", std::vector<test_resource_info>{}, 602 "empty.com", std::vector<test_resource_info>{},
576 }, 603 },
577 }; 604 };
578 // Add precached resources. 605 // Add precached resources.
579 for (const auto& test : tests) { 606 for (const auto& test : tests) {
580 for (const auto& resource : test.resource_info) { 607 for (const auto& resource : test.resource_info) {
581 precache_database_->RecordURLPrefetch(GURL(resource.url), test.hostname, 608 precache_database_->RecordURLPrefetch(GURL(resource.url), test.hostname,
582 kPrecacheTime, false, kSize); 609 kPrecacheTime, false, kSize);
583 } 610 }
584 } 611 }
612 precache_database_->RecordURLPrefetch(GURL(already_reported_and_in_cache),
613 "foo.com", kPrecacheTime, true, kSize);
585 // Update some resources as used due to user browsing. 614 // Update some resources as used due to user browsing.
586 for (const auto& test : tests) { 615 for (const auto& test : tests) {
587 for (const auto& resource : test.resource_info) { 616 for (const auto& resource : test.resource_info) {
588 if (!resource.is_user_browsed) 617 if (!resource.is_user_browsed)
589 continue; 618 continue;
590 if (!resource.is_network_fetched && !resource.is_cellular_fetched) { 619 if (!resource.is_network_fetched && !resource.is_cellular_fetched) {
591 RecordFetchFromCache(GURL(resource.url), kFetchTime, kSize); 620 RecordFetchFromCache(GURL(resource.url), kFetchTime, kSize);
592 } else if (!resource.is_network_fetched && resource.is_cellular_fetched) { 621 } else if (!resource.is_network_fetched && resource.is_cellular_fetched) {
593 RecordFetchFromCacheCellular(GURL(resource.url), kFetchTime, kSize); 622 RecordFetchFromCacheCellular(GURL(resource.url), kFetchTime, kSize);
594 } else if (resource.is_network_fetched && !resource.is_cellular_fetched) { 623 } else if (resource.is_network_fetched && !resource.is_cellular_fetched) {
595 RecordFetchFromNetwork(GURL(resource.url), kLatency, kFetchTime, kSize); 624 RecordFetchFromNetwork(GURL(resource.url), kLatency, kFetchTime, kSize);
596 } else if (resource.is_network_fetched && resource.is_cellular_fetched) { 625 } else if (resource.is_network_fetched && resource.is_cellular_fetched) {
597 RecordFetchFromNetworkCellular(GURL(resource.url), kLatency, kFetchTime, 626 RecordFetchFromNetworkCellular(GURL(resource.url), kLatency, kFetchTime,
598 kSize); 627 kSize);
599 } 628 }
600 } 629 }
601 } 630 }
602 Flush(); 631 Flush();
603 // Verify the used and unused resources. 632 // Verify the used and downloaded resources.
604 for (const auto& test : tests) { 633 for (const auto& test : tests) {
605 std::vector<GURL> expected_used_urls, expected_unused_urls; 634 std::vector<GURL> expected_used_urls, expected_downloaded_urls;
606 for (const auto& resource : test.resource_info) { 635 for (const auto& resource : test.resource_info) {
607 if (resource.expected_in_used) { 636 if (resource.expected_in_used) {
608 expected_used_urls.push_back(GURL(resource.url)); 637 expected_used_urls.push_back(GURL(resource.url));
609 } else {
610 expected_unused_urls.push_back(GURL(resource.url));
611 } 638 }
639 expected_downloaded_urls.push_back(GURL(resource.url));
612 } 640 }
613 std::vector<GURL> actual_used_urls, actual_unused_urls; 641 std::vector<GURL> actual_used_urls, actual_downloaded_urls;
614 auto referrer_id = precache_database_->GetReferrerHost(test.hostname).id; 642 auto referrer_id = precache_database_->GetReferrerHost(test.hostname).id;
615 EXPECT_NE(PrecacheReferrerHostEntry::kInvalidId, referrer_id); 643 EXPECT_NE(PrecacheReferrerHostEntry::kInvalidId, referrer_id);
616 precache_database_->GetURLListForReferrerHost( 644 precache_database_->GetURLListForReferrerHost(
617 referrer_id, &actual_used_urls, &actual_unused_urls); 645 referrer_id, &actual_used_urls, &actual_downloaded_urls);
618 EXPECT_THAT(expected_used_urls, ::testing::ContainerEq(actual_used_urls)); 646 EXPECT_THAT(actual_used_urls, ::testing::ContainerEq(expected_used_urls));
619 EXPECT_THAT(expected_unused_urls, 647 EXPECT_THAT(actual_downloaded_urls,
620 ::testing::ContainerEq(actual_unused_urls)); 648 ::testing::ContainerEq(expected_downloaded_urls))
649 << "Host: " << test.hostname;
621 } 650 }
622 // Subsequent manifest updates should clear the used and unused resources. 651 // Subsequent manifest updates should clear the used and downloaded resources.
623 for (const auto& test : tests) { 652 for (const auto& test : tests) {
624 precache_database_->UpdatePrecacheReferrerHost(test.hostname, 100, 653 precache_database_->UpdatePrecacheReferrerHost(test.hostname, 100,
625 kNewFetchTime); 654 kNewFetchTime);
626 Flush(); 655 Flush();
627 std::vector<GURL> actual_used_urls, actual_unused_urls; 656 std::vector<GURL> actual_used_urls, actual_downloaded_urls;
628 auto referrer_id = precache_database_->GetReferrerHost(test.hostname).id; 657 auto referrer_id = precache_database_->GetReferrerHost(test.hostname).id;
629 EXPECT_NE(PrecacheReferrerHostEntry::kInvalidId, referrer_id); 658 EXPECT_NE(PrecacheReferrerHostEntry::kInvalidId, referrer_id);
630 precache_database_->GetURLListForReferrerHost( 659 precache_database_->GetURLListForReferrerHost(
631 referrer_id, &actual_used_urls, &actual_unused_urls); 660 referrer_id, &actual_used_urls, &actual_downloaded_urls);
632 EXPECT_TRUE(actual_used_urls.empty()); 661 EXPECT_TRUE(actual_used_urls.empty());
633 } 662 }
634 // Resources that were precached previously and not seen in user browsing 663 // Resources that were precached previously and not seen in user browsing
635 // should be still marked as precached. 664 // should be still marked as precached.
636 std::map<GURL, base::Time> expected_url_table_map; 665 std::map<GURL, base::Time> expected_url_table_map;
637 for (const auto& test : tests) { 666 for (const auto& test : tests) {
638 for (const auto& resource : test.resource_info) { 667 for (const auto& resource : test.resource_info) {
639 if (!resource.is_user_browsed) 668 if (!resource.is_user_browsed)
640 expected_url_table_map[GURL(resource.url)] = kPrecacheTime; 669 expected_url_table_map[GURL(resource.url)] = kPrecacheTime;
641 } 670 }
642 } 671 }
672 expected_url_table_map[GURL(already_reported_and_not_refetch)] =
673 kPrecacheTime;
674 expected_url_table_map[GURL(already_reported_and_in_cache)] = kPrecacheTime;
643 EXPECT_EQ(expected_url_table_map, GetActualURLTableMap()); 675 EXPECT_EQ(expected_url_table_map, GetActualURLTableMap());
644 } 676 }
645 677
646 } // namespace 678 } // namespace
647 679
648 } // namespace precache 680 } // namespace precache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698