| 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 #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 <utility> | 14 #include <utility> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
| 18 #include "base/callback.h" | 18 #include "base/callback.h" |
| 19 #include "base/file_path.h" | 19 #include "base/file_path.h" |
| 20 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
| 21 #include "base/memory/weak_ptr.h" | |
| 22 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
| 23 #include "base/memory/weak_ptr.h" | 22 #include "base/memory/weak_ptr.h" |
| 23 #include "base/memory/weak_ptr.h" |
| 24 #include "base/sequenced_task_runner_helpers.h" | 24 #include "base/sequenced_task_runner_helpers.h" |
| 25 #include "webkit/quota/quota_client.h" |
| 25 #include "webkit/quota/quota_database.h" | 26 #include "webkit/quota/quota_database.h" |
| 26 #include "webkit/quota/quota_client.h" | |
| 27 #include "webkit/quota/quota_task.h" | 27 #include "webkit/quota/quota_task.h" |
| 28 #include "webkit/quota/quota_types.h" | 28 #include "webkit/quota/quota_types.h" |
| 29 #include "webkit/quota/special_storage_policy.h" | 29 #include "webkit/quota/special_storage_policy.h" |
| 30 | 30 |
| 31 class FilePath; | 31 class FilePath; |
| 32 | 32 |
| 33 namespace base { | 33 namespace base { |
| 34 class MessageLoopProxy; | 34 class SequencedTaskRunner; |
| 35 class SingleThreadTaskRunner; |
| 35 } | 36 } |
| 36 | 37 |
| 37 namespace quota_internals { | 38 namespace quota_internals { |
| 38 class QuotaInternalsProxy; | 39 class QuotaInternalsProxy; |
| 39 } | 40 } |
| 40 | 41 |
| 41 namespace quota { | 42 namespace quota { |
| 42 | 43 |
| 43 struct QuotaManagerDeleter; | 44 struct QuotaManagerDeleter; |
| 44 | 45 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 public base::RefCountedThreadSafe< | 100 public base::RefCountedThreadSafe< |
| 100 QuotaManager, QuotaManagerDeleter> { | 101 QuotaManager, QuotaManagerDeleter> { |
| 101 public: | 102 public: |
| 102 typedef base::Callback<void(QuotaStatusCode, | 103 typedef base::Callback<void(QuotaStatusCode, |
| 103 int64 /* usage */, | 104 int64 /* usage */, |
| 104 int64 /* quota */)> | 105 int64 /* quota */)> |
| 105 GetUsageAndQuotaCallback; | 106 GetUsageAndQuotaCallback; |
| 106 | 107 |
| 107 QuotaManager(bool is_incognito, | 108 QuotaManager(bool is_incognito, |
| 108 const FilePath& profile_path, | 109 const FilePath& profile_path, |
| 109 base::MessageLoopProxy* io_thread, | 110 base::SingleThreadTaskRunner* io_thread, |
| 110 base::MessageLoopProxy* db_thread, | 111 base::SequencedTaskRunner* db_thread, |
| 111 SpecialStoragePolicy* special_storage_policy); | 112 SpecialStoragePolicy* special_storage_policy); |
| 112 | 113 |
| 113 // Returns a proxy object that can be used on any thread. | 114 // Returns a proxy object that can be used on any thread. |
| 114 QuotaManagerProxy* proxy() { return proxy_.get(); } | 115 QuotaManagerProxy* proxy() { return proxy_.get(); } |
| 115 | 116 |
| 116 // Called by clients or webapps. Returns usage per host. | 117 // Called by clients or webapps. Returns usage per host. |
| 117 void GetUsageInfo(const GetUsageInfoCallback& callback); | 118 void GetUsageInfo(const GetUsageInfoCallback& callback); |
| 118 | 119 |
| 119 // Called by clients or webapps. | 120 // Called by clients or webapps. |
| 120 // This method is declared as virtual to allow test code to override it. | 121 // This method is declared as virtual to allow test code to override it. |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 void DidGetDatabaseLRUOrigin(const GURL& origin); | 346 void DidGetDatabaseLRUOrigin(const GURL& origin); |
| 346 | 347 |
| 347 void DeleteOnCorrectThread() const; | 348 void DeleteOnCorrectThread() const; |
| 348 | 349 |
| 349 const bool is_incognito_; | 350 const bool is_incognito_; |
| 350 const FilePath profile_path_; | 351 const FilePath profile_path_; |
| 351 | 352 |
| 352 scoped_refptr<QuotaManagerProxy> proxy_; | 353 scoped_refptr<QuotaManagerProxy> proxy_; |
| 353 bool db_disabled_; | 354 bool db_disabled_; |
| 354 bool eviction_disabled_; | 355 bool eviction_disabled_; |
| 355 scoped_refptr<base::MessageLoopProxy> io_thread_; | 356 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; |
| 356 scoped_refptr<base::MessageLoopProxy> db_thread_; | 357 scoped_refptr<base::SequencedTaskRunner> db_thread_; |
| 357 mutable scoped_ptr<QuotaDatabase> database_; | 358 mutable scoped_ptr<QuotaDatabase> database_; |
| 358 | 359 |
| 359 GetLRUOriginCallback lru_origin_callback_; | 360 GetLRUOriginCallback lru_origin_callback_; |
| 360 std::set<GURL> access_notified_origins_; | 361 std::set<GURL> access_notified_origins_; |
| 361 | 362 |
| 362 QuotaClientList clients_; | 363 QuotaClientList clients_; |
| 363 | 364 |
| 364 scoped_ptr<UsageTracker> temporary_usage_tracker_; | 365 scoped_ptr<UsageTracker> temporary_usage_tracker_; |
| 365 scoped_ptr<UsageTracker> persistent_usage_tracker_; | 366 scoped_ptr<UsageTracker> persistent_usage_tracker_; |
| 366 // TODO(michaeln): Need a way to clear the cache, drop and | 367 // TODO(michaeln): Need a way to clear the cache, drop and |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 virtual void NotifyOriginNoLongerInUse(const GURL& origin); | 412 virtual void NotifyOriginNoLongerInUse(const GURL& origin); |
| 412 | 413 |
| 413 // This method may only be called on the IO thread. | 414 // This method may only be called on the IO thread. |
| 414 // It may return NULL if the manager has already been deleted. | 415 // It may return NULL if the manager has already been deleted. |
| 415 QuotaManager* quota_manager() const; | 416 QuotaManager* quota_manager() const; |
| 416 | 417 |
| 417 protected: | 418 protected: |
| 418 friend class QuotaManager; | 419 friend class QuotaManager; |
| 419 friend class base::RefCountedThreadSafe<QuotaManagerProxy>; | 420 friend class base::RefCountedThreadSafe<QuotaManagerProxy>; |
| 420 | 421 |
| 421 QuotaManagerProxy(QuotaManager* manager, base::MessageLoopProxy* io_thread); | 422 QuotaManagerProxy(QuotaManager* manager, |
| 423 base::SingleThreadTaskRunner* io_thread); |
| 422 virtual ~QuotaManagerProxy(); | 424 virtual ~QuotaManagerProxy(); |
| 423 | 425 |
| 424 QuotaManager* manager_; // only accessed on the io thread | 426 QuotaManager* manager_; // only accessed on the io thread |
| 425 scoped_refptr<base::MessageLoopProxy> io_thread_; | 427 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; |
| 426 | 428 |
| 427 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); | 429 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); |
| 428 }; | 430 }; |
| 429 | 431 |
| 430 } // namespace quota | 432 } // namespace quota |
| 431 | 433 |
| 432 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 434 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
| OLD | NEW |