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 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <list> | 10 #include <list> |
11 #include <map> | 11 #include <map> |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
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/file_path.h" | 18 #include "base/file_path.h" |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
20 #include "base/memory/scoped_callback_factory.h" | 20 #include "base/memory/scoped_callback_factory.h" |
21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
22 #include "webkit/quota/quota_database.h" | 22 #include "webkit/quota/quota_database.h" |
23 #include "webkit/quota/quota_client.h" | 23 #include "webkit/quota/quota_client.h" |
24 #include "webkit/quota/quota_task.h" | 24 #include "webkit/quota/quota_task.h" |
25 #include "webkit/quota/quota_types.h" | 25 #include "webkit/quota/quota_types.h" |
26 #include "webkit/quota/special_storage_policy.h" | 26 #include "webkit/quota/special_storage_policy.h" |
27 | 27 |
| 28 class FilePath; |
| 29 |
28 namespace base { | 30 namespace base { |
29 class MessageLoopProxy; | 31 class MessageLoopProxy; |
30 } | 32 } |
31 class FilePath; | |
32 | 33 |
33 namespace quota_internals { | 34 namespace quota_internals { |
34 class QuotaInternalsProxy; | 35 class QuotaInternalsProxy; |
35 } | 36 } |
36 | 37 |
37 namespace quota { | 38 namespace quota { |
38 | 39 |
39 struct QuotaManagerDeleter; | 40 struct QuotaManagerDeleter; |
40 | 41 |
41 class QuotaDatabase; | 42 class QuotaDatabase; |
42 class QuotaManagerProxy; | 43 class QuotaManagerProxy; |
43 class QuotaTemporaryStorageEvictor; | 44 class QuotaTemporaryStorageEvictor; |
44 class UsageTracker; | 45 class UsageTracker; |
| 46 class MockQuotaManager; |
45 | 47 |
46 // An interface called by QuotaTemporaryStorageEvictor. | 48 // An interface called by QuotaTemporaryStorageEvictor. |
47 class QuotaEvictionHandler { | 49 class QuotaEvictionHandler { |
48 public: | 50 public: |
49 virtual ~QuotaEvictionHandler() {} | 51 virtual ~QuotaEvictionHandler() {} |
50 | 52 |
51 typedef Callback1<const GURL&>::Type GetLRUOriginCallback; | 53 typedef Callback1<const GURL&>::Type GetLRUOriginCallback; |
52 typedef StatusCallback EvictOriginDataCallback; | 54 typedef StatusCallback EvictOriginDataCallback; |
53 typedef Callback5<QuotaStatusCode, | 55 typedef Callback5<QuotaStatusCode, |
54 int64 /* usage */, | 56 int64 /* usage */, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // Used to avoid evicting origins with open pages. | 121 // Used to avoid evicting origins with open pages. |
120 // A call to NotifyOriginInUse must be balanced by a later call | 122 // A call to NotifyOriginInUse must be balanced by a later call |
121 // to NotifyOriginNoLongerInUse. | 123 // to NotifyOriginNoLongerInUse. |
122 void NotifyOriginInUse(const GURL& origin); | 124 void NotifyOriginInUse(const GURL& origin); |
123 void NotifyOriginNoLongerInUse(const GURL& origin); | 125 void NotifyOriginNoLongerInUse(const GURL& origin); |
124 bool IsOriginInUse(const GURL& origin) const { | 126 bool IsOriginInUse(const GURL& origin) const { |
125 return origins_in_use_.find(origin) != origins_in_use_.end(); | 127 return origins_in_use_.find(origin) != origins_in_use_.end(); |
126 } | 128 } |
127 | 129 |
128 // Called by UI. | 130 // Called by UI. |
129 void DeleteOriginData(const GURL& origin, | 131 virtual void DeleteOriginData(const GURL& origin, |
130 StorageType type, | 132 StorageType type, |
131 StatusCallback* callback); | 133 StatusCallback* callback); |
132 | 134 |
133 // Called by UI and internal modules. | 135 // Called by UI and internal modules. |
134 void GetAvailableSpace(AvailableSpaceCallback* callback); | 136 void GetAvailableSpace(AvailableSpaceCallback* callback); |
135 void GetTemporaryGlobalQuota(QuotaCallback* callback); | 137 void GetTemporaryGlobalQuota(QuotaCallback* callback); |
136 void SetTemporaryGlobalQuota(int64 new_quota, QuotaCallback* callback); | 138 void SetTemporaryGlobalQuota(int64 new_quota, QuotaCallback* callback); |
137 void GetPersistentHostQuota(const std::string& host, | 139 void GetPersistentHostQuota(const std::string& host, |
138 HostQuotaCallback* callback); | 140 HostQuotaCallback* callback); |
139 void SetPersistentHostQuota(const std::string& host, | 141 void SetPersistentHostQuota(const std::string& host, |
140 int64 new_quota, | 142 int64 new_quota, |
141 HostQuotaCallback* callback); | 143 HostQuotaCallback* callback); |
142 void GetGlobalUsage(StorageType type, GlobalUsageCallback* callback); | 144 void GetGlobalUsage(StorageType type, GlobalUsageCallback* callback); |
143 void GetHostUsage(const std::string& host, StorageType type, | 145 void GetHostUsage(const std::string& host, StorageType type, |
144 HostUsageCallback* callback); | 146 HostUsageCallback* callback); |
145 | 147 |
146 void GetStatistics(std::map<std::string, std::string>* statistics); | 148 void GetStatistics(std::map<std::string, std::string>* statistics); |
147 | 149 |
148 bool IsStorageUnlimited(const GURL& origin) const { | 150 bool IsStorageUnlimited(const GURL& origin) const { |
149 return special_storage_policy_.get() && | 151 return special_storage_policy_.get() && |
150 special_storage_policy_->IsStorageUnlimited(origin); | 152 special_storage_policy_->IsStorageUnlimited(origin); |
151 } | 153 } |
152 | 154 |
153 void GetOriginsModifiedSince( | 155 virtual void GetOriginsModifiedSince(StorageType type, |
154 StorageType type, | 156 base::Time modified_since, |
155 base::Time modified_since, | 157 GetOriginsCallback* callback); |
156 GetOriginsCallback* callback); | |
157 | 158 |
158 // Used to determine the total size of the temp pool. | 159 // Used to determine the total size of the temp pool. |
159 static const int64 kTemporaryStorageQuotaDefaultSize; | 160 static const int64 kTemporaryStorageQuotaDefaultSize; |
160 static const int64 kTemporaryStorageQuotaMaxSize; | 161 static const int64 kTemporaryStorageQuotaMaxSize; |
161 static const int64 kIncognitoDefaultTemporaryQuota; | 162 static const int64 kIncognitoDefaultTemporaryQuota; |
162 | 163 |
163 // Determines the portion of the temp pool that can be | 164 // Determines the portion of the temp pool that can be |
164 // utilized by a single host (ie. 5 for 20%). | 165 // utilized by a single host (ie. 5 for 20%). |
165 static const int kPerHostTemporaryPortion; | 166 static const int kPerHostTemporaryPortion; |
166 | 167 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 typedef std::pair<std::string, StorageType> HostAndType; | 227 typedef std::pair<std::string, StorageType> HostAndType; |
227 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> | 228 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> |
228 UsageAndQuotaDispatcherTaskMap; | 229 UsageAndQuotaDispatcherTaskMap; |
229 | 230 |
230 friend class quota_internals::QuotaInternalsProxy; | 231 friend class quota_internals::QuotaInternalsProxy; |
231 friend struct QuotaManagerDeleter; | 232 friend struct QuotaManagerDeleter; |
232 friend class MockStorageClient; | 233 friend class MockStorageClient; |
233 friend class QuotaManagerProxy; | 234 friend class QuotaManagerProxy; |
234 friend class QuotaManagerTest; | 235 friend class QuotaManagerTest; |
235 friend class QuotaTemporaryStorageEvictor; | 236 friend class QuotaTemporaryStorageEvictor; |
| 237 friend class MockQuotaManager; |
236 | 238 |
237 // This initialization method is lazily called on the IO thread | 239 // This initialization method is lazily called on the IO thread |
238 // when the first quota manager API is called. | 240 // when the first quota manager API is called. |
239 // Initialize must be called after all quota clients are added to the | 241 // Initialize must be called after all quota clients are added to the |
240 // manager by RegisterStorage. | 242 // manager by RegisterStorage. |
241 void LazyInitialize(); | 243 void LazyInitialize(); |
242 | 244 |
243 // Called by clients via proxy. | 245 // Called by clients via proxy. |
244 // Registers a quota client to the manager. | 246 // Registers a quota client to the manager. |
245 // The client must remain valid until OnQuotaManagerDestored is called. | 247 // The client must remain valid until OnQuotaManagerDestored is called. |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 387 |
386 QuotaManager* manager_; // only accessed on the io thread | 388 QuotaManager* manager_; // only accessed on the io thread |
387 scoped_refptr<base::MessageLoopProxy> io_thread_; | 389 scoped_refptr<base::MessageLoopProxy> io_thread_; |
388 | 390 |
389 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); | 391 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); |
390 }; | 392 }; |
391 | 393 |
392 } // namespace quota | 394 } // namespace quota |
393 | 395 |
394 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 396 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
OLD | NEW |