OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 5 #ifndef WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
6 #define WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 6 #define WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 21 matching lines...) Expand all Loading... | |
32 class SequencedTaskRunner; | 32 class SequencedTaskRunner; |
33 class SingleThreadTaskRunner; | 33 class SingleThreadTaskRunner; |
34 } | 34 } |
35 | 35 |
36 namespace quota_internals { | 36 namespace quota_internals { |
37 class QuotaInternalsProxy; | 37 class QuotaInternalsProxy; |
38 } | 38 } |
39 | 39 |
40 namespace quota { | 40 namespace quota { |
41 | 41 |
42 struct QuotaManagerDeleter; | 42 class MockQuotaManager; |
43 | |
44 class QuotaDatabase; | 43 class QuotaDatabase; |
45 class QuotaManagerProxy; | 44 class QuotaManagerProxy; |
46 class QuotaTemporaryStorageEvictor; | 45 class QuotaTemporaryStorageEvictor; |
47 class UsageTracker; | 46 class UsageTracker; |
48 class MockQuotaManager; | 47 |
48 struct QuotaManagerDeleter; | |
49 | 49 |
50 struct QuotaAndUsage { | 50 struct QuotaAndUsage { |
51 int64 usage; | 51 int64 usage; |
52 int64 unlimited_usage; | 52 int64 unlimited_usage; |
53 int64 quota; | 53 int64 quota; |
54 int64 available_disk_space; | 54 int64 available_disk_space; |
55 }; | 55 }; |
56 | 56 |
57 // An interface called by QuotaTemporaryStorageEvictor. | 57 // An interface called by QuotaTemporaryStorageEvictor. |
58 class QuotaEvictionHandler { | 58 class QuotaEvictionHandler { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 void GetHostUsage(const std::string& host, StorageType type, | 181 void GetHostUsage(const std::string& host, StorageType type, |
182 const HostUsageCallback& callback); | 182 const HostUsageCallback& callback); |
183 | 183 |
184 void GetStatistics(std::map<std::string, std::string>* statistics); | 184 void GetStatistics(std::map<std::string, std::string>* statistics); |
185 | 185 |
186 bool IsStorageUnlimited(const GURL& origin) const { | 186 bool IsStorageUnlimited(const GURL& origin) const { |
187 return special_storage_policy_.get() && | 187 return special_storage_policy_.get() && |
188 special_storage_policy_->IsStorageUnlimited(origin); | 188 special_storage_policy_->IsStorageUnlimited(origin); |
189 } | 189 } |
190 | 190 |
191 bool IsInstalledApp(const GURL& origin) const { | |
192 return special_storage_policy_.get() && | |
193 special_storage_policy_->IsInstalledApp(origin); | |
194 } | |
195 | |
191 virtual void GetOriginsModifiedSince(StorageType type, | 196 virtual void GetOriginsModifiedSince(StorageType type, |
192 base::Time modified_since, | 197 base::Time modified_since, |
193 const GetOriginsCallback& callback); | 198 const GetOriginsCallback& callback); |
194 | 199 |
195 bool ResetUsageTracker(StorageType type); | 200 bool ResetUsageTracker(StorageType type); |
196 | 201 |
197 // Determines the portion of the temp pool that can be | 202 // Determines the portion of the temp pool that can be |
198 // utilized by a single host (ie. 5 for 20%). | 203 // utilized by a single host (ie. 5 for 20%). |
199 static const int kPerHostTemporaryPortion; | 204 static const int kPerHostTemporaryPortion; |
200 | 205 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 | 245 |
241 class AvailableSpaceQueryTask; | 246 class AvailableSpaceQueryTask; |
242 class DumpQuotaTableTask; | 247 class DumpQuotaTableTask; |
243 class DumpOriginInfoTableTask; | 248 class DumpOriginInfoTableTask; |
244 | 249 |
245 typedef QuotaDatabase::QuotaTableEntry QuotaTableEntry; | 250 typedef QuotaDatabase::QuotaTableEntry QuotaTableEntry; |
246 typedef QuotaDatabase::OriginInfoTableEntry OriginInfoTableEntry; | 251 typedef QuotaDatabase::OriginInfoTableEntry OriginInfoTableEntry; |
247 typedef std::vector<QuotaTableEntry> QuotaTableEntries; | 252 typedef std::vector<QuotaTableEntry> QuotaTableEntries; |
248 typedef std::vector<OriginInfoTableEntry> OriginInfoTableEntries; | 253 typedef std::vector<OriginInfoTableEntry> OriginInfoTableEntries; |
249 | 254 |
255 // Function pointer type used to store the function which returns the | |
256 // available disk space for the disk containing the given FilePath. | |
257 typedef int64 (*GetAvailableDiskSpaceFn)(const FilePath&); | |
258 | |
250 typedef base::Callback<void(const QuotaTableEntries&)> | 259 typedef base::Callback<void(const QuotaTableEntries&)> |
251 DumpQuotaTableCallback; | 260 DumpQuotaTableCallback; |
252 typedef base::Callback<void(const OriginInfoTableEntries&)> | 261 typedef base::Callback<void(const OriginInfoTableEntries&)> |
253 DumpOriginInfoTableCallback; | 262 DumpOriginInfoTableCallback; |
254 | 263 |
255 struct EvictionContext { | 264 struct EvictionContext { |
256 EvictionContext(); | 265 EvictionContext(); |
257 virtual ~EvictionContext(); | 266 virtual ~EvictionContext(); |
258 GURL evicted_origin; | 267 GURL evicted_origin; |
259 StorageType evicted_type; | 268 StorageType evicted_type; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 // Map from origin to count. | 389 // Map from origin to count. |
381 std::map<GURL, int> origins_in_use_; | 390 std::map<GURL, int> origins_in_use_; |
382 // Map from origin to error count. | 391 // Map from origin to error count. |
383 std::map<GURL, int> origins_in_error_; | 392 std::map<GURL, int> origins_in_error_; |
384 | 393 |
385 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; | 394 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; |
386 | 395 |
387 base::WeakPtrFactory<QuotaManager> weak_factory_; | 396 base::WeakPtrFactory<QuotaManager> weak_factory_; |
388 base::RepeatingTimer<QuotaManager> histogram_timer_; | 397 base::RepeatingTimer<QuotaManager> histogram_timer_; |
389 | 398 |
399 // Pointer to the function used to get the available disk space. This is | |
400 // overwritten by QuotaManagerTest in order to attain a deterministic reported | |
401 // value. | |
kinuko
2012/08/20 04:04:44
nit: can you also add a comment about what is call
James Hawkins
2012/08/22 18:51:36
Done.
| |
402 GetAvailableDiskSpaceFn get_disk_space_fn_; | |
403 | |
390 DISALLOW_COPY_AND_ASSIGN(QuotaManager); | 404 DISALLOW_COPY_AND_ASSIGN(QuotaManager); |
391 }; | 405 }; |
392 | 406 |
393 struct QuotaManagerDeleter { | 407 struct QuotaManagerDeleter { |
394 static void Destruct(const QuotaManager* manager) { | 408 static void Destruct(const QuotaManager* manager) { |
395 manager->DeleteOnCorrectThread(); | 409 manager->DeleteOnCorrectThread(); |
396 } | 410 } |
397 }; | 411 }; |
398 | 412 |
399 // The proxy may be called and finally released on any thread. | 413 // The proxy may be called and finally released on any thread. |
(...skipping 25 matching lines...) Expand all Loading... | |
425 | 439 |
426 QuotaManager* manager_; // only accessed on the io thread | 440 QuotaManager* manager_; // only accessed on the io thread |
427 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; | 441 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; |
428 | 442 |
429 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); | 443 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); |
430 }; | 444 }; |
431 | 445 |
432 } // namespace quota | 446 } // namespace quota |
433 | 447 |
434 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 448 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
OLD | NEW |