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

Side by Side Diff: webkit/appcache/appcache_storage_impl_unittest.cc

Issue 16155009: Update webkit/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « webkit/appcache/appcache_storage_impl.cc ('k') | webkit/appcache/appcache_storage_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stack> 5 #include <stack>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 }; 180 };
181 181
182 class MockQuotaManagerProxy : public quota::QuotaManagerProxy { 182 class MockQuotaManagerProxy : public quota::QuotaManagerProxy {
183 public: 183 public:
184 MockQuotaManagerProxy() 184 MockQuotaManagerProxy()
185 : QuotaManagerProxy(NULL, NULL), 185 : QuotaManagerProxy(NULL, NULL),
186 notify_storage_accessed_count_(0), 186 notify_storage_accessed_count_(0),
187 notify_storage_modified_count_(0), 187 notify_storage_modified_count_(0),
188 last_delta_(0), 188 last_delta_(0),
189 mock_manager_(new MockQuotaManager) { 189 mock_manager_(new MockQuotaManager) {
190 manager_ = mock_manager_; 190 manager_ = mock_manager_.get();
191 } 191 }
192 192
193 virtual void NotifyStorageAccessed(quota::QuotaClient::ID client_id, 193 virtual void NotifyStorageAccessed(quota::QuotaClient::ID client_id,
194 const GURL& origin, 194 const GURL& origin,
195 quota::StorageType type) OVERRIDE { 195 quota::StorageType type) OVERRIDE {
196 EXPECT_EQ(quota::QuotaClient::kAppcache, client_id); 196 EXPECT_EQ(quota::QuotaClient::kAppcache, client_id);
197 EXPECT_EQ(quota::kStorageTypeTemporary, type); 197 EXPECT_EQ(quota::kStorageTypeTemporary, type);
198 ++notify_storage_accessed_count_; 198 ++notify_storage_accessed_count_;
199 last_origin_ = origin; 199 last_origin_ = origin;
200 } 200 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 // complete asynchronously. 347 // complete asynchronously.
348 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_LoadCache_Miss, 348 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_LoadCache_Miss,
349 base::Unretained(this))); 349 base::Unretained(this)));
350 350
351 storage()->LoadCache(111, delegate()); 351 storage()->LoadCache(111, delegate());
352 EXPECT_NE(111, delegate()->loaded_cache_id_); 352 EXPECT_NE(111, delegate()->loaded_cache_id_);
353 } 353 }
354 354
355 void Verify_LoadCache_Miss() { 355 void Verify_LoadCache_Miss() {
356 EXPECT_EQ(111, delegate()->loaded_cache_id_); 356 EXPECT_EQ(111, delegate()->loaded_cache_id_);
357 EXPECT_FALSE(delegate()->loaded_cache_); 357 EXPECT_FALSE(delegate()->loaded_cache_.get());
358 EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_accessed_count_); 358 EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_accessed_count_);
359 EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_modified_count_); 359 EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_modified_count_);
360 TestFinished(); 360 TestFinished();
361 } 361 }
362 362
363 // LoadCache_NearHit ------------------------------------------------- 363 // LoadCache_NearHit -------------------------------------------------
364 364
365 void LoadCache_NearHit() { 365 void LoadCache_NearHit() {
366 // Attempt to load a cache that is currently in use 366 // Attempt to load a cache that is currently in use
367 // and does not require loading from storage. This 367 // and does not require loading from storage. This
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 // appear to be "stored" and "not currently in use". 437 // appear to be "stored" and "not currently in use".
438 MakeCacheAndGroup(kManifestUrl, 1, 1, true); 438 MakeCacheAndGroup(kManifestUrl, 1, 1, true);
439 group_ = NULL; 439 group_ = NULL;
440 cache_ = NULL; 440 cache_ = NULL;
441 441
442 // Conduct the cache load test, completes async 442 // Conduct the cache load test, completes async
443 storage()->LoadCache(1, delegate()); 443 storage()->LoadCache(1, delegate());
444 } 444 }
445 445
446 void Verify_LoadCache_Far_Hit() { 446 void Verify_LoadCache_Far_Hit() {
447 EXPECT_TRUE(delegate()->loaded_cache_); 447 EXPECT_TRUE(delegate()->loaded_cache_.get());
448 EXPECT_TRUE(delegate()->loaded_cache_->HasOneRef()); 448 EXPECT_TRUE(delegate()->loaded_cache_->HasOneRef());
449 EXPECT_EQ(1, delegate()->loaded_cache_id_); 449 EXPECT_EQ(1, delegate()->loaded_cache_id_);
450 450
451 // The group should also have been loaded. 451 // The group should also have been loaded.
452 EXPECT_TRUE(delegate()->loaded_cache_->owning_group()); 452 EXPECT_TRUE(delegate()->loaded_cache_->owning_group());
453 EXPECT_TRUE(delegate()->loaded_cache_->owning_group()->HasOneRef()); 453 EXPECT_TRUE(delegate()->loaded_cache_->owning_group()->HasOneRef());
454 EXPECT_EQ(1, delegate()->loaded_cache_->owning_group()->group_id()); 454 EXPECT_EQ(1, delegate()->loaded_cache_->owning_group()->group_id());
455 455
456 EXPECT_EQ(1, mock_quota_manager_proxy_->notify_storage_accessed_count_); 456 EXPECT_EQ(1, mock_quota_manager_proxy_->notify_storage_accessed_count_);
457 EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_modified_count_); 457 EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_modified_count_);
458 458
459 // Drop things from the working set. 459 // Drop things from the working set.
460 delegate()->loaded_cache_ = NULL; 460 delegate()->loaded_cache_ = NULL;
461 EXPECT_FALSE(delegate()->loaded_group_); 461 EXPECT_FALSE(delegate()->loaded_group_.get());
462 462
463 // Conduct the group load test, also complete asynchronously. 463 // Conduct the group load test, also complete asynchronously.
464 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_LoadGroup_Far_Hit, 464 PushNextTask(base::Bind(&AppCacheStorageImplTest::Verify_LoadGroup_Far_Hit,
465 base::Unretained(this))); 465 base::Unretained(this)));
466 466
467 storage()->LoadOrCreateGroup(kManifestUrl, delegate()); 467 storage()->LoadOrCreateGroup(kManifestUrl, delegate());
468 } 468 }
469 469
470 void Verify_LoadGroup_Far_Hit() { 470 void Verify_LoadGroup_Far_Hit() {
471 EXPECT_TRUE(delegate()->loaded_group_); 471 EXPECT_TRUE(delegate()->loaded_group_.get());
472 EXPECT_EQ(kManifestUrl, delegate()->loaded_manifest_url_); 472 EXPECT_EQ(kManifestUrl, delegate()->loaded_manifest_url_);
473 EXPECT_TRUE(delegate()->loaded_group_->newest_complete_cache()); 473 EXPECT_TRUE(delegate()->loaded_group_->newest_complete_cache());
474 delegate()->loaded_groups_newest_cache_ = NULL; 474 delegate()->loaded_groups_newest_cache_ = NULL;
475 EXPECT_TRUE(delegate()->loaded_group_->HasOneRef()); 475 EXPECT_TRUE(delegate()->loaded_group_->HasOneRef());
476 EXPECT_EQ(2, mock_quota_manager_proxy_->notify_storage_accessed_count_); 476 EXPECT_EQ(2, mock_quota_manager_proxy_->notify_storage_accessed_count_);
477 EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_modified_count_); 477 EXPECT_EQ(0, mock_quota_manager_proxy_->notify_storage_modified_count_);
478 TestFinished(); 478 TestFinished();
479 } 479 }
480 480
481 // StoreNewGroup -------------------------------------- 481 // StoreNewGroup --------------------------------------
(...skipping 10 matching lines...) Expand all
492 cache_ = new AppCache(storage(), storage()->NewCacheId()); 492 cache_ = new AppCache(storage(), storage()->NewCacheId());
493 cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, 1, 493 cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, 1,
494 kDefaultEntrySize)); 494 kDefaultEntrySize));
495 // Hold a ref to the cache simulate the UpdateJob holding that ref, 495 // Hold a ref to the cache simulate the UpdateJob holding that ref,
496 // and hold a ref to the group to simulate the CacheHost holding that ref. 496 // and hold a ref to the group to simulate the CacheHost holding that ref.
497 497
498 // Have the quota manager retrun asynchronously for this test. 498 // Have the quota manager retrun asynchronously for this test.
499 mock_quota_manager_proxy_->mock_manager_->async_ = true; 499 mock_quota_manager_proxy_->mock_manager_->async_ = true;
500 500
501 // Conduct the store test. 501 // Conduct the store test.
502 storage()->StoreGroupAndNewestCache(group_, cache_, delegate()); 502 storage()->StoreGroupAndNewestCache(group_.get(), cache_.get(), delegate());
503 EXPECT_FALSE(delegate()->stored_group_success_); 503 EXPECT_FALSE(delegate()->stored_group_success_);
504 } 504 }
505 505
506 void Verify_StoreNewGroup() { 506 void Verify_StoreNewGroup() {
507 EXPECT_TRUE(delegate()->stored_group_success_); 507 EXPECT_TRUE(delegate()->stored_group_success_);
508 EXPECT_EQ(group_.get(), delegate()->stored_group_.get()); 508 EXPECT_EQ(group_.get(), delegate()->stored_group_.get());
509 EXPECT_EQ(cache_.get(), group_->newest_complete_cache()); 509 EXPECT_EQ(cache_.get(), group_->newest_complete_cache());
510 EXPECT_TRUE(cache_->is_complete()); 510 EXPECT_TRUE(cache_->is_complete());
511 511
512 // Should have been stored in the database. 512 // Should have been stored in the database.
(...skipping 22 matching lines...) Expand all
535 // that appear to be "stored" 535 // that appear to be "stored"
536 MakeCacheAndGroup(kManifestUrl, 1, 1, true); 536 MakeCacheAndGroup(kManifestUrl, 1, 1, true);
537 EXPECT_EQ(kDefaultEntrySize, storage()->usage_map_[kOrigin]); 537 EXPECT_EQ(kDefaultEntrySize, storage()->usage_map_[kOrigin]);
538 538
539 // And a newest unstored complete cache. 539 // And a newest unstored complete cache.
540 cache2_ = new AppCache(storage(), 2); 540 cache2_ = new AppCache(storage(), 2);
541 cache2_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::MASTER, 1, 541 cache2_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::MASTER, 1,
542 kDefaultEntrySize + 100)); 542 kDefaultEntrySize + 100));
543 543
544 // Conduct the test. 544 // Conduct the test.
545 storage()->StoreGroupAndNewestCache(group_, cache2_, delegate()); 545 storage()->StoreGroupAndNewestCache(
546 group_.get(), cache2_.get(), delegate());
546 EXPECT_FALSE(delegate()->stored_group_success_); 547 EXPECT_FALSE(delegate()->stored_group_success_);
547 } 548 }
548 549
549 void Verify_StoreExistingGroup() { 550 void Verify_StoreExistingGroup() {
550 EXPECT_TRUE(delegate()->stored_group_success_); 551 EXPECT_TRUE(delegate()->stored_group_success_);
551 EXPECT_EQ(group_.get(), delegate()->stored_group_.get()); 552 EXPECT_EQ(group_.get(), delegate()->stored_group_.get());
552 EXPECT_EQ(cache2_.get(), group_->newest_complete_cache()); 553 EXPECT_EQ(cache2_.get(), group_->newest_complete_cache());
553 EXPECT_TRUE(cache2_->is_complete()); 554 EXPECT_TRUE(cache2_->is_complete());
554 555
555 // The new cache should have been stored in the database. 556 // The new cache should have been stored in the database.
(...skipping 30 matching lines...) Expand all
586 base::Time now = base::Time::Now(); 587 base::Time now = base::Time::Now();
587 cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::MASTER, 1, 100)); 588 cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::MASTER, 1, 100));
588 cache_->set_update_time(now); 589 cache_->set_update_time(now);
589 590
590 PushNextTask(base::Bind( 591 PushNextTask(base::Bind(
591 &AppCacheStorageImplTest::Verify_StoreExistingGroupExistingCache, 592 &AppCacheStorageImplTest::Verify_StoreExistingGroupExistingCache,
592 base::Unretained(this), now)); 593 base::Unretained(this), now));
593 594
594 // Conduct the test. 595 // Conduct the test.
595 EXPECT_EQ(cache_, group_->newest_complete_cache()); 596 EXPECT_EQ(cache_, group_->newest_complete_cache());
596 storage()->StoreGroupAndNewestCache(group_, cache_, delegate()); 597 storage()->StoreGroupAndNewestCache(group_.get(), cache_.get(), delegate());
597 EXPECT_FALSE(delegate()->stored_group_success_); 598 EXPECT_FALSE(delegate()->stored_group_success_);
598 } 599 }
599 600
600 void Verify_StoreExistingGroupExistingCache( 601 void Verify_StoreExistingGroupExistingCache(
601 base::Time expected_update_time) { 602 base::Time expected_update_time) {
602 EXPECT_TRUE(delegate()->stored_group_success_); 603 EXPECT_TRUE(delegate()->stored_group_success_);
603 EXPECT_EQ(cache_, group_->newest_complete_cache()); 604 EXPECT_EQ(cache_, group_->newest_complete_cache());
604 605
605 AppCacheDatabase::CacheRecord cache_record; 606 AppCacheDatabase::CacheRecord cache_record;
606 EXPECT_TRUE(database()->FindCache(1, &cache_record)); 607 EXPECT_TRUE(database()->FindCache(1, &cache_record));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 const int64 kTooBig = 10 * 1024 * 1024; // 10M 643 const int64 kTooBig = 10 * 1024 * 1024; // 10M
643 group_ = new AppCacheGroup( 644 group_ = new AppCacheGroup(
644 storage(), kManifestUrl, storage()->NewGroupId()); 645 storage(), kManifestUrl, storage()->NewGroupId());
645 cache_ = new AppCache(storage(), storage()->NewCacheId()); 646 cache_ = new AppCache(storage(), storage()->NewCacheId());
646 cache_->AddEntry(kManifestUrl, 647 cache_->AddEntry(kManifestUrl,
647 AppCacheEntry(AppCacheEntry::MANIFEST, 1, kTooBig)); 648 AppCacheEntry(AppCacheEntry::MANIFEST, 1, kTooBig));
648 // Hold a ref to the cache simulate the UpdateJob holding that ref, 649 // Hold a ref to the cache simulate the UpdateJob holding that ref,
649 // and hold a ref to the group to simulate the CacheHost holding that ref. 650 // and hold a ref to the group to simulate the CacheHost holding that ref.
650 651
651 // Conduct the store test. 652 // Conduct the store test.
652 storage()->StoreGroupAndNewestCache(group_, cache_, delegate()); 653 storage()->StoreGroupAndNewestCache(group_.get(), cache_.get(), delegate());
653 EXPECT_FALSE(delegate()->stored_group_success_); // Expected to be async. 654 EXPECT_FALSE(delegate()->stored_group_success_); // Expected to be async.
654 } 655 }
655 656
656 void Verify_FailStoreGroup() { 657 void Verify_FailStoreGroup() {
657 EXPECT_FALSE(delegate()->stored_group_success_); 658 EXPECT_FALSE(delegate()->stored_group_success_);
658 EXPECT_TRUE(delegate()->would_exceed_quota_); 659 EXPECT_TRUE(delegate()->would_exceed_quota_);
659 660
660 // Should not have been stored in the database. 661 // Should not have been stored in the database.
661 AppCacheDatabase::GroupRecord group_record; 662 AppCacheDatabase::GroupRecord group_record;
662 AppCacheDatabase::CacheRecord cache_record; 663 AppCacheDatabase::CacheRecord cache_record;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 fallback_namespace_record.namespace_.namespace_url = kFallbackNamespace; 696 fallback_namespace_record.namespace_.namespace_url = kFallbackNamespace;
696 fallback_namespace_record.origin = kManifestUrl.GetOrigin(); 697 fallback_namespace_record.origin = kManifestUrl.GetOrigin();
697 EXPECT_TRUE(database()->InsertNamespace(&fallback_namespace_record)); 698 EXPECT_TRUE(database()->InsertNamespace(&fallback_namespace_record));
698 699
699 AppCacheDatabase::OnlineWhiteListRecord online_whitelist_record; 700 AppCacheDatabase::OnlineWhiteListRecord online_whitelist_record;
700 online_whitelist_record.cache_id = 1; 701 online_whitelist_record.cache_id = 1;
701 online_whitelist_record.namespace_url = kOnlineNamespace; 702 online_whitelist_record.namespace_url = kOnlineNamespace;
702 EXPECT_TRUE(database()->InsertOnlineWhiteList(&online_whitelist_record)); 703 EXPECT_TRUE(database()->InsertOnlineWhiteList(&online_whitelist_record));
703 704
704 // Conduct the test. 705 // Conduct the test.
705 storage()->MakeGroupObsolete(group_, delegate()); 706 storage()->MakeGroupObsolete(group_.get(), delegate());
706 EXPECT_FALSE(group_->is_obsolete()); 707 EXPECT_FALSE(group_->is_obsolete());
707 } 708 }
708 709
709 void Verify_MakeGroupObsolete() { 710 void Verify_MakeGroupObsolete() {
710 EXPECT_TRUE(delegate()->obsoleted_success_); 711 EXPECT_TRUE(delegate()->obsoleted_success_);
711 EXPECT_EQ(group_.get(), delegate()->obsoleted_group_.get()); 712 EXPECT_EQ(group_.get(), delegate()->obsoleted_group_.get());
712 EXPECT_TRUE(group_->is_obsolete()); 713 EXPECT_TRUE(group_->is_obsolete());
713 EXPECT_TRUE(storage()->usage_map_.empty()); 714 EXPECT_TRUE(storage()->usage_map_.empty());
714 715
715 // The cache and group have been deleted from the database. 716 // The cache and group have been deleted from the database.
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 cache_->AddEntry(kEntryUrl2, AppCacheEntry(AppCacheEntry::FALLBACK, 2)); 913 cache_->AddEntry(kEntryUrl2, AppCacheEntry(AppCacheEntry::FALLBACK, 2));
913 cache_->fallback_namespaces_.push_back( 914 cache_->fallback_namespaces_.push_back(
914 Namespace(FALLBACK_NAMESPACE, kFallbackNamespace2, kEntryUrl2, false)); 915 Namespace(FALLBACK_NAMESPACE, kFallbackNamespace2, kEntryUrl2, false));
915 cache_->fallback_namespaces_.push_back( 916 cache_->fallback_namespaces_.push_back(
916 Namespace(FALLBACK_NAMESPACE, kFallbackNamespace, kEntryUrl, false)); 917 Namespace(FALLBACK_NAMESPACE, kFallbackNamespace, kEntryUrl, false));
917 AppCacheDatabase::CacheRecord cache_record; 918 AppCacheDatabase::CacheRecord cache_record;
918 std::vector<AppCacheDatabase::EntryRecord> entries; 919 std::vector<AppCacheDatabase::EntryRecord> entries;
919 std::vector<AppCacheDatabase::NamespaceRecord> intercepts; 920 std::vector<AppCacheDatabase::NamespaceRecord> intercepts;
920 std::vector<AppCacheDatabase::NamespaceRecord> fallbacks; 921 std::vector<AppCacheDatabase::NamespaceRecord> fallbacks;
921 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists; 922 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists;
922 cache_->ToDatabaseRecords(group_, 923 cache_->ToDatabaseRecords(group_.get(),
923 &cache_record, &entries, &intercepts, &fallbacks, &whitelists); 924 &cache_record,
925 &entries,
926 &intercepts,
927 &fallbacks,
928 &whitelists);
924 929
925 std::vector<AppCacheDatabase::EntryRecord>::const_iterator iter = 930 std::vector<AppCacheDatabase::EntryRecord>::const_iterator iter =
926 entries.begin(); 931 entries.begin();
927 while (iter != entries.end()) { 932 while (iter != entries.end()) {
928 // MakeCacheAndGroup has inserted the default entry record already. 933 // MakeCacheAndGroup has inserted the default entry record already.
929 if (iter->url != kDefaultEntryUrl) 934 if (iter->url != kDefaultEntryUrl)
930 EXPECT_TRUE(database()->InsertEntry(&(*iter))); 935 EXPECT_TRUE(database()->InsertEntry(&(*iter)));
931 ++iter; 936 ++iter;
932 } 937 }
933 938
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 Namespace(INTERCEPT_NAMESPACE, kInterceptNamespace2, 987 Namespace(INTERCEPT_NAMESPACE, kInterceptNamespace2,
983 kEntryUrl2, false)); 988 kEntryUrl2, false));
984 cache_->intercept_namespaces_.push_back( 989 cache_->intercept_namespaces_.push_back(
985 Namespace(INTERCEPT_NAMESPACE, kInterceptNamespace, 990 Namespace(INTERCEPT_NAMESPACE, kInterceptNamespace,
986 kEntryUrl, false)); 991 kEntryUrl, false));
987 AppCacheDatabase::CacheRecord cache_record; 992 AppCacheDatabase::CacheRecord cache_record;
988 std::vector<AppCacheDatabase::EntryRecord> entries; 993 std::vector<AppCacheDatabase::EntryRecord> entries;
989 std::vector<AppCacheDatabase::NamespaceRecord> intercepts; 994 std::vector<AppCacheDatabase::NamespaceRecord> intercepts;
990 std::vector<AppCacheDatabase::NamespaceRecord> fallbacks; 995 std::vector<AppCacheDatabase::NamespaceRecord> fallbacks;
991 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists; 996 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists;
992 cache_->ToDatabaseRecords(group_, 997 cache_->ToDatabaseRecords(group_.get(),
993 &cache_record, &entries, &intercepts, &fallbacks, &whitelists); 998 &cache_record,
999 &entries,
1000 &intercepts,
1001 &fallbacks,
1002 &whitelists);
994 1003
995 std::vector<AppCacheDatabase::EntryRecord>::const_iterator iter = 1004 std::vector<AppCacheDatabase::EntryRecord>::const_iterator iter =
996 entries.begin(); 1005 entries.begin();
997 while (iter != entries.end()) { 1006 while (iter != entries.end()) {
998 // MakeCacheAndGroup has inserted the default entry record already 1007 // MakeCacheAndGroup has inserted the default entry record already
999 if (iter->url != kDefaultEntryUrl) 1008 if (iter->url != kDefaultEntryUrl)
1000 EXPECT_TRUE(database()->InsertEntry(&(*iter))); 1009 EXPECT_TRUE(database()->InsertEntry(&(*iter)));
1001 ++iter; 1010 ++iter;
1002 } 1011 }
1003 1012
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 MakeCacheAndGroup(kManifestUrl, 2, 1, true); 1054 MakeCacheAndGroup(kManifestUrl, 2, 1, true);
1046 cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::INTERCEPT, 1)); 1055 cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::INTERCEPT, 1));
1047 cache_->intercept_namespaces_.push_back( 1056 cache_->intercept_namespaces_.push_back(
1048 Namespace(INTERCEPT_NAMESPACE, kInterceptPatternNamespace, 1057 Namespace(INTERCEPT_NAMESPACE, kInterceptPatternNamespace,
1049 kEntryUrl, true)); 1058 kEntryUrl, true));
1050 AppCacheDatabase::CacheRecord cache_record; 1059 AppCacheDatabase::CacheRecord cache_record;
1051 std::vector<AppCacheDatabase::EntryRecord> entries; 1060 std::vector<AppCacheDatabase::EntryRecord> entries;
1052 std::vector<AppCacheDatabase::NamespaceRecord> intercepts; 1061 std::vector<AppCacheDatabase::NamespaceRecord> intercepts;
1053 std::vector<AppCacheDatabase::NamespaceRecord> fallbacks; 1062 std::vector<AppCacheDatabase::NamespaceRecord> fallbacks;
1054 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists; 1063 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists;
1055 cache_->ToDatabaseRecords(group_, 1064 cache_->ToDatabaseRecords(group_.get(),
1056 &cache_record, &entries, &intercepts, &fallbacks, &whitelists); 1065 &cache_record,
1066 &entries,
1067 &intercepts,
1068 &fallbacks,
1069 &whitelists);
1057 1070
1058 std::vector<AppCacheDatabase::EntryRecord>::const_iterator iter = 1071 std::vector<AppCacheDatabase::EntryRecord>::const_iterator iter =
1059 entries.begin(); 1072 entries.begin();
1060 while (iter != entries.end()) { 1073 while (iter != entries.end()) {
1061 // MakeCacheAndGroup has inserted the default entry record already 1074 // MakeCacheAndGroup has inserted the default entry record already
1062 if (iter->url != kDefaultEntryUrl) 1075 if (iter->url != kDefaultEntryUrl)
1063 EXPECT_TRUE(database()->InsertEntry(&(*iter))); 1076 EXPECT_TRUE(database()->InsertEntry(&(*iter)));
1064 ++iter; 1077 ++iter;
1065 } 1078 }
1066 1079
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 MakeCacheAndGroup(kManifestUrl, 2, 1, true); 1140 MakeCacheAndGroup(kManifestUrl, 2, 1, true);
1128 cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::FALLBACK, 1)); 1141 cache_->AddEntry(kEntryUrl, AppCacheEntry(AppCacheEntry::FALLBACK, 1));
1129 cache_->fallback_namespaces_.push_back( 1142 cache_->fallback_namespaces_.push_back(
1130 Namespace(FALLBACK_NAMESPACE, kFallbackPatternNamespace, 1143 Namespace(FALLBACK_NAMESPACE, kFallbackPatternNamespace,
1131 kEntryUrl, true)); 1144 kEntryUrl, true));
1132 AppCacheDatabase::CacheRecord cache_record; 1145 AppCacheDatabase::CacheRecord cache_record;
1133 std::vector<AppCacheDatabase::EntryRecord> entries; 1146 std::vector<AppCacheDatabase::EntryRecord> entries;
1134 std::vector<AppCacheDatabase::NamespaceRecord> intercepts; 1147 std::vector<AppCacheDatabase::NamespaceRecord> intercepts;
1135 std::vector<AppCacheDatabase::NamespaceRecord> fallbacks; 1148 std::vector<AppCacheDatabase::NamespaceRecord> fallbacks;
1136 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists; 1149 std::vector<AppCacheDatabase::OnlineWhiteListRecord> whitelists;
1137 cache_->ToDatabaseRecords(group_, 1150 cache_->ToDatabaseRecords(group_.get(),
1138 &cache_record, &entries, &intercepts, &fallbacks, &whitelists); 1151 &cache_record,
1152 &entries,
1153 &intercepts,
1154 &fallbacks,
1155 &whitelists);
1139 1156
1140 std::vector<AppCacheDatabase::EntryRecord>::const_iterator iter = 1157 std::vector<AppCacheDatabase::EntryRecord>::const_iterator iter =
1141 entries.begin(); 1158 entries.begin();
1142 while (iter != entries.end()) { 1159 while (iter != entries.end()) {
1143 // MakeCacheAndGroup has inserted the default entry record already. 1160 // MakeCacheAndGroup has inserted the default entry record already.
1144 if (iter->url != kDefaultEntryUrl) 1161 if (iter->url != kDefaultEntryUrl)
1145 EXPECT_TRUE(database()->InsertEntry(&(*iter))); 1162 EXPECT_TRUE(database()->InsertEntry(&(*iter)));
1146 ++iter; 1163 ++iter;
1147 } 1164 }
1148 1165
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 void MakeCacheAndGroup( 1475 void MakeCacheAndGroup(
1459 const GURL& manifest_url, int64 group_id, int64 cache_id, 1476 const GURL& manifest_url, int64 group_id, int64 cache_id,
1460 bool add_to_database) { 1477 bool add_to_database) {
1461 AppCacheEntry default_entry( 1478 AppCacheEntry default_entry(
1462 AppCacheEntry::EXPLICIT, cache_id + kDefaultEntryIdOffset, 1479 AppCacheEntry::EXPLICIT, cache_id + kDefaultEntryIdOffset,
1463 kDefaultEntrySize); 1480 kDefaultEntrySize);
1464 group_ = new AppCacheGroup(storage(), manifest_url, group_id); 1481 group_ = new AppCacheGroup(storage(), manifest_url, group_id);
1465 cache_ = new AppCache(storage(), cache_id); 1482 cache_ = new AppCache(storage(), cache_id);
1466 cache_->AddEntry(kDefaultEntryUrl, default_entry); 1483 cache_->AddEntry(kDefaultEntryUrl, default_entry);
1467 cache_->set_complete(true); 1484 cache_->set_complete(true);
1468 group_->AddCache(cache_); 1485 group_->AddCache(cache_.get());
1469 if (add_to_database) { 1486 if (add_to_database) {
1470 AppCacheDatabase::GroupRecord group_record; 1487 AppCacheDatabase::GroupRecord group_record;
1471 group_record.group_id = group_id; 1488 group_record.group_id = group_id;
1472 group_record.manifest_url = manifest_url; 1489 group_record.manifest_url = manifest_url;
1473 group_record.origin = manifest_url.GetOrigin(); 1490 group_record.origin = manifest_url.GetOrigin();
1474 EXPECT_TRUE(database()->InsertGroup(&group_record)); 1491 EXPECT_TRUE(database()->InsertGroup(&group_record));
1475 AppCacheDatabase::CacheRecord cache_record; 1492 AppCacheDatabase::CacheRecord cache_record;
1476 cache_record.cache_id = cache_id; 1493 cache_record.cache_id = cache_id;
1477 cache_record.group_id = group_id; 1494 cache_record.group_id = group_id;
1478 cache_record.online_wildcard = false; 1495 cache_record.online_wildcard = false;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 } 1636 }
1620 1637
1621 TEST_F(AppCacheStorageImplTest, FindFallbackPatternMatchInDatabase) { 1638 TEST_F(AppCacheStorageImplTest, FindFallbackPatternMatchInDatabase) {
1622 RunTestOnIOThread( 1639 RunTestOnIOThread(
1623 &AppCacheStorageImplTest::FindFallbackPatternMatchInDatabase); 1640 &AppCacheStorageImplTest::FindFallbackPatternMatchInDatabase);
1624 } 1641 }
1625 1642
1626 // That's all folks! 1643 // That's all folks!
1627 1644
1628 } // namespace appcache 1645 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_storage_impl.cc ('k') | webkit/appcache/appcache_storage_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698