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 <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <set> | 11 #include <set> |
10 #include <utility> | 12 #include <utility> |
11 #include <vector> | 13 #include <vector> |
12 | 14 |
13 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
14 #include "storage/browser/quota/quota_client.h" | 16 #include "storage/browser/quota/quota_client.h" |
15 #include "storage/browser/quota/quota_manager.h" | 17 #include "storage/browser/quota/quota_manager.h" |
16 #include "storage/browser/quota/quota_task.h" | 18 #include "storage/browser/quota/quota_task.h" |
17 #include "storage/common/quota/quota_types.h" | 19 #include "storage/common/quota/quota_types.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // specifies the types of QuotaClients which should be removed from this | 69 // specifies the types of QuotaClients which should be removed from this |
68 // origin as a bitmask built from QuotaClient::IDs. Setting the mask to | 70 // origin as a bitmask built from QuotaClient::IDs. Setting the mask to |
69 // QuotaClient::kAllClientsMask will remove all clients from the origin, | 71 // QuotaClient::kAllClientsMask will remove all clients from the origin, |
70 // regardless of type. | 72 // regardless of type. |
71 void DeleteOriginData(const GURL& origin, | 73 void DeleteOriginData(const GURL& origin, |
72 StorageType type, | 74 StorageType type, |
73 int quota_client_mask, | 75 int quota_client_mask, |
74 const StatusCallback& callback) override; | 76 const StatusCallback& callback) override; |
75 | 77 |
76 // Helper method for updating internal quota info. | 78 // Helper method for updating internal quota info. |
77 void SetQuota(const GURL& origin, StorageType type, int64 quota); | 79 void SetQuota(const GURL& origin, StorageType type, int64_t quota); |
78 | 80 |
79 // Helper methods for timed-deletion testing: | 81 // Helper methods for timed-deletion testing: |
80 // Adds an origin to the canned list that will be searched through via | 82 // Adds an origin to the canned list that will be searched through via |
81 // GetOriginsModifiedSince. The caller must provide |quota_client_mask| | 83 // GetOriginsModifiedSince. The caller must provide |quota_client_mask| |
82 // which specifies the types of QuotaClients this canned origin contains | 84 // which specifies the types of QuotaClients this canned origin contains |
83 // as a bitmask built from QuotaClient::IDs. | 85 // as a bitmask built from QuotaClient::IDs. |
84 bool AddOrigin(const GURL& origin, | 86 bool AddOrigin(const GURL& origin, |
85 StorageType type, | 87 StorageType type, |
86 int quota_client_mask, | 88 int quota_client_mask, |
87 base::Time modified); | 89 base::Time modified); |
(...skipping 28 matching lines...) Expand all Loading... |
116 base::Time modified; | 118 base::Time modified; |
117 }; | 119 }; |
118 | 120 |
119 // Contains the essential information for each origin for usage/quota testing. | 121 // Contains the essential information for each origin for usage/quota testing. |
120 // (Ideally this should probably merged into the above struct, but for | 122 // (Ideally this should probably merged into the above struct, but for |
121 // regular usage/quota testing we hardly need modified time but only | 123 // regular usage/quota testing we hardly need modified time but only |
122 // want to keep usage and quota information, so this struct exists. | 124 // want to keep usage and quota information, so this struct exists. |
123 struct StorageInfo { | 125 struct StorageInfo { |
124 StorageInfo(); | 126 StorageInfo(); |
125 ~StorageInfo(); | 127 ~StorageInfo(); |
126 int64 usage; | 128 int64_t usage; |
127 int64 quota; | 129 int64_t quota; |
128 }; | 130 }; |
129 | 131 |
130 typedef std::pair<GURL, StorageType> OriginAndType; | 132 typedef std::pair<GURL, StorageType> OriginAndType; |
131 typedef std::map<OriginAndType, StorageInfo> UsageAndQuotaMap; | 133 typedef std::map<OriginAndType, StorageInfo> UsageAndQuotaMap; |
132 | 134 |
133 // This must be called via MockQuotaManagerProxy. | 135 // This must be called via MockQuotaManagerProxy. |
134 void UpdateUsage(const GURL& origin, StorageType type, int64 delta); | 136 void UpdateUsage(const GURL& origin, StorageType type, int64_t delta); |
135 void DidGetModifiedSince(const GetOriginsCallback& callback, | 137 void DidGetModifiedSince(const GetOriginsCallback& callback, |
136 std::set<GURL>* origins, | 138 std::set<GURL>* origins, |
137 StorageType storage_type); | 139 StorageType storage_type); |
138 void DidDeleteOriginData(const StatusCallback& callback, | 140 void DidDeleteOriginData(const StatusCallback& callback, |
139 QuotaStatusCode status); | 141 QuotaStatusCode status); |
140 | 142 |
141 // The list of stored origins that have been added via AddOrigin. | 143 // The list of stored origins that have been added via AddOrigin. |
142 std::vector<OriginInfo> origins_; | 144 std::vector<OriginInfo> origins_; |
143 UsageAndQuotaMap usage_and_quota_map_; | 145 UsageAndQuotaMap usage_and_quota_map_; |
144 base::WeakPtrFactory<MockQuotaManager> weak_factory_; | 146 base::WeakPtrFactory<MockQuotaManager> weak_factory_; |
145 | 147 |
146 DISALLOW_COPY_AND_ASSIGN(MockQuotaManager); | 148 DISALLOW_COPY_AND_ASSIGN(MockQuotaManager); |
147 }; | 149 }; |
148 | 150 |
149 } // namespace content | 151 } // namespace content |
150 | 152 |
151 #endif // CONTENT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_H_ | 153 #endif // CONTENT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_H_ |
OLD | NEW |