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

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

Issue 8343018: More groundwork for flat file based response storage. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 "webkit/appcache/appcache_storage_impl.h" 5 #include "webkit/appcache/appcache_storage_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 group != groups.end(); ++group) { 323 group != groups.end(); ++group) {
324 AppCacheDatabase::CacheRecord cache_record; 324 AppCacheDatabase::CacheRecord cache_record;
325 database_->FindCacheForGroup(group->group_id, &cache_record); 325 database_->FindCacheForGroup(group->group_id, &cache_record);
326 AppCacheInfo info; 326 AppCacheInfo info;
327 info.manifest_url = group->manifest_url; 327 info.manifest_url = group->manifest_url;
328 info.creation_time = group->creation_time; 328 info.creation_time = group->creation_time;
329 info.size = cache_record.cache_size; 329 info.size = cache_record.cache_size;
330 info.last_access_time = group->last_access_time; 330 info.last_access_time = group->last_access_time;
331 info.last_update_time = cache_record.update_time; 331 info.last_update_time = cache_record.update_time;
332 info.cache_id = cache_record.cache_id; 332 info.cache_id = cache_record.cache_id;
333 info.group_id = group->group_id;
333 info.is_complete = true; 334 info.is_complete = true;
334 infos.push_back(info); 335 infos.push_back(info);
335 } 336 }
336 } 337 }
337 } 338 }
338 339
339 void AppCacheStorageImpl::GetAllInfoTask::RunCompleted() { 340 void AppCacheStorageImpl::GetAllInfoTask::RunCompleted() {
340 DCHECK(delegates_.size() == 1); 341 DCHECK(delegates_.size() == 1);
341 FOR_EACH_DELEGATE(delegates_, OnAllInfo(info_collection_)); 342 FOR_EACH_DELEGATE(delegates_, OnAllInfo(info_collection_));
342 } 343 }
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 newly_deletable_response_ids_.push_back(*id_iter); 621 newly_deletable_response_ids_.push_back(*id_iter);
621 ++id_iter; 622 ++id_iter;
622 } 623 }
623 624
624 success_ = 625 success_ =
625 database_->DeleteCache(cache.cache_id) && 626 database_->DeleteCache(cache.cache_id) &&
626 database_->DeleteEntriesForCache(cache.cache_id) && 627 database_->DeleteEntriesForCache(cache.cache_id) &&
627 database_->DeleteFallbackNameSpacesForCache(cache.cache_id) && 628 database_->DeleteFallbackNameSpacesForCache(cache.cache_id) &&
628 database_->DeleteOnlineWhiteListForCache(cache.cache_id) && 629 database_->DeleteOnlineWhiteListForCache(cache.cache_id) &&
629 database_->InsertDeletableResponseIds(newly_deletable_response_ids_); 630 database_->InsertDeletableResponseIds(newly_deletable_response_ids_);
631 // TODO(michaeln): store group_id too with deletable ids
630 } else { 632 } else {
631 NOTREACHED() << "A existing group without a cache is unexpected"; 633 NOTREACHED() << "A existing group without a cache is unexpected";
632 } 634 }
633 } 635 }
634 636
635 success_ = 637 success_ =
636 success_ && 638 success_ &&
637 database_->InsertCache(&cache_record_) && 639 database_->InsertCache(&cache_record_) &&
638 database_->InsertEntryRecords(entry_records_) && 640 database_->InsertEntryRecords(entry_records_) &&
639 database_->InsertFallbackNameSpaceRecords(fallback_namespace_records_)&& 641 database_->InsertFallbackNameSpaceRecords(fallback_namespace_records_)&&
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 // FindMainResponseTask ------- 708 // FindMainResponseTask -------
707 709
708 class AppCacheStorageImpl::FindMainResponseTask : public DatabaseTask { 710 class AppCacheStorageImpl::FindMainResponseTask : public DatabaseTask {
709 public: 711 public:
710 FindMainResponseTask(AppCacheStorageImpl* storage, 712 FindMainResponseTask(AppCacheStorageImpl* storage,
711 const GURL& url, 713 const GURL& url,
712 const GURL& preferred_manifest_url, 714 const GURL& preferred_manifest_url,
713 const AppCacheWorkingSet::GroupMap* groups_in_use) 715 const AppCacheWorkingSet::GroupMap* groups_in_use)
714 : DatabaseTask(storage), url_(url), 716 : DatabaseTask(storage), url_(url),
715 preferred_manifest_url_(preferred_manifest_url), 717 preferred_manifest_url_(preferred_manifest_url),
716 cache_id_(kNoCacheId) { 718 cache_id_(kNoCacheId), group_id_(0) {
717 if (groups_in_use) { 719 if (groups_in_use) {
718 for (AppCacheWorkingSet::GroupMap::const_iterator it = 720 for (AppCacheWorkingSet::GroupMap::const_iterator it =
719 groups_in_use->begin(); 721 groups_in_use->begin();
720 it != groups_in_use->end(); ++it) { 722 it != groups_in_use->end(); ++it) {
721 AppCacheGroup* group = it->second; 723 AppCacheGroup* group = it->second;
722 AppCache* cache = group->newest_complete_cache(); 724 AppCache* cache = group->newest_complete_cache();
723 if (group->is_obsolete() || !cache) 725 if (group->is_obsolete() || !cache)
724 continue; 726 continue;
725 cache_ids_in_use_.insert(cache->cache_id()); 727 cache_ids_in_use_.insert(cache->cache_id());
726 } 728 }
(...skipping 10 matching lines...) Expand all
737 bool FindFallback(int64 preferred_id); 739 bool FindFallback(int64 preferred_id);
738 bool FindFirstValidFallback(const FallbackNameSpaceVector& fallbacks); 740 bool FindFirstValidFallback(const FallbackNameSpaceVector& fallbacks);
739 741
740 GURL url_; 742 GURL url_;
741 GURL preferred_manifest_url_; 743 GURL preferred_manifest_url_;
742 std::set<int64> cache_ids_in_use_; 744 std::set<int64> cache_ids_in_use_;
743 AppCacheEntry entry_; 745 AppCacheEntry entry_;
744 AppCacheEntry fallback_entry_; 746 AppCacheEntry fallback_entry_;
745 GURL fallback_url_; 747 GURL fallback_url_;
746 int64 cache_id_; 748 int64 cache_id_;
749 int64 group_id_;
747 GURL manifest_url_; 750 GURL manifest_url_;
748 }; 751 };
749 752
750 // Helpers for FindMainResponseTask::Run() 753 // Helpers for FindMainResponseTask::Run()
751 namespace { 754 namespace {
752 class SortByCachePreference 755 class SortByCachePreference
753 : public std::binary_function< 756 : public std::binary_function<
754 AppCacheDatabase::EntryRecord, 757 AppCacheDatabase::EntryRecord,
755 AppCacheDatabase::EntryRecord, 758 AppCacheDatabase::EntryRecord,
756 bool> { 759 bool> {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 ++iter; 815 ++iter;
813 } 816 }
814 } 817 }
815 818
816 // Key is cache id 819 // Key is cache id
817 typedef std::map<int64, std::vector<GURL> > WhiteListMap; 820 typedef std::map<int64, std::vector<GURL> > WhiteListMap;
818 WhiteListMap namespaces_map_; 821 WhiteListMap namespaces_map_;
819 AppCacheDatabase* database_; 822 AppCacheDatabase* database_;
820 }; 823 };
821 824
822 bool FindManifestForEntry(
823 const AppCacheDatabase::EntryRecord& entry_record,
824 AppCacheDatabase* database,
825 GURL* manifest_url_out) {
826 AppCacheDatabase::GroupRecord group_record;
827 if (!database->FindGroupForCache(entry_record.cache_id, &group_record)) {
828 NOTREACHED() << "A cache without a group is not expected.";
829 return false;
830 }
831 *manifest_url_out = group_record.manifest_url;
832 return true;
833 }
834
835 } // namespace 825 } // namespace
836 826
837 void AppCacheStorageImpl::FindMainResponseTask::Run() { 827 void AppCacheStorageImpl::FindMainResponseTask::Run() {
838 // NOTE: The heuristics around choosing amoungst multiple candidates 828 // NOTE: The heuristics around choosing amoungst multiple candidates
839 // is underspecified, and just plain not fully understood. This needs 829 // is underspecified, and just plain not fully understood. This needs
840 // to be refined. 830 // to be refined.
841 831
842 // The 'preferred_manifest_url' is the url of the manifest associated 832 // The 'preferred_manifest_url' is the url of the manifest associated
843 // with the page that opened or embedded the page being loaded now. 833 // with the page that opened or embedded the page being loaded now.
844 // We have a strong preference to use resources from that cache. 834 // We have a strong preference to use resources from that cache.
(...skipping 10 matching lines...) Expand all
855 preferred_manifest_url_, &preferred_group) && 845 preferred_manifest_url_, &preferred_group) &&
856 database_->FindCacheForGroup( 846 database_->FindCacheForGroup(
857 preferred_group.group_id, &preferred_cache)) { 847 preferred_group.group_id, &preferred_cache)) {
858 preferred_cache_id = preferred_cache.cache_id; 848 preferred_cache_id = preferred_cache.cache_id;
859 } 849 }
860 } 850 }
861 851
862 if (FindExactMatch(preferred_cache_id) || 852 if (FindExactMatch(preferred_cache_id) ||
863 FindFallback(preferred_cache_id)) { 853 FindFallback(preferred_cache_id)) {
864 // We found something. 854 // We found something.
865 DCHECK(cache_id_ != kNoCacheId && !manifest_url_.is_empty()); 855 DCHECK(cache_id_ != kNoCacheId && !manifest_url_.is_empty() &&
856 group_id_ != 0);
866 return; 857 return;
867 } 858 }
868 859
869 // We didn't find anything. 860 // We didn't find anything.
870 DCHECK(cache_id_ == kNoCacheId && manifest_url_.is_empty()); 861 DCHECK(cache_id_ == kNoCacheId && manifest_url_.is_empty() &&
862 group_id_ == 0);
871 } 863 }
872 864
873 bool AppCacheStorageImpl:: 865 bool AppCacheStorageImpl::
874 FindMainResponseTask::FindExactMatch(int64 preferred_cache_id) { 866 FindMainResponseTask::FindExactMatch(int64 preferred_cache_id) {
875 std::vector<AppCacheDatabase::EntryRecord> entries; 867 std::vector<AppCacheDatabase::EntryRecord> entries;
876 if (database_->FindEntriesForUrl(url_, &entries) && !entries.empty()) { 868 if (database_->FindEntriesForUrl(url_, &entries) && !entries.empty()) {
877 // Sort them in order of preference, from the preferred_cache first, 869 // Sort them in order of preference, from the preferred_cache first,
878 // followed by hits from caches that are 'in use', then the rest. 870 // followed by hits from caches that are 'in use', then the rest.
879 std::sort(entries.begin(), entries.end(), 871 std::sort(entries.begin(), entries.end(),
880 SortByCachePreference(preferred_cache_id, cache_ids_in_use_)); 872 SortByCachePreference(preferred_cache_id, cache_ids_in_use_));
881 873
882 // Take the first with a valid, non-foreign entry. 874 // Take the first with a valid, non-foreign entry.
883 std::vector<AppCacheDatabase::EntryRecord>::iterator iter; 875 std::vector<AppCacheDatabase::EntryRecord>::iterator iter;
884 for (iter = entries.begin(); iter < entries.end(); ++iter) { 876 for (iter = entries.begin(); iter < entries.end(); ++iter) {
877 AppCacheDatabase::GroupRecord group_record;
885 if ((iter->flags & AppCacheEntry::FOREIGN) || 878 if ((iter->flags & AppCacheEntry::FOREIGN) ||
886 !FindManifestForEntry(*iter, database_, &manifest_url_)) { 879 !database_->FindGroupForCache(iter->cache_id, &group_record)) {
887 continue; 880 continue;
888 } 881 }
882 manifest_url_ = group_record.manifest_url;
883 group_id_ = group_record.group_id;
889 entry_ = AppCacheEntry(iter->flags, iter->response_id); 884 entry_ = AppCacheEntry(iter->flags, iter->response_id);
890 cache_id_ = iter->cache_id; 885 cache_id_ = iter->cache_id;
891 return true; // We found an exact match. 886 return true; // We found an exact match.
892 } 887 }
893 } 888 }
894 return false; 889 return false;
895 } 890 }
896 891
897 bool AppCacheStorageImpl:: 892 bool AppCacheStorageImpl::
898 FindMainResponseTask::FindFallback(int64 preferred_cache_id) { 893 FindMainResponseTask::FindFallback(int64 preferred_cache_id) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 938
944 bool AppCacheStorageImpl:: 939 bool AppCacheStorageImpl::
945 FindMainResponseTask::FindFirstValidFallback( 940 FindMainResponseTask::FindFirstValidFallback(
946 const FallbackNameSpaceVector& fallbacks) { 941 const FallbackNameSpaceVector& fallbacks) {
947 // Take the first with a valid, non-foreign entry. 942 // Take the first with a valid, non-foreign entry.
948 FallbackNameSpaceVector::const_iterator iter; 943 FallbackNameSpaceVector::const_iterator iter;
949 for (iter = fallbacks.begin(); iter < fallbacks.end(); ++iter) { 944 for (iter = fallbacks.begin(); iter < fallbacks.end(); ++iter) {
950 AppCacheDatabase::EntryRecord entry_record; 945 AppCacheDatabase::EntryRecord entry_record;
951 if (database_->FindEntry((*iter)->cache_id, (*iter)->fallback_entry_url, 946 if (database_->FindEntry((*iter)->cache_id, (*iter)->fallback_entry_url,
952 &entry_record)) { 947 &entry_record)) {
948 AppCacheDatabase::GroupRecord group_record;
953 if ((entry_record.flags & AppCacheEntry::FOREIGN) || 949 if ((entry_record.flags & AppCacheEntry::FOREIGN) ||
954 !FindManifestForEntry(entry_record, database_, &manifest_url_)) { 950 !database_->FindGroupForCache(entry_record.cache_id, &group_record)) {
955 continue; 951 continue;
956 } 952 }
953 manifest_url_ = group_record.manifest_url;
954 group_id_ = group_record.group_id;
957 cache_id_ = (*iter)->cache_id; 955 cache_id_ = (*iter)->cache_id;
958 fallback_url_ = (*iter)->fallback_entry_url; 956 fallback_url_ = (*iter)->fallback_entry_url;
959 fallback_entry_ = AppCacheEntry( 957 fallback_entry_ = AppCacheEntry(
960 entry_record.flags, entry_record.response_id); 958 entry_record.flags, entry_record.response_id);
961 return true; // We found one. 959 return true; // We found one.
962 } 960 }
963 } 961 }
964 return false; // We didn't find a match. 962 return false; // We didn't find a match.
965 } 963 }
966 964
967 void AppCacheStorageImpl::FindMainResponseTask::RunCompleted() { 965 void AppCacheStorageImpl::FindMainResponseTask::RunCompleted() {
968 storage_->CallOnMainResponseFound( 966 storage_->CallOnMainResponseFound(
969 &delegates_, url_, entry_, fallback_url_, fallback_entry_, 967 &delegates_, url_, entry_, fallback_url_, fallback_entry_,
970 cache_id_, manifest_url_); 968 cache_id_, group_id_, manifest_url_);
971 } 969 }
972 970
973 // MarkEntryAsForeignTask ------- 971 // MarkEntryAsForeignTask -------
974 972
975 class AppCacheStorageImpl::MarkEntryAsForeignTask : public DatabaseTask { 973 class AppCacheStorageImpl::MarkEntryAsForeignTask : public DatabaseTask {
976 public: 974 public:
977 MarkEntryAsForeignTask( 975 MarkEntryAsForeignTask(
978 AppCacheStorageImpl* storage, const GURL& url, int64 cache_id) 976 AppCacheStorageImpl* storage, const GURL& url, int64 cache_id)
979 : DatabaseTask(storage), cache_id_(cache_id), entry_url_(url) {} 977 : DatabaseTask(storage), cache_id_(cache_id), entry_url_(url) {}
980 978
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 virtual void Run(); 1079 virtual void Run();
1082 virtual void RunCompleted(); 1080 virtual void RunCompleted();
1083 1081
1084 int64 max_rowid_; 1082 int64 max_rowid_;
1085 std::vector<int64> response_ids_; 1083 std::vector<int64> response_ids_;
1086 }; 1084 };
1087 1085
1088 void AppCacheStorageImpl::GetDeletableResponseIdsTask::Run() { 1086 void AppCacheStorageImpl::GetDeletableResponseIdsTask::Run() {
1089 const int kSqlLimit = 1000; 1087 const int kSqlLimit = 1000;
1090 database_->GetDeletableResponseIds(&response_ids_, max_rowid_, kSqlLimit); 1088 database_->GetDeletableResponseIds(&response_ids_, max_rowid_, kSqlLimit);
1089 // TODO(michaeln): retrieve group_ids too
1091 } 1090 }
1092 1091
1093 void AppCacheStorageImpl::GetDeletableResponseIdsTask::RunCompleted() { 1092 void AppCacheStorageImpl::GetDeletableResponseIdsTask::RunCompleted() {
1094 if (!response_ids_.empty()) 1093 if (!response_ids_.empty())
1095 storage_->StartDeletingResponses(response_ids_); 1094 storage_->StartDeletingResponses(response_ids_);
1096 } 1095 }
1097 1096
1098 // InsertDeletableResponseIdsTask ------- 1097 // InsertDeletableResponseIdsTask -------
1099 1098
1100 class AppCacheStorageImpl::InsertDeletableResponseIdsTask 1099 class AppCacheStorageImpl::InsertDeletableResponseIdsTask
1101 : public DatabaseTask { 1100 : public DatabaseTask {
1102 public: 1101 public:
1103 explicit InsertDeletableResponseIdsTask(AppCacheStorageImpl* storage) 1102 explicit InsertDeletableResponseIdsTask(AppCacheStorageImpl* storage)
1104 : DatabaseTask(storage) {} 1103 : DatabaseTask(storage) {}
1105 virtual void Run(); 1104 virtual void Run();
1106 std::vector<int64> response_ids_; 1105 std::vector<int64> response_ids_;
1107 }; 1106 };
1108 1107
1109 void AppCacheStorageImpl::InsertDeletableResponseIdsTask::Run() { 1108 void AppCacheStorageImpl::InsertDeletableResponseIdsTask::Run() {
1110 database_->InsertDeletableResponseIds(response_ids_); 1109 database_->InsertDeletableResponseIds(response_ids_);
1110 // TODO(michaeln): store group_ids too
1111 } 1111 }
1112 1112
1113 // DeleteDeletableResponseIdsTask ------- 1113 // DeleteDeletableResponseIdsTask -------
1114 1114
1115 class AppCacheStorageImpl::DeleteDeletableResponseIdsTask 1115 class AppCacheStorageImpl::DeleteDeletableResponseIdsTask
1116 : public DatabaseTask { 1116 : public DatabaseTask {
1117 public: 1117 public:
1118 explicit DeleteDeletableResponseIdsTask(AppCacheStorageImpl* storage) 1118 explicit DeleteDeletableResponseIdsTask(AppCacheStorageImpl* storage)
1119 : DatabaseTask(storage) {} 1119 : DatabaseTask(storage) {}
1120 virtual void Run(); 1120 virtual void Run();
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 const AppCacheEntry& found_entry, 1386 const AppCacheEntry& found_entry,
1387 scoped_refptr<AppCacheGroup> group, 1387 scoped_refptr<AppCacheGroup> group,
1388 scoped_refptr<AppCache> cache, 1388 scoped_refptr<AppCache> cache,
1389 scoped_refptr<DelegateReference> delegate_ref) { 1389 scoped_refptr<DelegateReference> delegate_ref) {
1390 if (delegate_ref->delegate) { 1390 if (delegate_ref->delegate) {
1391 DelegateReferenceVector delegates(1, delegate_ref); 1391 DelegateReferenceVector delegates(1, delegate_ref);
1392 CallOnMainResponseFound( 1392 CallOnMainResponseFound(
1393 &delegates, url, found_entry, 1393 &delegates, url, found_entry,
1394 GURL(), AppCacheEntry(), 1394 GURL(), AppCacheEntry(),
1395 cache.get() ? cache->cache_id() : kNoCacheId, 1395 cache.get() ? cache->cache_id() : kNoCacheId,
1396 group.get() ? group->group_id() : kNoCacheId,
1396 group.get() ? group->manifest_url() : GURL()); 1397 group.get() ? group->manifest_url() : GURL());
1397 } 1398 }
1398 } 1399 }
1399 1400
1400 void AppCacheStorageImpl::CallOnMainResponseFound( 1401 void AppCacheStorageImpl::CallOnMainResponseFound(
1401 DelegateReferenceVector* delegates, 1402 DelegateReferenceVector* delegates,
1402 const GURL& url, const AppCacheEntry& entry, 1403 const GURL& url, const AppCacheEntry& entry,
1403 const GURL& fallback_url, const AppCacheEntry& fallback_entry, 1404 const GURL& fallback_url, const AppCacheEntry& fallback_entry,
1404 int64 cache_id, const GURL& manifest_url) { 1405 int64 cache_id, int64 group_id, const GURL& manifest_url) {
1405 FOR_EACH_DELEGATE( 1406 FOR_EACH_DELEGATE(
1406 (*delegates), 1407 (*delegates),
1407 OnMainResponseFound(url, entry, 1408 OnMainResponseFound(url, entry,
1408 fallback_url, fallback_entry, 1409 fallback_url, fallback_entry,
1409 cache_id, manifest_url)); 1410 cache_id, group_id, manifest_url));
1410 } 1411 }
1411 1412
1412 void AppCacheStorageImpl::FindResponseForSubRequest( 1413 void AppCacheStorageImpl::FindResponseForSubRequest(
1413 AppCache* cache, const GURL& url, 1414 AppCache* cache, const GURL& url,
1414 AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry, 1415 AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry,
1415 bool* found_network_namespace) { 1416 bool* found_network_namespace) {
1416 DCHECK(cache && cache->is_complete()); 1417 DCHECK(cache && cache->is_complete());
1417 1418
1418 // When a group is forcibly deleted, all subresource loads for pages 1419 // When a group is forcibly deleted, all subresource loads for pages
1419 // using caches in the group will result in a synthesized network errors. 1420 // using caches in the group will result in a synthesized network errors.
(...skipping 29 matching lines...) Expand all
1449 void AppCacheStorageImpl::MakeGroupObsolete( 1450 void AppCacheStorageImpl::MakeGroupObsolete(
1450 AppCacheGroup* group, Delegate* delegate) { 1451 AppCacheGroup* group, Delegate* delegate) {
1451 DCHECK(group && delegate); 1452 DCHECK(group && delegate);
1452 scoped_refptr<MakeGroupObsoleteTask> task( 1453 scoped_refptr<MakeGroupObsoleteTask> task(
1453 new MakeGroupObsoleteTask(this, group)); 1454 new MakeGroupObsoleteTask(this, group));
1454 task->AddDelegate(GetOrCreateDelegateReference(delegate)); 1455 task->AddDelegate(GetOrCreateDelegateReference(delegate));
1455 task->Schedule(); 1456 task->Schedule();
1456 } 1457 }
1457 1458
1458 AppCacheResponseReader* AppCacheStorageImpl::CreateResponseReader( 1459 AppCacheResponseReader* AppCacheStorageImpl::CreateResponseReader(
1459 const GURL& manifest_url, int64 response_id) { 1460 const GURL& manifest_url, int64 group_id, int64 response_id) {
1460 return new AppCacheResponseReader(response_id, disk_cache()); 1461 return new AppCacheResponseReader(response_id, group_id, disk_cache());
1461 } 1462 }
1462 1463
1463 AppCacheResponseWriter* AppCacheStorageImpl::CreateResponseWriter( 1464 AppCacheResponseWriter* AppCacheStorageImpl::CreateResponseWriter(
1464 const GURL& manifest_url) { 1465 const GURL& manifest_url, int64 group_id) {
1465 return new AppCacheResponseWriter(NewResponseId(), disk_cache()); 1466 return new AppCacheResponseWriter(NewResponseId(), group_id, disk_cache());
1466 } 1467 }
1467 1468
1468 void AppCacheStorageImpl::DoomResponses( 1469 void AppCacheStorageImpl::DoomResponses(
1469 const GURL& manifest_url, const std::vector<int64>& response_ids) { 1470 const GURL& manifest_url, const std::vector<int64>& response_ids) {
1470 if (response_ids.empty()) 1471 if (response_ids.empty())
1471 return; 1472 return;
1472 1473
1473 // Start deleting them from the disk cache lazily. 1474 // Start deleting them from the disk cache lazily.
1474 StartDeletingResponses(response_ids); 1475 StartDeletingResponses(response_ids);
1475 1476
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 DCHECK(!deletable_response_ids_.empty()); 1533 DCHECK(!deletable_response_ids_.empty());
1533 1534
1534 if (!disk_cache()) { 1535 if (!disk_cache()) {
1535 DCHECK(is_disabled_); 1536 DCHECK(is_disabled_);
1536 deletable_response_ids_.clear(); 1537 deletable_response_ids_.clear();
1537 deleted_response_ids_.clear(); 1538 deleted_response_ids_.clear();
1538 is_response_deletion_scheduled_ = false; 1539 is_response_deletion_scheduled_ = false;
1539 return; 1540 return;
1540 } 1541 }
1541 1542
1543 // TODO(michaeln): add group_id to DoomEntry args
1542 int64 id = deletable_response_ids_.front(); 1544 int64 id = deletable_response_ids_.front();
1543 int rv = disk_cache_->DoomEntry(id, &doom_callback_); 1545 int rv = disk_cache_->DoomEntry(id, &doom_callback_);
1544 if (rv != net::ERR_IO_PENDING) 1546 if (rv != net::ERR_IO_PENDING)
1545 OnDeletedOneResponse(rv); 1547 OnDeletedOneResponse(rv);
1546 } 1548 }
1547 1549
1548 void AppCacheStorageImpl::OnDeletedOneResponse(int rv) { 1550 void AppCacheStorageImpl::OnDeletedOneResponse(int rv) {
1549 is_response_deletion_scheduled_ = false; 1551 is_response_deletion_scheduled_ = false;
1550 if (is_disabled_) 1552 if (is_disabled_)
1551 return; 1553 return;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 Disable(); 1656 Disable();
1655 if (!is_incognito_) { 1657 if (!is_incognito_) {
1656 VLOG(1) << "Deleting existing appcache data and starting over."; 1658 VLOG(1) << "Deleting existing appcache data and starting over.";
1657 db_thread_->PostTask( 1659 db_thread_->PostTask(
1658 FROM_HERE, base::Bind(&DeleteDirectory, cache_directory_)); 1660 FROM_HERE, base::Bind(&DeleteDirectory, cache_directory_));
1659 } 1661 }
1660 } 1662 }
1661 } 1663 }
1662 1664
1663 } // namespace appcache 1665 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_storage_impl.h ('k') | webkit/appcache/appcache_storage_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698