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> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 bool is_incognito, | 44 bool is_incognito, |
45 const base::FilePath& profile_path, | 45 const base::FilePath& profile_path, |
46 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread, | 46 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread, |
47 const scoped_refptr<base::SequencedTaskRunner>& db_thread, | 47 const scoped_refptr<base::SequencedTaskRunner>& db_thread, |
48 const scoped_refptr<SpecialStoragePolicy>& special_storage_policy); | 48 const scoped_refptr<SpecialStoragePolicy>& special_storage_policy); |
49 | 49 |
50 // Overrides QuotaManager's implementation. The internal usage data is | 50 // Overrides QuotaManager's implementation. The internal usage data is |
51 // updated when MockQuotaManagerProxy::NotifyStorageModified() is | 51 // updated when MockQuotaManagerProxy::NotifyStorageModified() is |
52 // called. The internal quota value can be updated by calling | 52 // called. The internal quota value can be updated by calling |
53 // a helper method MockQuotaManagerProxy::SetQuota(). | 53 // a helper method MockQuotaManagerProxy::SetQuota(). |
54 virtual void GetUsageAndQuota( | 54 void GetUsageAndQuota(const GURL& origin, |
55 const GURL& origin, | 55 storage::StorageType type, |
56 storage::StorageType type, | 56 const GetUsageAndQuotaCallback& callback) override; |
57 const GetUsageAndQuotaCallback& callback) override; | |
58 | 57 |
59 // Overrides QuotaManager's implementation with a canned implementation that | 58 // Overrides QuotaManager's implementation with a canned implementation that |
60 // 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 |
61 // method will only search through the origins added explicitly via AddOrigin. | 60 // method will only search through the origins added explicitly via AddOrigin. |
62 virtual void GetOriginsModifiedSince( | 61 void GetOriginsModifiedSince(StorageType type, |
63 StorageType type, | 62 base::Time modified_since, |
64 base::Time modified_since, | 63 const GetOriginsCallback& callback) override; |
65 const GetOriginsCallback& callback) override; | |
66 | 64 |
67 // Removes an origin from the canned list of origins, but doesn't touch | 65 // Removes an origin from the canned list of origins, but doesn't touch |
68 // anything on disk. The caller must provide |quota_client_mask| which | 66 // anything on disk. The caller must provide |quota_client_mask| which |
69 // specifies the types of QuotaClients which should be removed from this | 67 // specifies the types of QuotaClients which should be removed from this |
70 // origin as a bitmask built from QuotaClient::IDs. Setting the mask to | 68 // origin as a bitmask built from QuotaClient::IDs. Setting the mask to |
71 // QuotaClient::kAllClientsMask will remove all clients from the origin, | 69 // QuotaClient::kAllClientsMask will remove all clients from the origin, |
72 // regardless of type. | 70 // regardless of type. |
73 virtual void DeleteOriginData(const GURL& origin, | 71 void DeleteOriginData(const GURL& origin, |
74 StorageType type, | 72 StorageType type, |
75 int quota_client_mask, | 73 int quota_client_mask, |
76 const StatusCallback& callback) override; | 74 const StatusCallback& callback) override; |
77 | 75 |
78 // Helper method for updating internal quota info. | 76 // Helper method for updating internal quota info. |
79 void SetQuota(const GURL& origin, StorageType type, int64 quota); | 77 void SetQuota(const GURL& origin, StorageType type, int64 quota); |
80 | 78 |
81 // Helper methods for timed-deletion testing: | 79 // Helper methods for timed-deletion testing: |
82 // Adds an origin to the canned list that will be searched through via | 80 // Adds an origin to the canned list that will be searched through via |
83 // GetOriginsModifiedSince. The caller must provide |quota_client_mask| | 81 // GetOriginsModifiedSince. The caller must provide |quota_client_mask| |
84 // which specifies the types of QuotaClients this canned origin contains | 82 // which specifies the types of QuotaClients this canned origin contains |
85 // as a bitmask built from QuotaClient::IDs. | 83 // as a bitmask built from QuotaClient::IDs. |
86 bool AddOrigin(const GURL& origin, | 84 bool AddOrigin(const GURL& origin, |
87 StorageType type, | 85 StorageType type, |
88 int quota_client_mask, | 86 int quota_client_mask, |
89 base::Time modified); | 87 base::Time modified); |
90 | 88 |
91 // Helper methods for timed-deletion testing: | 89 // Helper methods for timed-deletion testing: |
92 // Checks an origin and type against the origins that have been added via | 90 // Checks an origin and type against the origins that have been added via |
93 // AddOrigin and removed via DeleteOriginData. If the origin exists in the | 91 // AddOrigin and removed via DeleteOriginData. If the origin exists in the |
94 // canned list with the proper StorageType and client, returns true. | 92 // canned list with the proper StorageType and client, returns true. |
95 bool OriginHasData(const GURL& origin, | 93 bool OriginHasData(const GURL& origin, |
96 StorageType type, | 94 StorageType type, |
97 QuotaClient::ID quota_client) const; | 95 QuotaClient::ID quota_client) const; |
98 | 96 |
99 protected: | 97 protected: |
100 virtual ~MockQuotaManager(); | 98 ~MockQuotaManager() override; |
101 | 99 |
102 private: | 100 private: |
103 friend class MockQuotaManagerProxy; | 101 friend class MockQuotaManagerProxy; |
104 | 102 |
105 // Contains the essential bits of information about an origin that the | 103 // Contains the essential bits of information about an origin that the |
106 // MockQuotaManager needs to understand for time-based deletion: | 104 // MockQuotaManager needs to understand for time-based deletion: |
107 // the origin itself, the StorageType and its modification time. | 105 // the origin itself, the StorageType and its modification time. |
108 struct OriginInfo { | 106 struct OriginInfo { |
109 OriginInfo(const GURL& origin, | 107 OriginInfo(const GURL& origin, |
110 StorageType type, | 108 StorageType type, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 std::vector<OriginInfo> origins_; | 142 std::vector<OriginInfo> origins_; |
145 UsageAndQuotaMap usage_and_quota_map_; | 143 UsageAndQuotaMap usage_and_quota_map_; |
146 base::WeakPtrFactory<MockQuotaManager> weak_factory_; | 144 base::WeakPtrFactory<MockQuotaManager> weak_factory_; |
147 | 145 |
148 DISALLOW_COPY_AND_ASSIGN(MockQuotaManager); | 146 DISALLOW_COPY_AND_ASSIGN(MockQuotaManager); |
149 }; | 147 }; |
150 | 148 |
151 } // namespace content | 149 } // namespace content |
152 | 150 |
153 #endif // CONTENT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_H_ | 151 #endif // CONTENT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_H_ |
OLD | NEW |