| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_H_ | 6 #define CONTENT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 #include "webkit/browser/quota/quota_client.h" | 15 #include "webkit/browser/quota/quota_client.h" |
| 16 #include "webkit/browser/quota/quota_manager.h" | 16 #include "webkit/browser/quota/quota_manager.h" |
| 17 #include "webkit/browser/quota/quota_task.h" | 17 #include "webkit/browser/quota/quota_task.h" |
| 18 #include "webkit/common/quota/quota_types.h" | 18 #include "webkit/common/quota/quota_types.h" |
| 19 | 19 |
| 20 using quota::GetOriginsCallback; | 20 using storage::GetOriginsCallback; |
| 21 using quota::QuotaClient; | 21 using storage::QuotaClient; |
| 22 using quota::QuotaManager; | 22 using storage::QuotaManager; |
| 23 using quota::QuotaStatusCode; | 23 using storage::QuotaStatusCode; |
| 24 using quota::SpecialStoragePolicy; | 24 using storage::SpecialStoragePolicy; |
| 25 using quota::StatusCallback; | 25 using storage::StatusCallback; |
| 26 using quota::StorageType; | 26 using storage::StorageType; |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 | 29 |
| 30 // Mocks the pieces of QuotaManager's interface. | 30 // Mocks the pieces of QuotaManager's interface. |
| 31 // | 31 // |
| 32 // For usage/quota tracking test: | 32 // For usage/quota tracking test: |
| 33 // Usage and quota information can be updated by following private helper | 33 // Usage and quota information can be updated by following private helper |
| 34 // methods: SetQuota() and UpdateUsage(). | 34 // methods: SetQuota() and UpdateUsage(). |
| 35 // | 35 // |
| 36 // For time-based deletion test: | 36 // For time-based deletion test: |
| 37 // Origins can be added to the mock by calling AddOrigin, and that list of | 37 // Origins can be added to the mock by calling AddOrigin, and that list of |
| 38 // origins is then searched through in GetOriginsModifiedSince. | 38 // origins is then searched through in GetOriginsModifiedSince. |
| 39 // Neither GetOriginsModifiedSince nor DeleteOriginData touches the actual | 39 // Neither GetOriginsModifiedSince nor DeleteOriginData touches the actual |
| 40 // origin data stored in the profile. | 40 // origin data stored in the profile. |
| 41 class MockQuotaManager : public QuotaManager { | 41 class MockQuotaManager : public QuotaManager { |
| 42 public: | 42 public: |
| 43 MockQuotaManager(bool is_incognito, | 43 MockQuotaManager(bool is_incognito, |
| 44 const base::FilePath& profile_path, | 44 const base::FilePath& profile_path, |
| 45 base::SingleThreadTaskRunner* io_thread, | 45 base::SingleThreadTaskRunner* io_thread, |
| 46 base::SequencedTaskRunner* db_thread, | 46 base::SequencedTaskRunner* db_thread, |
| 47 SpecialStoragePolicy* special_storage_policy); | 47 SpecialStoragePolicy* special_storage_policy); |
| 48 | 48 |
| 49 // Overrides QuotaManager's implementation. The internal usage data is | 49 // Overrides QuotaManager's implementation. The internal usage data is |
| 50 // updated when MockQuotaManagerProxy::NotifyStorageModified() is | 50 // updated when MockQuotaManagerProxy::NotifyStorageModified() is |
| 51 // called. The internal quota value can be updated by calling | 51 // called. The internal quota value can be updated by calling |
| 52 // a helper method MockQuotaManagerProxy::SetQuota(). | 52 // a helper method MockQuotaManagerProxy::SetQuota(). |
| 53 virtual void GetUsageAndQuota( | 53 virtual void GetUsageAndQuota( |
| 54 const GURL& origin, | 54 const GURL& origin, |
| 55 quota::StorageType type, | 55 storage::StorageType type, |
| 56 const GetUsageAndQuotaCallback& callback) OVERRIDE; | 56 const GetUsageAndQuotaCallback& callback) OVERRIDE; |
| 57 | 57 |
| 58 // Overrides QuotaManager's implementation with a canned implementation that | 58 // Overrides QuotaManager's implementation with a canned implementation that |
| 59 // allows clients to set up the origin database that should be queried. This | 59 // allows clients to set up the origin database that should be queried. This |
| 60 // method will only search through the origins added explicitly via AddOrigin. | 60 // method will only search through the origins added explicitly via AddOrigin. |
| 61 virtual void GetOriginsModifiedSince( | 61 virtual void GetOriginsModifiedSince( |
| 62 StorageType type, | 62 StorageType type, |
| 63 base::Time modified_since, | 63 base::Time modified_since, |
| 64 const GetOriginsCallback& callback) OVERRIDE; | 64 const GetOriginsCallback& callback) OVERRIDE; |
| 65 | 65 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 std::vector<OriginInfo> origins_; | 143 std::vector<OriginInfo> origins_; |
| 144 UsageAndQuotaMap usage_and_quota_map_; | 144 UsageAndQuotaMap usage_and_quota_map_; |
| 145 base::WeakPtrFactory<MockQuotaManager> weak_factory_; | 145 base::WeakPtrFactory<MockQuotaManager> weak_factory_; |
| 146 | 146 |
| 147 DISALLOW_COPY_AND_ASSIGN(MockQuotaManager); | 147 DISALLOW_COPY_AND_ASSIGN(MockQuotaManager); |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 } // namespace content | 150 } // namespace content |
| 151 | 151 |
| 152 #endif // CONTENT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_H_ | 152 #endif // CONTENT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_H_ |
| OLD | NEW |