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

Side by Side Diff: content/browser/appcache/appcache_storage_impl.h

Issue 924723002: [appcache] Don't write during startup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
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 #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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 class StoreOrLoadTask; 84 class StoreOrLoadTask;
84 class CacheLoadTask; 85 class CacheLoadTask;
85 class GroupLoadTask; 86 class GroupLoadTask;
86 class StoreGroupAndCacheTask; 87 class StoreGroupAndCacheTask;
87 class FindMainResponseTask; 88 class FindMainResponseTask;
88 class MarkEntryAsForeignTask; 89 class MarkEntryAsForeignTask;
89 class MakeGroupObsoleteTask; 90 class MakeGroupObsoleteTask;
90 class GetDeletableResponseIdsTask; 91 class GetDeletableResponseIdsTask;
91 class InsertDeletableResponseIdsTask; 92 class InsertDeletableResponseIdsTask;
92 class DeleteDeletableResponseIdsTask; 93 class DeleteDeletableResponseIdsTask;
93 class UpdateGroupLastAccessTimeTask; 94 class LazyUpdateLastAccessTimeTask;
95 class CommitLastAccessTimesTask;
94 96
95 typedef std::deque<DatabaseTask*> DatabaseTaskQueue; 97 typedef std::deque<DatabaseTask*> DatabaseTaskQueue;
96 typedef std::map<int64, CacheLoadTask*> PendingCacheLoads; 98 typedef std::map<int64, CacheLoadTask*> PendingCacheLoads;
97 typedef std::map<GURL, GroupLoadTask*> PendingGroupLoads; 99 typedef std::map<GURL, GroupLoadTask*> PendingGroupLoads;
98 typedef std::deque<std::pair<GURL, int64> > PendingForeignMarkings; 100 typedef std::deque<std::pair<GURL, int64> > PendingForeignMarkings;
99 typedef std::set<StoreGroupAndCacheTask*> PendingQuotaQueries; 101 typedef std::set<StoreGroupAndCacheTask*> PendingQuotaQueries;
100 102
101 bool IsInitTaskComplete() { 103 bool IsInitTaskComplete() {
102 return last_cache_id_ != AppCacheStorage::kUnitializedId; 104 return last_cache_id_ != AppCacheStorage::kUnitializedId;
103 } 105 }
104 106
105 CacheLoadTask* GetPendingCacheLoadTask(int64 cache_id); 107 CacheLoadTask* GetPendingCacheLoadTask(int64 cache_id);
106 GroupLoadTask* GetPendingGroupLoadTask(const GURL& manifest_url); 108 GroupLoadTask* GetPendingGroupLoadTask(const GURL& manifest_url);
107 void GetPendingForeignMarkingsForCache( 109 void GetPendingForeignMarkingsForCache(
108 int64 cache_id, std::vector<GURL>* urls); 110 int64 cache_id, std::vector<GURL>* urls);
109 111
110 void ScheduleSimpleTask(const base::Closure& task); 112 void ScheduleSimpleTask(const base::Closure& task);
111 void RunOnePendingSimpleTask(); 113 void RunOnePendingSimpleTask();
112 114
113 void DelayedStartDeletingUnusedResponses(); 115 void DelayedStartDeletingUnusedResponses();
114 void StartDeletingResponses(const std::vector<int64>& response_ids); 116 void StartDeletingResponses(const std::vector<int64>& response_ids);
115 void ScheduleDeleteOneResponse(); 117 void ScheduleDeleteOneResponse();
116 void DeleteOneResponse(); 118 void DeleteOneResponse();
117
118 void OnDeletedOneResponse(int rv); 119 void OnDeletedOneResponse(int rv);
119 void OnDiskCacheInitialized(int rv); 120 void OnDiskCacheInitialized(int rv);
120 void DeleteAndStartOver(); 121 void DeleteAndStartOver();
121 void DeleteAndStartOverPart2(); 122 void DeleteAndStartOverPart2();
122 void CallScheduleReinitialize(); 123 void CallScheduleReinitialize();
124 void LazilyCommitLastAccessTimes();
125 void OnLazyCommitTimer();
123 126
124 // Sometimes we can respond without having to query the database. 127 // Sometimes we can respond without having to query the database.
125 bool FindResponseForMainRequestInGroup( 128 bool FindResponseForMainRequestInGroup(
126 AppCacheGroup* group, const GURL& url, Delegate* delegate); 129 AppCacheGroup* group, const GURL& url, Delegate* delegate);
127 void DeliverShortCircuitedFindMainResponse( 130 void DeliverShortCircuitedFindMainResponse(
128 const GURL& url, 131 const GURL& url,
129 const AppCacheEntry& found_entry, 132 const AppCacheEntry& found_entry,
130 scoped_refptr<AppCacheGroup> group, 133 scoped_refptr<AppCacheGroup> group,
131 scoped_refptr<AppCache> newest_cache, 134 scoped_refptr<AppCache> newest_cache,
132 scoped_refptr<DelegateReference> delegate_ref); 135 scoped_refptr<DelegateReference> delegate_ref);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 int64 last_deletable_response_rowid_; 167 int64 last_deletable_response_rowid_;
165 168
166 // Created on the IO thread, but only used on the DB thread. 169 // Created on the IO thread, but only used on the DB thread.
167 AppCacheDatabase* database_; 170 AppCacheDatabase* database_;
168 171
169 // Set if we discover a fatal error like a corrupt SQL database or 172 // Set if we discover a fatal error like a corrupt SQL database or
170 // disk cache and cannot continue. 173 // disk cache and cannot continue.
171 bool is_disabled_; 174 bool is_disabled_;
172 175
173 scoped_ptr<AppCacheDiskCache> disk_cache_; 176 scoped_ptr<AppCacheDiskCache> disk_cache_;
177 base::OneShotTimer<AppCacheStorageImpl> lazy_commit_timer_;
174 178
175 // Used to short-circuit certain operations without having to schedule 179 // Used to short-circuit certain operations without having to schedule
176 // any tasks on the background database thread. 180 // any tasks on the background database thread.
177 std::deque<base::Closure> pending_simple_tasks_; 181 std::deque<base::Closure> pending_simple_tasks_;
178 base::WeakPtrFactory<AppCacheStorageImpl> weak_factory_; 182 base::WeakPtrFactory<AppCacheStorageImpl> weak_factory_;
179 183
180 friend class content::AppCacheStorageImplTest; 184 friend class content::AppCacheStorageImplTest;
181 friend class content::ChromeAppCacheServiceTest; 185 friend class content::ChromeAppCacheServiceTest;
182 }; 186 };
183 187
184 } // namespace content 188 } // namespace content
185 189
186 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_STORAGE_IMPL_H_ 190 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_STORAGE_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_database.cc ('k') | content/browser/appcache/appcache_storage_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698