| 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/browser/quota/storage_observer.h" |
| 28 #include "webkit/browser/webkit_storage_browser_export.h" | 29 #include "webkit/browser/webkit_storage_browser_export.h" |
| 29 | 30 |
| 30 namespace base { | 31 namespace base { |
| 31 class FilePath; | 32 class FilePath; |
| 32 class SequencedTaskRunner; | 33 class SequencedTaskRunner; |
| 33 class SingleThreadTaskRunner; | 34 class SingleThreadTaskRunner; |
| 34 } | 35 } |
| 35 | 36 |
| 36 namespace quota_internals { | 37 namespace quota_internals { |
| 37 class QuotaInternalsProxy; | 38 class QuotaInternalsProxy; |
| 38 } | 39 } |
| 39 | 40 |
| 40 namespace quota { | 41 namespace quota { |
| 41 | 42 |
| 42 class MockQuotaManager; | 43 class MockQuotaManager; |
| 43 class QuotaDatabase; | 44 class QuotaDatabase; |
| 44 class QuotaManagerProxy; | 45 class QuotaManagerProxy; |
| 45 class QuotaTemporaryStorageEvictor; | 46 class QuotaTemporaryStorageEvictor; |
| 47 class StorageMonitor; |
| 46 class UsageTracker; | 48 class UsageTracker; |
| 47 | 49 |
| 48 struct QuotaManagerDeleter; | 50 struct QuotaManagerDeleter; |
| 49 | 51 |
| 50 struct WEBKIT_STORAGE_BROWSER_EXPORT UsageAndQuota { | 52 struct WEBKIT_STORAGE_BROWSER_EXPORT UsageAndQuota { |
| 51 int64 usage; | 53 int64 usage; |
| 52 int64 global_limited_usage; | 54 int64 global_limited_usage; |
| 53 int64 quota; | 55 int64 quota; |
| 54 int64 available_disk_space; | 56 int64 available_disk_space; |
| 55 | 57 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 return special_storage_policy_.get() && | 220 return special_storage_policy_.get() && |
| 219 special_storage_policy_->CanQueryDiskSize(origin); | 221 special_storage_policy_->CanQueryDiskSize(origin); |
| 220 } | 222 } |
| 221 | 223 |
| 222 virtual void GetOriginsModifiedSince(StorageType type, | 224 virtual void GetOriginsModifiedSince(StorageType type, |
| 223 base::Time modified_since, | 225 base::Time modified_since, |
| 224 const GetOriginsCallback& callback); | 226 const GetOriginsCallback& callback); |
| 225 | 227 |
| 226 bool ResetUsageTracker(StorageType type); | 228 bool ResetUsageTracker(StorageType type); |
| 227 | 229 |
| 230 // Used to register/deregister observers that wish to monitor storage events. |
| 231 void AddStorageObserver(StorageObserver* observer, |
| 232 const StorageObserver::MonitorParams& params); |
| 233 void RemoveStorageObserver(StorageObserver* observer); |
| 234 void RemoveStorageObserverForFilter(StorageObserver* observer, |
| 235 const StorageObserver::Filter& filter); |
| 236 |
| 228 // Determines the portion of the temp pool that can be | 237 // Determines the portion of the temp pool that can be |
| 229 // utilized by a single host (ie. 5 for 20%). | 238 // utilized by a single host (ie. 5 for 20%). |
| 230 static const int kPerHostTemporaryPortion; | 239 static const int kPerHostTemporaryPortion; |
| 231 | 240 |
| 232 static const int64 kPerHostPersistentQuotaLimit; | 241 static const int64 kPerHostPersistentQuotaLimit; |
| 233 | 242 |
| 234 static const char kDatabaseName[]; | 243 static const char kDatabaseName[]; |
| 235 | 244 |
| 236 static const int64 kMinimumPreserveForSystem; | 245 static const int64 kMinimumPreserveForSystem; |
| 237 | 246 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 250 private: | 259 private: |
| 251 friend class base::DeleteHelper<QuotaManager>; | 260 friend class base::DeleteHelper<QuotaManager>; |
| 252 friend class base::RefCountedThreadSafe<QuotaManager, QuotaManagerDeleter>; | 261 friend class base::RefCountedThreadSafe<QuotaManager, QuotaManagerDeleter>; |
| 253 friend class MockQuotaManager; | 262 friend class MockQuotaManager; |
| 254 friend class MockStorageClient; | 263 friend class MockStorageClient; |
| 255 friend class quota_internals::QuotaInternalsProxy; | 264 friend class quota_internals::QuotaInternalsProxy; |
| 256 friend class QuotaManagerProxy; | 265 friend class QuotaManagerProxy; |
| 257 friend class QuotaManagerTest; | 266 friend class QuotaManagerTest; |
| 258 friend class QuotaTemporaryStorageEvictor; | 267 friend class QuotaTemporaryStorageEvictor; |
| 259 friend struct QuotaManagerDeleter; | 268 friend struct QuotaManagerDeleter; |
| 269 friend class StorageMonitorTest; |
| 260 | 270 |
| 261 class GetUsageInfoTask; | 271 class GetUsageInfoTask; |
| 262 | 272 |
| 263 class OriginDataDeleter; | 273 class OriginDataDeleter; |
| 264 class HostDataDeleter; | 274 class HostDataDeleter; |
| 265 | 275 |
| 266 class GetModifiedSinceHelper; | 276 class GetModifiedSinceHelper; |
| 267 class DumpQuotaTableHelper; | 277 class DumpQuotaTableHelper; |
| 268 class DumpOriginInfoTableHelper; | 278 class DumpOriginInfoTableHelper; |
| 269 | 279 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 | 428 |
| 419 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; | 429 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; |
| 420 | 430 |
| 421 base::RepeatingTimer<QuotaManager> histogram_timer_; | 431 base::RepeatingTimer<QuotaManager> histogram_timer_; |
| 422 | 432 |
| 423 // Pointer to the function used to get the available disk space. This is | 433 // Pointer to the function used to get the available disk space. This is |
| 424 // overwritten by QuotaManagerTest in order to attain a deterministic reported | 434 // overwritten by QuotaManagerTest in order to attain a deterministic reported |
| 425 // value. The default value points to base::SysInfo::AmountOfFreeDiskSpace. | 435 // value. The default value points to base::SysInfo::AmountOfFreeDiskSpace. |
| 426 GetAvailableDiskSpaceFn get_disk_space_fn_; | 436 GetAvailableDiskSpaceFn get_disk_space_fn_; |
| 427 | 437 |
| 438 scoped_ptr<StorageMonitor> storage_monitor_; |
| 439 |
| 428 base::WeakPtrFactory<QuotaManager> weak_factory_; | 440 base::WeakPtrFactory<QuotaManager> weak_factory_; |
| 429 | 441 |
| 430 DISALLOW_COPY_AND_ASSIGN(QuotaManager); | 442 DISALLOW_COPY_AND_ASSIGN(QuotaManager); |
| 431 }; | 443 }; |
| 432 | 444 |
| 433 struct QuotaManagerDeleter { | 445 struct QuotaManagerDeleter { |
| 434 static void Destruct(const QuotaManager* manager) { | 446 static void Destruct(const QuotaManager* manager) { |
| 435 manager->DeleteOnCorrectThread(); | 447 manager->DeleteOnCorrectThread(); |
| 436 } | 448 } |
| 437 }; | 449 }; |
| 438 | 450 |
| 439 } // namespace quota | 451 } // namespace quota |
| 440 | 452 |
| 441 #endif // WEBKIT_BROWSER_QUOTA_QUOTA_MANAGER_H_ | 453 #endif // WEBKIT_BROWSER_QUOTA_QUOTA_MANAGER_H_ |
| OLD | NEW |