OLD | NEW |
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 WEBKIT_BROWSER_QUOTA_QUOTA_MANAGER_H_ | 5 #ifndef WEBKIT_BROWSER_QUOTA_QUOTA_MANAGER_H_ |
6 #define WEBKIT_BROWSER_QUOTA_QUOTA_MANAGER_H_ | 6 #define WEBKIT_BROWSER_QUOTA_QUOTA_MANAGER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
17 #include "base/callback.h" | 17 #include "base/callback.h" |
18 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
22 #include "base/sequenced_task_runner_helpers.h" | 22 #include "base/sequenced_task_runner_helpers.h" |
23 #include "webkit/browser/quota/quota_callbacks.h" | 23 #include "webkit/browser/quota/quota_callbacks.h" |
24 #include "webkit/browser/quota/quota_client.h" | 24 #include "webkit/browser/quota/quota_client.h" |
25 #include "webkit/browser/quota/quota_database.h" | 25 #include "webkit/browser/quota/quota_database.h" |
26 #include "webkit/browser/quota/quota_task.h" | 26 #include "webkit/browser/quota/quota_task.h" |
27 #include "webkit/browser/quota/special_storage_policy.h" | 27 #include "webkit/browser/quota/special_storage_policy.h" |
28 #include "webkit/storage/webkit_storage_export.h" | 28 #include "webkit/browser/webkit_storage_browser_export.h" |
29 | 29 |
30 namespace base { | 30 namespace base { |
31 class FilePath; | 31 class FilePath; |
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 class MockQuotaManager; | 42 class MockQuotaManager; |
43 class QuotaDatabase; | 43 class QuotaDatabase; |
44 class QuotaManagerProxy; | 44 class QuotaManagerProxy; |
45 class QuotaTemporaryStorageEvictor; | 45 class QuotaTemporaryStorageEvictor; |
46 class UsageTracker; | 46 class UsageTracker; |
47 | 47 |
48 struct QuotaManagerDeleter; | 48 struct QuotaManagerDeleter; |
49 | 49 |
50 struct WEBKIT_STORAGE_EXPORT UsageAndQuota { | 50 struct WEBKIT_STORAGE_BROWSER_EXPORT UsageAndQuota { |
51 int64 usage; | 51 int64 usage; |
52 int64 global_limited_usage; | 52 int64 global_limited_usage; |
53 int64 quota; | 53 int64 quota; |
54 int64 available_disk_space; | 54 int64 available_disk_space; |
55 | 55 |
56 UsageAndQuota(); | 56 UsageAndQuota(); |
57 UsageAndQuota(int64 usage, | 57 UsageAndQuota(int64 usage, |
58 int64 global_limited_usage, | 58 int64 global_limited_usage, |
59 int64 quota, | 59 int64 quota, |
60 int64 available_disk_space); | 60 int64 available_disk_space); |
61 }; | 61 }; |
62 | 62 |
63 // An interface called by QuotaTemporaryStorageEvictor. | 63 // An interface called by QuotaTemporaryStorageEvictor. |
64 class WEBKIT_STORAGE_EXPORT QuotaEvictionHandler { | 64 class WEBKIT_STORAGE_BROWSER_EXPORT QuotaEvictionHandler { |
65 public: | 65 public: |
66 typedef base::Callback<void(const GURL&)> GetLRUOriginCallback; | 66 typedef base::Callback<void(const GURL&)> GetLRUOriginCallback; |
67 typedef StatusCallback EvictOriginDataCallback; | 67 typedef StatusCallback EvictOriginDataCallback; |
68 typedef base::Callback<void(QuotaStatusCode status, | 68 typedef base::Callback<void(QuotaStatusCode status, |
69 const UsageAndQuota& usage_and_quota)> | 69 const UsageAndQuota& usage_and_quota)> |
70 UsageAndQuotaCallback; | 70 UsageAndQuotaCallback; |
71 | 71 |
72 // Returns the least recently used origin. It might return empty | 72 // Returns the least recently used origin. It might return empty |
73 // GURL when there are no evictable origins. | 73 // GURL when there are no evictable origins. |
74 virtual void GetLRUOrigin( | 74 virtual void GetLRUOrigin( |
(...skipping 18 matching lines...) Expand all Loading... |
93 type(type), | 93 type(type), |
94 usage(usage) {} | 94 usage(usage) {} |
95 std::string host; | 95 std::string host; |
96 StorageType type; | 96 StorageType type; |
97 int64 usage; | 97 int64 usage; |
98 }; | 98 }; |
99 | 99 |
100 // The quota manager class. This class is instantiated per profile and | 100 // The quota manager class. This class is instantiated per profile and |
101 // held by the profile. With the exception of the constructor and the | 101 // held by the profile. With the exception of the constructor and the |
102 // proxy() method, all methods should only be called on the IO thread. | 102 // proxy() method, all methods should only be called on the IO thread. |
103 class WEBKIT_STORAGE_EXPORT QuotaManager | 103 class WEBKIT_STORAGE_BROWSER_EXPORT QuotaManager |
104 : public QuotaTaskObserver, | 104 : public QuotaTaskObserver, |
105 public QuotaEvictionHandler, | 105 public QuotaEvictionHandler, |
106 public base::RefCountedThreadSafe<QuotaManager, QuotaManagerDeleter> { | 106 public base::RefCountedThreadSafe<QuotaManager, QuotaManagerDeleter> { |
107 public: | 107 public: |
108 typedef base::Callback<void(QuotaStatusCode, | 108 typedef base::Callback<void(QuotaStatusCode, |
109 int64 /* usage */, | 109 int64 /* usage */, |
110 int64 /* quota */)> | 110 int64 /* quota */)> |
111 GetUsageAndQuotaCallback; | 111 GetUsageAndQuotaCallback; |
112 | 112 |
113 static const int64 kIncognitoDefaultQuotaLimit; | 113 static const int64 kIncognitoDefaultQuotaLimit; |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 DISALLOW_COPY_AND_ASSIGN(QuotaManager); | 422 DISALLOW_COPY_AND_ASSIGN(QuotaManager); |
423 }; | 423 }; |
424 | 424 |
425 struct QuotaManagerDeleter { | 425 struct QuotaManagerDeleter { |
426 static void Destruct(const QuotaManager* manager) { | 426 static void Destruct(const QuotaManager* manager) { |
427 manager->DeleteOnCorrectThread(); | 427 manager->DeleteOnCorrectThread(); |
428 } | 428 } |
429 }; | 429 }; |
430 | 430 |
431 // The proxy may be called and finally released on any thread. | 431 // The proxy may be called and finally released on any thread. |
432 class WEBKIT_STORAGE_EXPORT QuotaManagerProxy | 432 class WEBKIT_STORAGE_BROWSER_EXPORT QuotaManagerProxy |
433 : public base::RefCountedThreadSafe<QuotaManagerProxy> { | 433 : public base::RefCountedThreadSafe<QuotaManagerProxy> { |
434 public: | 434 public: |
435 virtual void RegisterClient(QuotaClient* client); | 435 virtual void RegisterClient(QuotaClient* client); |
436 virtual void NotifyStorageAccessed(QuotaClient::ID client_id, | 436 virtual void NotifyStorageAccessed(QuotaClient::ID client_id, |
437 const GURL& origin, | 437 const GURL& origin, |
438 StorageType type); | 438 StorageType type); |
439 virtual void NotifyStorageModified(QuotaClient::ID client_id, | 439 virtual void NotifyStorageModified(QuotaClient::ID client_id, |
440 const GURL& origin, | 440 const GURL& origin, |
441 StorageType type, | 441 StorageType type, |
442 int64 delta); | 442 int64 delta); |
(...skipping 19 matching lines...) Expand all Loading... |
462 | 462 |
463 QuotaManager* manager_; // only accessed on the io thread | 463 QuotaManager* manager_; // only accessed on the io thread |
464 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; | 464 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; |
465 | 465 |
466 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); | 466 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); |
467 }; | 467 }; |
468 | 468 |
469 } // namespace quota | 469 } // namespace quota |
470 | 470 |
471 #endif // WEBKIT_BROWSER_QUOTA_QUOTA_MANAGER_H_ | 471 #endif // WEBKIT_BROWSER_QUOTA_QUOTA_MANAGER_H_ |
OLD | NEW |