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

Side by Side Diff: storage/browser/quota/quota_manager.h

Issue 1782053004: Change how the quota system computes the total poolsize for temporary storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ 5 #ifndef STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_
6 #define STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ 6 #define STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
11 #include <list> 11 #include <list>
12 #include <map> 12 #include <map>
13 #include <memory> 13 #include <memory>
14 #include <set> 14 #include <set>
15 #include <string> 15 #include <string>
16 #include <utility> 16 #include <utility>
17 #include <vector> 17 #include <vector>
18 18
19 #include "base/callback.h" 19 #include "base/callback.h"
20 #include "base/files/file_path.h" 20 #include "base/files/file_path.h"
21 #include "base/macros.h" 21 #include "base/macros.h"
22 #include "base/memory/ref_counted.h" 22 #include "base/memory/ref_counted.h"
23 #include "base/memory/weak_ptr.h" 23 #include "base/memory/weak_ptr.h"
24 #include "base/optional.h"
24 #include "base/sequenced_task_runner_helpers.h" 25 #include "base/sequenced_task_runner_helpers.h"
25 #include "storage/browser/quota/quota_callbacks.h" 26 #include "storage/browser/quota/quota_callbacks.h"
26 #include "storage/browser/quota/quota_client.h" 27 #include "storage/browser/quota/quota_client.h"
27 #include "storage/browser/quota/quota_database.h" 28 #include "storage/browser/quota/quota_database.h"
29 #include "storage/browser/quota/quota_settings.h"
28 #include "storage/browser/quota/quota_task.h" 30 #include "storage/browser/quota/quota_task.h"
29 #include "storage/browser/quota/special_storage_policy.h" 31 #include "storage/browser/quota/special_storage_policy.h"
30 #include "storage/browser/quota/storage_observer.h" 32 #include "storage/browser/quota/storage_observer.h"
31 #include "storage/browser/storage_browser_export.h" 33 #include "storage/browser/storage_browser_export.h"
32 34
33 class SiteEngagementEvictionPolicyWithQuotaManagerTest; 35 class SiteEngagementEvictionPolicyWithQuotaManagerTest;
34 36
35 namespace base { 37 namespace base {
36 class FilePath; 38 class FilePath;
37 class SequencedTaskRunner; 39 class SequencedTaskRunner;
(...skipping 15 matching lines...) Expand all
53 namespace storage { 55 namespace storage {
54 56
55 class QuotaDatabase; 57 class QuotaDatabase;
56 class QuotaManagerProxy; 58 class QuotaManagerProxy;
57 class QuotaTemporaryStorageEvictor; 59 class QuotaTemporaryStorageEvictor;
58 class StorageMonitor; 60 class StorageMonitor;
59 class UsageTracker; 61 class UsageTracker;
60 62
61 struct QuotaManagerDeleter; 63 struct QuotaManagerDeleter;
62 64
63 struct STORAGE_EXPORT UsageAndQuota { 65 // DEPRECATED
64 int64_t usage;
65 int64_t global_limited_usage;
66 int64_t quota;
67 int64_t available_disk_space;
68
69 UsageAndQuota();
70 UsageAndQuota(int64_t usage,
71 int64_t global_limited_usage,
72 int64_t quota,
73 int64_t available_disk_space);
74 };
75
76 // TODO(calamity): Use this in the temporary storage eviction path. 66 // TODO(calamity): Use this in the temporary storage eviction path.
77 // An interface for deciding which origin's storage should be evicted when the 67 // An interface for deciding which origin's storage should be evicted when the
78 // quota is exceeded. 68 // quota is exceeded.
79 class STORAGE_EXPORT QuotaEvictionPolicy { 69 class STORAGE_EXPORT QuotaEvictionPolicy {
80 public: 70 public:
81 virtual ~QuotaEvictionPolicy() {} 71 virtual ~QuotaEvictionPolicy() {}
82 72
83 // Returns the next origin to evict. It might return an empty GURL when there 73 // Returns the next origin to evict. It might return an empty GURL when there
84 // are no evictable origins. 74 // are no evictable origins.
85 virtual void GetEvictionOrigin( 75 virtual void GetEvictionOrigin(
86 const scoped_refptr<SpecialStoragePolicy>& special_storage_policy, 76 const scoped_refptr<SpecialStoragePolicy>& special_storage_policy,
87 const std::set<GURL>& exceptions, 77 const std::set<GURL>& exceptions,
88 const std::map<GURL, int64_t>& usage_map, 78 const std::map<GURL, int64_t>& usage_map,
89 int64_t global_quota, 79 int64_t global_quota,
90 const GetOriginCallback& callback) = 0; 80 const GetOriginCallback& callback) = 0;
91 }; 81 };
92 82
93 // An interface called by QuotaTemporaryStorageEvictor. 83 // An interface called by QuotaTemporaryStorageEvictor.
94 class STORAGE_EXPORT QuotaEvictionHandler { 84 class STORAGE_EXPORT QuotaEvictionHandler {
95 public: 85 public:
96 using EvictOriginDataCallback = StatusCallback; 86 using EvictionRoundInfoCallback =
97 using UsageAndQuotaCallback = base::Callback< 87 base::Callback<void(QuotaStatusCode status,
98 void(QuotaStatusCode status, const UsageAndQuota& usage_and_quota)>; 88 const QuotaSettings& settings,
99 using VolumeInfoCallback = base::Callback< 89 int64_t available_space,
100 void(bool success, uint64_t available_space, uint64_t total_space)>; 90 int64_t total_space,
91 int64_t global_usage,
92 bool global_usage_is_complete)>;
93
94 // Called at the beginning of an eviction round to gather the info about
95 // the current settings, capacity, and usage.
96 virtual void GetEvictionRoundInfo(
97 const EvictionRoundInfoCallback& callback) = 0;
101 98
102 // Returns next origin to evict. It might return an empty GURL when there are 99 // Returns next origin to evict. It might return an empty GURL when there are
103 // no evictable origins. 100 // no evictable origins.
104 virtual void GetEvictionOrigin(StorageType type, 101 virtual void GetEvictionOrigin(StorageType type,
105 const std::set<GURL>& extra_exceptions, 102 const std::set<GURL>& extra_exceptions,
106 int64_t global_quota, 103 int64_t global_quota,
107 const GetOriginCallback& callback) = 0; 104 const GetOriginCallback& callback) = 0;
108 105
109 virtual void EvictOriginData( 106 // Called to evict an origin.
110 const GURL& origin, 107 virtual void EvictOriginData(const GURL& origin,
111 StorageType type, 108 StorageType type,
112 const EvictOriginDataCallback& callback) = 0; 109 const StatusCallback& callback) = 0;
113
114 virtual void AsyncGetVolumeInfo(const VolumeInfoCallback& callback) = 0;
115 virtual void GetUsageAndQuotaForEviction(
116 const UsageAndQuotaCallback& callback) = 0;
117 110
118 protected: 111 protected:
119 virtual ~QuotaEvictionHandler() {} 112 virtual ~QuotaEvictionHandler() {}
120 }; 113 };
121 114
122 struct UsageInfo { 115 struct UsageInfo {
123 UsageInfo(const std::string& host, StorageType type, int64_t usage) 116 UsageInfo(const std::string& host, StorageType type, int64_t usage)
124 : host(host), type(type), usage(usage) {} 117 : host(host), type(type), usage(usage) {}
125 std::string host; 118 std::string host;
126 StorageType type; 119 StorageType type;
127 int64_t usage; 120 int64_t usage;
128 }; 121 };
129 122
130 // The quota manager class. This class is instantiated per profile and 123 // The quota manager class. This class is instantiated per profile and
131 // held by the profile. With the exception of the constructor and the 124 // held by the profile. With the exception of the constructor and the
132 // proxy() method, all methods should only be called on the IO thread. 125 // proxy() method, all methods should only be called on the IO thread.
133 class STORAGE_EXPORT QuotaManager 126 class STORAGE_EXPORT QuotaManager
134 : public QuotaTaskObserver, 127 : public QuotaTaskObserver,
135 public QuotaEvictionHandler, 128 public QuotaEvictionHandler,
136 public base::RefCountedThreadSafe<QuotaManager, QuotaManagerDeleter> { 129 public base::RefCountedThreadSafe<QuotaManager, QuotaManagerDeleter> {
137 public: 130 public:
138 typedef base::Callback<void(QuotaStatusCode, 131 typedef base::Callback<
139 int64_t /* usage */, 132 void(QuotaStatusCode, int64_t /* usage */, int64_t /* quota */)>
140 int64_t /* quota */)> GetUsageAndQuotaCallback; 133 UsageAndQuotaCallback;
141 134
142 static const int64_t kIncognitoDefaultQuotaLimit;
143 static const int64_t kNoLimit; 135 static const int64_t kNoLimit;
144 136
145 QuotaManager( 137 QuotaManager(
146 bool is_incognito, 138 bool is_incognito,
147 const base::FilePath& profile_path, 139 const base::FilePath& profile_path,
148 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread, 140 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread,
149 const scoped_refptr<base::SequencedTaskRunner>& db_thread, 141 const scoped_refptr<base::SequencedTaskRunner>& db_thread,
150 const scoped_refptr<SpecialStoragePolicy>& special_storage_policy); 142 const scoped_refptr<SpecialStoragePolicy>& special_storage_policy,
143 const GetQuotaSettingsFunc& get_settings_function);
144
145 const QuotaSettings& settings() const { return settings_; }
146 void SetQuotaSettings(const QuotaSettings& settings);
151 147
152 // Returns a proxy object that can be used on any thread. 148 // Returns a proxy object that can be used on any thread.
153 QuotaManagerProxy* proxy() { return proxy_.get(); } 149 QuotaManagerProxy* proxy() { return proxy_.get(); }
154 150
155 // Called by clients or webapps. Returns usage per host. 151 // Called by clients or webapps. Returns usage per host.
156 void GetUsageInfo(const GetUsageInfoCallback& callback); 152 void GetUsageInfo(const GetUsageInfoCallback& callback);
157 153
158 // Called by Web Apps. 154 // Called by Web Apps.
159 // This method is declared as virtual to allow test code to override it. 155 // This method is declared as virtual to allow test code to override it.
160 virtual void GetUsageAndQuotaForWebApps( 156 virtual void GetUsageAndQuotaForWebApps(
161 const GURL& origin, 157 const GURL& origin,
162 StorageType type, 158 StorageType type,
163 const GetUsageAndQuotaCallback& callback); 159 const UsageAndQuotaCallback& callback);
164 160
165 // Called by StorageClients. 161 // Called by StorageClients.
166 // This method is declared as virtual to allow test code to override it. 162 // This method is declared as virtual to allow test code to override it.
167 // 163 //
168 // For UnlimitedStorage origins, this version skips usage and quota handling 164 // For UnlimitedStorage origins, this version skips usage and quota handling
169 // to avoid extra query cost. 165 // to avoid extra query cost.
170 // Do not call this method for apps/user-facing code. 166 // Do not call this method for apps/user-facing code.
171 virtual void GetUsageAndQuota( 167 virtual void GetUsageAndQuota(const GURL& origin,
172 const GURL& origin, 168 StorageType type,
173 StorageType type, 169 const UsageAndQuotaCallback& callback);
174 const GetUsageAndQuotaCallback& callback);
175 170
176 // Called by clients via proxy. 171 // Called by clients via proxy.
177 // Client storage should call this method when storage is accessed. 172 // Client storage should call this method when storage is accessed.
178 // Used to maintain LRU ordering. 173 // Used to maintain LRU ordering.
179 void NotifyStorageAccessed(QuotaClient::ID client_id, 174 void NotifyStorageAccessed(QuotaClient::ID client_id,
180 const GURL& origin, 175 const GURL& origin,
181 StorageType type); 176 StorageType type);
182 177
183 // Called by clients via proxy. 178 // Called by clients via proxy.
184 // Client storage must call this method whenever they have made any 179 // Client storage must call this method whenever they have made any
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 virtual void DeleteOriginData(const GURL& origin, 211 virtual void DeleteOriginData(const GURL& origin,
217 StorageType type, 212 StorageType type,
218 int quota_client_mask, 213 int quota_client_mask,
219 const StatusCallback& callback); 214 const StatusCallback& callback);
220 void DeleteHostData(const std::string& host, 215 void DeleteHostData(const std::string& host,
221 StorageType type, 216 StorageType type,
222 int quota_client_mask, 217 int quota_client_mask,
223 const StatusCallback& callback); 218 const StatusCallback& callback);
224 219
225 // Called by UI and internal modules. 220 // Called by UI and internal modules.
226 void GetAvailableSpace(const AvailableSpaceCallback& callback);
227 void GetTemporaryGlobalQuota(const QuotaCallback& callback);
228
229 // Ok to call with NULL callback.
230 void SetTemporaryGlobalOverrideQuota(int64_t new_quota,
231 const QuotaCallback& callback);
232
233 void GetPersistentHostQuota(const std::string& host, 221 void GetPersistentHostQuota(const std::string& host,
234 const QuotaCallback& callback); 222 const QuotaCallback& callback);
235 void SetPersistentHostQuota(const std::string& host, 223 void SetPersistentHostQuota(const std::string& host,
236 int64_t new_quota, 224 int64_t new_quota,
237 const QuotaCallback& callback); 225 const QuotaCallback& callback);
238 void GetGlobalUsage(StorageType type, const GlobalUsageCallback& callback); 226 void GetGlobalUsage(StorageType type, const GlobalUsageCallback& callback);
239 void GetHostUsage(const std::string& host, StorageType type, 227 void GetHostUsage(const std::string& host, StorageType type,
240 const UsageCallback& callback); 228 const UsageCallback& callback);
241 void GetHostUsage(const std::string& host, StorageType type, 229 void GetHostUsage(const std::string& host, StorageType type,
242 QuotaClient::ID client_id, 230 QuotaClient::ID client_id,
243 const UsageCallback& callback); 231 const UsageCallback& callback);
244 232
245 bool IsTrackingHostUsage(StorageType type, QuotaClient::ID client_id) const; 233 bool IsTrackingHostUsage(StorageType type, QuotaClient::ID client_id) const;
246 234
247 void GetStatistics(std::map<std::string, std::string>* statistics); 235 void GetStatistics(std::map<std::string, std::string>* statistics);
248 236
249 bool IsStorageUnlimited(const GURL& origin, StorageType type) const; 237 bool IsStorageUnlimited(const GURL& origin, StorageType type) const;
250 238
251 bool CanQueryDiskSize(const GURL& origin) const {
252 return special_storage_policy_.get() &&
253 special_storage_policy_->CanQueryDiskSize(origin);
254 }
255
256 virtual void GetOriginsModifiedSince(StorageType type, 239 virtual void GetOriginsModifiedSince(StorageType type,
257 base::Time modified_since, 240 base::Time modified_since,
258 const GetOriginsCallback& callback); 241 const GetOriginsCallback& callback);
259 242
260 bool ResetUsageTracker(StorageType type); 243 bool ResetUsageTracker(StorageType type);
261 244
262 // Used to register/deregister observers that wish to monitor storage events. 245 // Used to register/deregister observers that wish to monitor storage events.
263 void AddStorageObserver(StorageObserver* observer, 246 void AddStorageObserver(StorageObserver* observer,
264 const StorageObserver::MonitorParams& params); 247 const StorageObserver::MonitorParams& params);
265 void RemoveStorageObserver(StorageObserver* observer); 248 void RemoveStorageObserver(StorageObserver* observer);
266 void RemoveStorageObserverForFilter(StorageObserver* observer, 249 void RemoveStorageObserverForFilter(StorageObserver* observer,
267 const StorageObserver::Filter& filter); 250 const StorageObserver::Filter& filter);
268 251
269 // Determines the portion of the temp pool that can be
270 // utilized by a single host (ie. 5 for 20%).
271 static const int kPerHostTemporaryPortion;
272
273 static const int64_t kPerHostPersistentQuotaLimit; 252 static const int64_t kPerHostPersistentQuotaLimit;
274
275 static const char kDatabaseName[]; 253 static const char kDatabaseName[];
276
277 static const int kThresholdOfErrorsToBeBlacklisted; 254 static const int kThresholdOfErrorsToBeBlacklisted;
278
279 static const int kEvictionIntervalInMilliSeconds; 255 static const int kEvictionIntervalInMilliSeconds;
280
281 static const char kTimeBetweenRepeatedOriginEvictionsHistogram[]; 256 static const char kTimeBetweenRepeatedOriginEvictionsHistogram[];
282 static const char kEvictedOriginAccessedCountHistogram[]; 257 static const char kEvictedOriginAccessedCountHistogram[];
283 static const char kEvictedOriginTimeSinceAccessHistogram[]; 258 static const char kEvictedOriginTimeSinceAccessHistogram[];
284 259
285 // These are kept non-const so that test code can change the value. 260 // Kept non-const so that test code can change the value.
286 // TODO(kinuko): Make this a real const value and add a proper way to set 261 // TODO(kinuko): Make this a real const value and add a proper way to set
287 // the quota for syncable storage. (http://crbug.com/155488) 262 // the quota for syncable storage. (http://crbug.com/155488)
288 static int64_t kMinimumPreserveForSystem;
289 static int64_t kSyncableStorageDefaultHostQuota; 263 static int64_t kSyncableStorageDefaultHostQuota;
290 264
291 protected: 265 protected:
292 ~QuotaManager() override; 266 ~QuotaManager() override;
293 267
294 private: 268 private:
295 friend class base::DeleteHelper<QuotaManager>; 269 friend class base::DeleteHelper<QuotaManager>;
296 friend class base::RefCountedThreadSafe<QuotaManager, QuotaManagerDeleter>; 270 friend class base::RefCountedThreadSafe<QuotaManager, QuotaManagerDeleter>;
297 friend class content::QuotaManagerTest; 271 friend class content::QuotaManagerTest;
298 friend class content::StorageMonitorTest; 272 friend class content::StorageMonitorTest;
299 friend class content::MockQuotaManager; 273 friend class content::MockQuotaManager;
300 friend class content::MockStorageClient; 274 friend class content::MockStorageClient;
301 friend class quota_internals::QuotaInternalsProxy; 275 friend class quota_internals::QuotaInternalsProxy;
302 friend class QuotaManagerProxy; 276 friend class QuotaManagerProxy;
303 friend class QuotaTemporaryStorageEvictor; 277 friend class QuotaTemporaryStorageEvictor;
304 friend struct QuotaManagerDeleter; 278 friend struct QuotaManagerDeleter;
305 friend class ::SiteEngagementEvictionPolicyWithQuotaManagerTest; 279 friend class ::SiteEngagementEvictionPolicyWithQuotaManagerTest;
306 280
281 class EvictionRoundInfoHelper;
282 class UsageAndQuotaHelper;
307 class GetUsageInfoTask; 283 class GetUsageInfoTask;
308
309 class OriginDataDeleter; 284 class OriginDataDeleter;
310 class HostDataDeleter; 285 class HostDataDeleter;
311
312 class GetModifiedSinceHelper; 286 class GetModifiedSinceHelper;
313 class DumpQuotaTableHelper; 287 class DumpQuotaTableHelper;
314 class DumpOriginInfoTableHelper; 288 class DumpOriginInfoTableHelper;
315 289
316 typedef QuotaDatabase::QuotaTableEntry QuotaTableEntry; 290 typedef QuotaDatabase::QuotaTableEntry QuotaTableEntry;
317 typedef QuotaDatabase::OriginInfoTableEntry OriginInfoTableEntry; 291 typedef QuotaDatabase::OriginInfoTableEntry OriginInfoTableEntry;
318 typedef std::vector<QuotaTableEntry> QuotaTableEntries; 292 typedef std::vector<QuotaTableEntry> QuotaTableEntries;
319 typedef std::vector<OriginInfoTableEntry> OriginInfoTableEntries; 293 typedef std::vector<OriginInfoTableEntry> OriginInfoTableEntries;
320 294
295 using QuotaSettingsCallback = base::Callback<void(const QuotaSettings&)>;
296
321 // Function pointer type used to store the function which returns 297 // Function pointer type used to store the function which returns
322 // information about the volume containing the given FilePath. 298 // information about the volume containing the given FilePath.
323 using GetVolumeInfoFn = bool(*)(const base::FilePath&, 299 // The value returned is std::pair<total_space, available_space>.
324 uint64_t* available, uint64_t* total); 300 using GetVolumeInfoFn =
301 std::pair<int64_t, int64_t> (*)(const base::FilePath&);
325 302
326 typedef base::Callback<void(const QuotaTableEntries&)> 303 typedef base::Callback<void(const QuotaTableEntries&)>
327 DumpQuotaTableCallback; 304 DumpQuotaTableCallback;
328 typedef base::Callback<void(const OriginInfoTableEntries&)> 305 typedef base::Callback<void(const OriginInfoTableEntries&)>
329 DumpOriginInfoTableCallback; 306 DumpOriginInfoTableCallback;
330 307
331 typedef CallbackQueue<base::Closure> ClosureQueue; 308 typedef CallbackQueue<base::Closure> ClosureQueue;
332 typedef CallbackQueue<AvailableSpaceCallback, QuotaStatusCode, int64_t>
333 AvailableSpaceCallbackQueue;
334 typedef CallbackQueueMap<QuotaCallback, std::string, QuotaStatusCode, int64_t> 309 typedef CallbackQueueMap<QuotaCallback, std::string, QuotaStatusCode, int64_t>
335 HostQuotaCallbackMap; 310 HostQuotaCallbackMap;
311 using QuotaSettingsCallbackQueue =
312 CallbackQueue<QuotaSettingsCallback, const QuotaSettings&>;
313
314 // The values returned total_space, available_space.
315 using StorageCapacityCallback = base::Callback<void(int64_t, int64_t)>;
316 using StorageCapacityCallbackQueue =
317 CallbackQueue<StorageCapacityCallback, int64_t, int64_t>;
336 318
337 struct EvictionContext { 319 struct EvictionContext {
338 EvictionContext(); 320 EvictionContext();
339 virtual ~EvictionContext(); 321 ~EvictionContext();
340 GURL evicted_origin; 322 GURL evicted_origin;
341 StorageType evicted_type; 323 StorageType evicted_type;
342 324 StatusCallback evict_origin_data_callback;
343 EvictOriginDataCallback evict_origin_data_callback;
344 }; 325 };
345 326
346 typedef QuotaEvictionHandler::UsageAndQuotaCallback
347 UsageAndQuotaDispatcherCallback;
348
349 // This initialization method is lazily called on the IO thread 327 // This initialization method is lazily called on the IO thread
350 // when the first quota manager API is called. 328 // when the first quota manager API is called.
351 // Initialize must be called after all quota clients are added to the 329 // Initialize must be called after all quota clients are added to the
352 // manager by RegisterStorage. 330 // manager by RegisterStorage.
353 void LazyInitialize(); 331 void LazyInitialize();
332 void FinishLazyInitialize(bool is_database_bootstraped);
333 void BootstrapDatabaseForEviction(
334 const GetOriginCallback& did_get_origin_callback,
335 int64_t unused_usage,
336 int64_t unused_unlimited_usage);
337 void DidBootstrapDatabase(const GetOriginCallback& did_get_origin_callback,
338 bool success);
354 339
355 // Called by clients via proxy. 340 // Called by clients via proxy.
356 // Registers a quota client to the manager. 341 // Registers a quota client to the manager.
357 // The client must remain valid until OnQuotaManagerDestored is called. 342 // The client must remain valid until OnQuotaManagerDestored is called.
358 void RegisterClient(QuotaClient* client); 343 void RegisterClient(QuotaClient* client);
359 344
360 UsageTracker* GetUsageTracker(StorageType type) const; 345 UsageTracker* GetUsageTracker(StorageType type) const;
361 346
362 // Extract cached origins list from the usage tracker. 347 // Extract cached origins list from the usage tracker.
363 // (Might return empty list if no origin is tracked by the tracker.) 348 // (Might return empty list if no origin is tracked by the tracker.)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 void DidGetEvictionOrigin(const GetOriginCallback& callback, 390 void DidGetEvictionOrigin(const GetOriginCallback& callback,
406 const GURL& origin); 391 const GURL& origin);
407 392
408 // QuotaEvictionHandler. 393 // QuotaEvictionHandler.
409 void GetEvictionOrigin(StorageType type, 394 void GetEvictionOrigin(StorageType type,
410 const std::set<GURL>& extra_exceptions, 395 const std::set<GURL>& extra_exceptions,
411 int64_t global_quota, 396 int64_t global_quota,
412 const GetOriginCallback& callback) override; 397 const GetOriginCallback& callback) override;
413 void EvictOriginData(const GURL& origin, 398 void EvictOriginData(const GURL& origin,
414 StorageType type, 399 StorageType type,
415 const EvictOriginDataCallback& callback) override; 400 const StatusCallback& callback) override;
416 void GetUsageAndQuotaForEviction( 401 void GetEvictionRoundInfo(const EvictionRoundInfoCallback& callback) override;
417 const UsageAndQuotaCallback& callback) override;
418 void AsyncGetVolumeInfo(const VolumeInfoCallback& callback) override;
419
420 void DidGetVolumeInfo(
421 const VolumeInfoCallback& callback,
422 uint64_t* available_space, uint64_t* total_space, bool success);
423 402
424 void GetLRUOrigin(StorageType type, const GetOriginCallback& callback); 403 void GetLRUOrigin(StorageType type, const GetOriginCallback& callback);
425 404
426 void DidSetTemporaryGlobalOverrideQuota(const QuotaCallback& callback,
427 const int64_t* new_quota,
428 bool success);
429 void DidGetPersistentHostQuota(const std::string& host, 405 void DidGetPersistentHostQuota(const std::string& host,
430 const int64_t* quota, 406 const int64_t* quota,
431 bool success); 407 bool success);
432 void DidSetPersistentHostQuota(const std::string& host, 408 void DidSetPersistentHostQuota(const std::string& host,
433 const QuotaCallback& callback, 409 const QuotaCallback& callback,
434 const int64_t* new_quota, 410 const int64_t* new_quota,
435 bool success); 411 bool success);
436 void DidInitialize(int64_t* temporary_quota_override,
437 int64_t* desired_available_space,
438 bool success);
439 void DidGetLRUOrigin(const GURL* origin, 412 void DidGetLRUOrigin(const GURL* origin,
440 bool success); 413 bool success);
441 void DidGetInitialTemporaryGlobalQuota(base::TimeTicks start_ticks, 414 void GetQuotaSettings(const QuotaSettingsCallback& callback);
442 QuotaStatusCode status, 415 void DidGetSettings(base::TimeTicks start_ticks,
443 int64_t quota_unused); 416 base::Optional<QuotaSettings> settings);
444 void DidInitializeTemporaryOriginsInfo(bool success); 417 void GetStorageCapacity(const StorageCapacityCallback& callback);
445 void DidGetAvailableSpace(int64_t space); 418 void ContinueIncognitoGetStorageCapacity(const QuotaSettings& settings);
419 void DidGetStorageCapacity(
420 const std::pair<int64_t, int64_t>& total_and_available);
421
446 void DidDatabaseWork(bool success); 422 void DidDatabaseWork(bool success);
447 423
448 void DeleteOnCorrectThread() const; 424 void DeleteOnCorrectThread() const;
449 425
450 void PostTaskAndReplyWithResultForDBThread( 426 void PostTaskAndReplyWithResultForDBThread(
451 const tracked_objects::Location& from_here, 427 const tracked_objects::Location& from_here,
452 const base::Callback<bool(QuotaDatabase*)>& task, 428 const base::Callback<bool(QuotaDatabase*)>& task,
453 const base::Callback<void(bool)>& reply); 429 const base::Callback<void(bool)>& reply);
454 430
455 static int64_t CallGetAmountOfFreeDiskSpace( 431 static std::pair<int64_t, int64_t> CallGetVolumeInfo(
456 GetVolumeInfoFn get_vol_info_fn, 432 GetVolumeInfoFn get_volume_info_fn,
457 const base::FilePath& profile_path); 433 const base::FilePath& path);
458 static bool GetVolumeInfo(const base::FilePath& path, 434 static std::pair<int64_t, int64_t> GetVolumeInfo(const base::FilePath& path);
459 uint64_t* available_space,
460 uint64_t* total_size);
461 435
462 const bool is_incognito_; 436 const bool is_incognito_;
463 const base::FilePath profile_path_; 437 const base::FilePath profile_path_;
464 438
465 scoped_refptr<QuotaManagerProxy> proxy_; 439 scoped_refptr<QuotaManagerProxy> proxy_;
466 bool db_disabled_; 440 bool db_disabled_;
467 bool eviction_disabled_; 441 bool eviction_disabled_;
468 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; 442 scoped_refptr<base::SingleThreadTaskRunner> io_thread_;
469 scoped_refptr<base::SequencedTaskRunner> db_thread_; 443 scoped_refptr<base::SequencedTaskRunner> db_thread_;
470 mutable std::unique_ptr<QuotaDatabase> database_; 444 mutable std::unique_ptr<QuotaDatabase> database_;
445 bool is_database_bootstrapped_ = false;
446
447 GetQuotaSettingsFunc get_settings_function_;
448 scoped_refptr<base::TaskRunner> get_settings_task_runner_;
449 QuotaSettings settings_;
450 base::TimeTicks settings_timestamp_;
451 QuotaSettingsCallbackQueue settings_callbacks_;
452 StorageCapacityCallbackQueue storage_capacity_callbacks_;
471 453
472 GetOriginCallback lru_origin_callback_; 454 GetOriginCallback lru_origin_callback_;
473 std::set<GURL> access_notified_origins_; 455 std::set<GURL> access_notified_origins_;
474 456
475 QuotaClientList clients_; 457 QuotaClientList clients_;
476 458
477 std::unique_ptr<UsageTracker> temporary_usage_tracker_; 459 std::unique_ptr<UsageTracker> temporary_usage_tracker_;
478 std::unique_ptr<UsageTracker> persistent_usage_tracker_; 460 std::unique_ptr<UsageTracker> persistent_usage_tracker_;
479 std::unique_ptr<UsageTracker> syncable_usage_tracker_; 461 std::unique_ptr<UsageTracker> syncable_usage_tracker_;
480 // TODO(michaeln): Need a way to clear the cache, drop and 462 // TODO(michaeln): Need a way to clear the cache, drop and
481 // reinstantiate the trackers when they're not handling requests. 463 // reinstantiate the trackers when they're not handling requests.
482 464
483 std::unique_ptr<QuotaTemporaryStorageEvictor> temporary_storage_evictor_; 465 std::unique_ptr<QuotaTemporaryStorageEvictor> temporary_storage_evictor_;
484 EvictionContext eviction_context_; 466 EvictionContext eviction_context_;
485 std::unique_ptr<QuotaEvictionPolicy> temporary_storage_eviction_policy_; 467 std::unique_ptr<QuotaEvictionPolicy> temporary_storage_eviction_policy_;
486 bool is_getting_eviction_origin_; 468 bool is_getting_eviction_origin_;
487 469
488 ClosureQueue db_initialization_callbacks_;
489 AvailableSpaceCallbackQueue available_space_callbacks_;
490 HostQuotaCallbackMap persistent_host_quota_callbacks_; 470 HostQuotaCallbackMap persistent_host_quota_callbacks_;
491 471
492 bool temporary_quota_initialized_;
493 int64_t temporary_quota_override_;
494 int64_t desired_available_space_;
495
496 // Map from origin to count. 472 // Map from origin to count.
497 std::map<GURL, int> origins_in_use_; 473 std::map<GURL, int> origins_in_use_;
498 // Map from origin to error count. 474 // Map from origin to error count.
499 std::map<GURL, int> origins_in_error_; 475 std::map<GURL, int> origins_in_error_;
500 476
501 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; 477 scoped_refptr<SpecialStoragePolicy> special_storage_policy_;
502 478
503 base::RepeatingTimer histogram_timer_; 479 base::RepeatingTimer histogram_timer_;
504 480
505 // Pointer to the function used to get volume information. This is 481 // Pointer to the function used to get volume information. This is
(...skipping 10 matching lines...) Expand all
516 492
517 struct QuotaManagerDeleter { 493 struct QuotaManagerDeleter {
518 static void Destruct(const QuotaManager* manager) { 494 static void Destruct(const QuotaManager* manager) {
519 manager->DeleteOnCorrectThread(); 495 manager->DeleteOnCorrectThread();
520 } 496 }
521 }; 497 };
522 498
523 } // namespace storage 499 } // namespace storage
524 500
525 #endif // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ 501 #endif // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698