| OLD | NEW |
| 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 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_STORAGE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_STORAGE_IMPL_H_ |
| 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_STORAGE_IMPL_H_ | 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_STORAGE_IMPL_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/timer/timer.h" |
| 18 #include "content/browser/appcache/appcache_database.h" | 19 #include "content/browser/appcache/appcache_database.h" |
| 19 #include "content/browser/appcache/appcache_disk_cache.h" | 20 #include "content/browser/appcache/appcache_disk_cache.h" |
| 20 #include "content/browser/appcache/appcache_storage.h" | 21 #include "content/browser/appcache/appcache_storage.h" |
| 21 #include "content/common/content_export.h" | 22 #include "content/common/content_export.h" |
| 22 | 23 |
| 23 namespace base { | 24 namespace base { |
| 24 class SingleThreadTaskRunner; | 25 class SingleThreadTaskRunner; |
| 25 } // namespace base | 26 } // namespace base |
| 26 | 27 |
| 27 namespace content { | 28 namespace content { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 class StoreOrLoadTask; | 81 class StoreOrLoadTask; |
| 81 class CacheLoadTask; | 82 class CacheLoadTask; |
| 82 class GroupLoadTask; | 83 class GroupLoadTask; |
| 83 class StoreGroupAndCacheTask; | 84 class StoreGroupAndCacheTask; |
| 84 class FindMainResponseTask; | 85 class FindMainResponseTask; |
| 85 class MarkEntryAsForeignTask; | 86 class MarkEntryAsForeignTask; |
| 86 class MakeGroupObsoleteTask; | 87 class MakeGroupObsoleteTask; |
| 87 class GetDeletableResponseIdsTask; | 88 class GetDeletableResponseIdsTask; |
| 88 class InsertDeletableResponseIdsTask; | 89 class InsertDeletableResponseIdsTask; |
| 89 class DeleteDeletableResponseIdsTask; | 90 class DeleteDeletableResponseIdsTask; |
| 90 class UpdateGroupLastAccessTimeTask; | 91 class LazyUpdateLastAccessTimeTask; |
| 92 class CommitLastAccessTimesTask; |
| 91 | 93 |
| 92 typedef std::deque<DatabaseTask*> DatabaseTaskQueue; | 94 typedef std::deque<DatabaseTask*> DatabaseTaskQueue; |
| 93 typedef std::map<int64, CacheLoadTask*> PendingCacheLoads; | 95 typedef std::map<int64, CacheLoadTask*> PendingCacheLoads; |
| 94 typedef std::map<GURL, GroupLoadTask*> PendingGroupLoads; | 96 typedef std::map<GURL, GroupLoadTask*> PendingGroupLoads; |
| 95 typedef std::deque<std::pair<GURL, int64> > PendingForeignMarkings; | 97 typedef std::deque<std::pair<GURL, int64> > PendingForeignMarkings; |
| 96 typedef std::set<StoreGroupAndCacheTask*> PendingQuotaQueries; | 98 typedef std::set<StoreGroupAndCacheTask*> PendingQuotaQueries; |
| 97 | 99 |
| 98 bool IsInitTaskComplete() { | 100 bool IsInitTaskComplete() { |
| 99 return last_cache_id_ != AppCacheStorage::kUnitializedId; | 101 return last_cache_id_ != AppCacheStorage::kUnitializedId; |
| 100 } | 102 } |
| 101 | 103 |
| 102 CacheLoadTask* GetPendingCacheLoadTask(int64 cache_id); | 104 CacheLoadTask* GetPendingCacheLoadTask(int64 cache_id); |
| 103 GroupLoadTask* GetPendingGroupLoadTask(const GURL& manifest_url); | 105 GroupLoadTask* GetPendingGroupLoadTask(const GURL& manifest_url); |
| 104 void GetPendingForeignMarkingsForCache( | 106 void GetPendingForeignMarkingsForCache( |
| 105 int64 cache_id, std::vector<GURL>* urls); | 107 int64 cache_id, std::vector<GURL>* urls); |
| 106 | 108 |
| 107 void ScheduleSimpleTask(const base::Closure& task); | 109 void ScheduleSimpleTask(const base::Closure& task); |
| 108 void RunOnePendingSimpleTask(); | 110 void RunOnePendingSimpleTask(); |
| 109 | 111 |
| 110 void DelayedStartDeletingUnusedResponses(); | 112 void DelayedStartDeletingUnusedResponses(); |
| 111 void StartDeletingResponses(const std::vector<int64>& response_ids); | 113 void StartDeletingResponses(const std::vector<int64>& response_ids); |
| 112 void ScheduleDeleteOneResponse(); | 114 void ScheduleDeleteOneResponse(); |
| 113 void DeleteOneResponse(); | 115 void DeleteOneResponse(); |
| 114 | |
| 115 void OnDeletedOneResponse(int rv); | 116 void OnDeletedOneResponse(int rv); |
| 116 void OnDiskCacheInitialized(int rv); | 117 void OnDiskCacheInitialized(int rv); |
| 117 void DeleteAndStartOver(); | 118 void DeleteAndStartOver(); |
| 118 void DeleteAndStartOverPart2(); | 119 void DeleteAndStartOverPart2(); |
| 119 void CallScheduleReinitialize(); | 120 void CallScheduleReinitialize(); |
| 121 void LazilyCommitLastAccessTimes(); |
| 122 void OnCommitLastAccessTimes(); |
| 120 | 123 |
| 121 // Sometimes we can respond without having to query the database. | 124 // Sometimes we can respond without having to query the database. |
| 122 bool FindResponseForMainRequestInGroup( | 125 bool FindResponseForMainRequestInGroup( |
| 123 AppCacheGroup* group, const GURL& url, Delegate* delegate); | 126 AppCacheGroup* group, const GURL& url, Delegate* delegate); |
| 124 void DeliverShortCircuitedFindMainResponse( | 127 void DeliverShortCircuitedFindMainResponse( |
| 125 const GURL& url, | 128 const GURL& url, |
| 126 const AppCacheEntry& found_entry, | 129 const AppCacheEntry& found_entry, |
| 127 scoped_refptr<AppCacheGroup> group, | 130 scoped_refptr<AppCacheGroup> group, |
| 128 scoped_refptr<AppCache> newest_cache, | 131 scoped_refptr<AppCache> newest_cache, |
| 129 scoped_refptr<DelegateReference> delegate_ref); | 132 scoped_refptr<DelegateReference> delegate_ref); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 int64 last_deletable_response_rowid_; | 164 int64 last_deletable_response_rowid_; |
| 162 | 165 |
| 163 // Created on the IO thread, but only used on the DB thread. | 166 // Created on the IO thread, but only used on the DB thread. |
| 164 AppCacheDatabase* database_; | 167 AppCacheDatabase* database_; |
| 165 | 168 |
| 166 // Set if we discover a fatal error like a corrupt SQL database or | 169 // Set if we discover a fatal error like a corrupt SQL database or |
| 167 // disk cache and cannot continue. | 170 // disk cache and cannot continue. |
| 168 bool is_disabled_; | 171 bool is_disabled_; |
| 169 | 172 |
| 170 scoped_ptr<AppCacheDiskCache> disk_cache_; | 173 scoped_ptr<AppCacheDiskCache> disk_cache_; |
| 174 base::OneShotTimer<AppCacheStorageImpl> lazy_commit_timer_; |
| 171 | 175 |
| 172 // Used to short-circuit certain operations without having to schedule | 176 // Used to short-circuit certain operations without having to schedule |
| 173 // any tasks on the background database thread. | 177 // any tasks on the background database thread. |
| 174 std::deque<base::Closure> pending_simple_tasks_; | 178 std::deque<base::Closure> pending_simple_tasks_; |
| 175 base::WeakPtrFactory<AppCacheStorageImpl> weak_factory_; | 179 base::WeakPtrFactory<AppCacheStorageImpl> weak_factory_; |
| 176 | 180 |
| 177 friend class content::AppCacheStorageImplTest; | 181 friend class content::AppCacheStorageImplTest; |
| 178 friend class content::ChromeAppCacheServiceTest; | 182 friend class content::ChromeAppCacheServiceTest; |
| 179 }; | 183 }; |
| 180 | 184 |
| 181 } // namespace content | 185 } // namespace content |
| 182 | 186 |
| 183 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_STORAGE_IMPL_H_ | 187 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_STORAGE_IMPL_H_ |
| OLD | NEW |