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

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

Issue 7031065: AppCache + Quota integration (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/threading/thread.h" 8 #include "base/threading/thread.h"
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 } 347 }
348 348
349 void CreateGroupInPopulatedOrigin() { 349 void CreateGroupInPopulatedOrigin() {
350 // Attempt to load a group that doesn't exist, one should 350 // Attempt to load a group that doesn't exist, one should
351 // be created for us, but not stored. 351 // be created for us, but not stored.
352 PushNextTask(NewRunnableMethod( 352 PushNextTask(NewRunnableMethod(
353 this, &AppCacheStorageImplTest::Verify_CreateGroup)); 353 this, &AppCacheStorageImplTest::Verify_CreateGroup));
354 354
355 // Since the origin has groups, storage class will have to 355 // Since the origin has groups, storage class will have to
356 // consult the database and completion will be async. 356 // consult the database and completion will be async.
357 storage()->origins_with_groups_.insert(kManifestUrl.GetOrigin()); 357 storage()->usage_map_[kManifestUrl.GetOrigin()] = 10;
358 358
359 storage()->LoadOrCreateGroup(kManifestUrl, delegate()); 359 storage()->LoadOrCreateGroup(kManifestUrl, delegate());
360 EXPECT_FALSE(delegate()->loaded_group_.get()); 360 EXPECT_FALSE(delegate()->loaded_group_.get());
361 } 361 }
362 362
363 void Verify_CreateGroup() { 363 void Verify_CreateGroup() {
364 EXPECT_EQ(kManifestUrl, delegate()->loaded_manifest_url_); 364 EXPECT_EQ(kManifestUrl, delegate()->loaded_manifest_url_);
365 EXPECT_TRUE(delegate()->loaded_group_.get()); 365 EXPECT_TRUE(delegate()->loaded_group_.get());
366 EXPECT_TRUE(delegate()->loaded_group_->HasOneRef()); 366 EXPECT_TRUE(delegate()->loaded_group_->HasOneRef());
367 EXPECT_FALSE(delegate()->loaded_group_->newest_complete_cache()); 367 EXPECT_FALSE(delegate()->loaded_group_->newest_complete_cache());
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 // MakeGroupObsolete ------------------------------- 583 // MakeGroupObsolete -------------------------------
584 584
585 void MakeGroupObsolete() { 585 void MakeGroupObsolete() {
586 // Make a group obsolete, should complete asyncly. 586 // Make a group obsolete, should complete asyncly.
587 PushNextTask(NewRunnableMethod( 587 PushNextTask(NewRunnableMethod(
588 this, &AppCacheStorageImplTest::Verify_MakeGroupObsolete)); 588 this, &AppCacheStorageImplTest::Verify_MakeGroupObsolete));
589 589
590 // Setup some preconditions. Create a group and newest cache that 590 // Setup some preconditions. Create a group and newest cache that
591 // appears to be "stored" and "currently in use". 591 // appears to be "stored" and "currently in use".
592 MakeCacheAndGroup(kManifestUrl, 1, 1, true); 592 MakeCacheAndGroup(kManifestUrl, 1, 1, true);
593 EXPECT_FALSE(storage()->origins_with_groups_.empty()); 593 EXPECT_FALSE(storage()->usage_map_.empty());
594 594
595 // Also insert some related records. 595 // Also insert some related records.
596 AppCacheDatabase::EntryRecord entry_record; 596 AppCacheDatabase::EntryRecord entry_record;
597 entry_record.cache_id = 1; 597 entry_record.cache_id = 1;
598 entry_record.flags = AppCacheEntry::FALLBACK; 598 entry_record.flags = AppCacheEntry::FALLBACK;
599 entry_record.response_id = 1; 599 entry_record.response_id = 1;
600 entry_record.url = kEntryUrl; 600 entry_record.url = kEntryUrl;
601 EXPECT_TRUE(database()->InsertEntry(&entry_record)); 601 EXPECT_TRUE(database()->InsertEntry(&entry_record));
602 602
603 AppCacheDatabase::FallbackNameSpaceRecord fallback_namespace_record; 603 AppCacheDatabase::FallbackNameSpaceRecord fallback_namespace_record;
(...skipping 11 matching lines...) Expand all
615 615
616 // Conduct the test. 616 // Conduct the test.
617 storage()->MakeGroupObsolete(group_, delegate()); 617 storage()->MakeGroupObsolete(group_, delegate());
618 EXPECT_FALSE(group_->is_obsolete()); 618 EXPECT_FALSE(group_->is_obsolete());
619 } 619 }
620 620
621 void Verify_MakeGroupObsolete() { 621 void Verify_MakeGroupObsolete() {
622 EXPECT_TRUE(delegate()->obsoleted_success_); 622 EXPECT_TRUE(delegate()->obsoleted_success_);
623 EXPECT_EQ(group_.get(), delegate()->obsoleted_group_.get()); 623 EXPECT_EQ(group_.get(), delegate()->obsoleted_group_.get());
624 EXPECT_TRUE(group_->is_obsolete()); 624 EXPECT_TRUE(group_->is_obsolete());
625 EXPECT_TRUE(storage()->origins_with_groups_.empty()); 625 EXPECT_TRUE(storage()->usage_map_.empty());
626 626
627 // The cache and group have been deleted from the database. 627 // The cache and group have been deleted from the database.
628 AppCacheDatabase::GroupRecord group_record; 628 AppCacheDatabase::GroupRecord group_record;
629 AppCacheDatabase::CacheRecord cache_record; 629 AppCacheDatabase::CacheRecord cache_record;
630 EXPECT_FALSE(database()->FindGroup(1, &group_record)); 630 EXPECT_FALSE(database()->FindGroup(1, &group_record));
631 EXPECT_FALSE(database()->FindCache(1, &cache_record)); 631 EXPECT_FALSE(database()->FindCache(1, &cache_record));
632 632
633 // The related records should have been deleted too. 633 // The related records should have been deleted too.
634 std::vector<AppCacheDatabase::EntryRecord> entry_records; 634 std::vector<AppCacheDatabase::EntryRecord> entry_records;
635 database()->FindEntriesForCache(1, &entry_records); 635 database()->FindEntriesForCache(1, &entry_records);
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 group_record.group_id = group_id; 1134 group_record.group_id = group_id;
1135 group_record.manifest_url = manifest_url; 1135 group_record.manifest_url = manifest_url;
1136 group_record.origin = manifest_url.GetOrigin(); 1136 group_record.origin = manifest_url.GetOrigin();
1137 EXPECT_TRUE(database()->InsertGroup(&group_record)); 1137 EXPECT_TRUE(database()->InsertGroup(&group_record));
1138 AppCacheDatabase::CacheRecord cache_record; 1138 AppCacheDatabase::CacheRecord cache_record;
1139 cache_record.cache_id = cache_id; 1139 cache_record.cache_id = cache_id;
1140 cache_record.group_id = group_id; 1140 cache_record.group_id = group_id;
1141 cache_record.online_wildcard = false; 1141 cache_record.online_wildcard = false;
1142 cache_record.update_time = kZeroTime; 1142 cache_record.update_time = kZeroTime;
1143 EXPECT_TRUE(database()->InsertCache(&cache_record)); 1143 EXPECT_TRUE(database()->InsertCache(&cache_record));
1144 storage()->origins_with_groups_.insert(manifest_url.GetOrigin()); 1144 storage()->usage_map_[manifest_url.GetOrigin()] = 10;
1145 } 1145 }
1146 } 1146 }
1147 1147
1148 // Data members -------------------------------------------------- 1148 // Data members --------------------------------------------------
1149 1149
1150 scoped_ptr<base::WaitableEvent> test_finished_event_; 1150 scoped_ptr<base::WaitableEvent> test_finished_event_;
1151 std::stack<Task*> task_stack_; 1151 std::stack<Task*> task_stack_;
1152 MockAppCachePolicy policy_; 1152 MockAppCachePolicy policy_;
1153 scoped_ptr<AppCacheService> service_; 1153 scoped_ptr<AppCacheService> service_;
1154 scoped_ptr<MockStorageDelegate> delegate_; 1154 scoped_ptr<MockStorageDelegate> delegate_;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 &AppCacheStorageImplTest::FindMainResponseExclusionsInWorkingSet); 1251 &AppCacheStorageImplTest::FindMainResponseExclusionsInWorkingSet);
1252 } 1252 }
1253 1253
1254 // That's all folks! 1254 // That's all folks!
1255 1255
1256 } // namespace appcache 1256 } // namespace appcache
1257 1257
1258 // AppCacheStorageImplTest is expected to always live longer than the 1258 // AppCacheStorageImplTest is expected to always live longer than the
1259 // runnable methods. This lets us call NewRunnableMethod on its instances. 1259 // runnable methods. This lets us call NewRunnableMethod on its instances.
1260 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheStorageImplTest); 1260 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheStorageImplTest);
OLDNEW
« webkit/appcache/appcache_storage_impl.cc ('K') | « webkit/appcache/appcache_storage_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698