OLD | NEW |
---|---|
1 // Copyright (c) 2011 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_MOCK_QUOTA_MANAGER_H_ | 5 #ifndef WEBKIT_QUOTA_MOCK_QUOTA_MANAGER_H_ |
6 #define WEBKIT_QUOTA_MOCK_QUOTA_MANAGER_H_ | 6 #define WEBKIT_QUOTA_MOCK_QUOTA_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 #include <string> | 10 #include <string> |
11 | 11 |
(...skipping 12 matching lines...) Expand all Loading... | |
24 // GetOriginsModifiedSince. Neither GetOriginsModifiedSince nor DeleteOriginData | 24 // GetOriginsModifiedSince. Neither GetOriginsModifiedSince nor DeleteOriginData |
25 // touches the actual origin data stored in the profile. | 25 // touches the actual origin data stored in the profile. |
26 class MockQuotaManager : public QuotaManager { | 26 class MockQuotaManager : public QuotaManager { |
27 public: | 27 public: |
28 // Contains the essential bits of information about an origin that the | 28 // Contains the essential bits of information about an origin that the |
29 // MockQuotaManager needs to understand: the origin itself, the StorageType, | 29 // MockQuotaManager needs to understand: the origin itself, the StorageType, |
30 // and its modification time. | 30 // and its modification time. |
31 struct OriginInfo { | 31 struct OriginInfo { |
32 OriginInfo(const GURL& origin, | 32 OriginInfo(const GURL& origin, |
33 StorageType type, | 33 StorageType type, |
34 int quota_client_mask, | |
34 base::Time modified); | 35 base::Time modified); |
35 ~OriginInfo(); | 36 ~OriginInfo(); |
36 | 37 |
37 GURL origin; | 38 GURL origin; |
38 StorageType type; | 39 StorageType type; |
40 int quota_client_mask; | |
39 base::Time modified; | 41 base::Time modified; |
40 }; | 42 }; |
41 | 43 |
42 MockQuotaManager(bool is_incognito, | 44 MockQuotaManager(bool is_incognito, |
43 const FilePath& profile_path, | 45 const FilePath& profile_path, |
44 base::MessageLoopProxy* io_thread, | 46 base::MessageLoopProxy* io_thread, |
45 base::MessageLoopProxy* db_thread, | 47 base::MessageLoopProxy* db_thread, |
46 SpecialStoragePolicy* special_storage_policy); | 48 SpecialStoragePolicy* special_storage_policy); |
47 | 49 |
48 virtual ~MockQuotaManager(); | 50 virtual ~MockQuotaManager(); |
49 | 51 |
50 // Adds an origin to the canned list that will be searched through via | 52 // Adds an origin to the canned list that will be searched through via |
51 // GetOriginsModifiedSince. | 53 // GetOriginsModifiedSince. |
kinuko
2012/01/22 18:35:31
nit: can we also add a brief comment for |quota_cl
Mike West
2012/01/22 20:54:38
Done.
| |
52 bool AddOrigin(const GURL& origin, StorageType type, base::Time modified); | 54 bool AddOrigin(const GURL& origin, |
55 StorageType type, | |
56 int quota_client_mask, | |
57 base::Time modified); | |
53 | 58 |
54 // Checks an origin and type against the origins that have been added via | 59 // Checks an origin and type against the origins that have been added via |
55 // AddOrigin and removed via DeleteOriginData. If the origin exists in the | 60 // AddOrigin and removed via DeleteOriginData. If the origin exists in the |
56 // canned list with the proper StorageType, returns true. | 61 // canned list with the proper StorageType and client, returns true. |
57 bool OriginHasData(const GURL& origin, StorageType type) const; | 62 bool OriginHasData(const GURL& origin, |
63 StorageType type, | |
64 QuotaClient::ID quota_client) const; | |
58 | 65 |
59 // Overrides QuotaManager's implementation with a canned implementation that | 66 // Overrides QuotaManager's implementation with a canned implementation that |
60 // allows clients to set up the origin database that should be queried. This | 67 // 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. | 68 // method will only search through the origins added explicitly via AddOrigin. |
62 virtual void GetOriginsModifiedSince( | 69 virtual void GetOriginsModifiedSince( |
63 StorageType type, | 70 StorageType type, |
64 base::Time modified_since, | 71 base::Time modified_since, |
65 const GetOriginsCallback& callback) OVERRIDE; | 72 const GetOriginsCallback& callback) OVERRIDE; |
66 | 73 |
67 // Removes an origin from the canned list of origins, but doesn't touch | 74 // Removes an origin from the canned list of origins, but doesn't touch |
68 // anything on disk. | 75 // anything on disk. |
69 virtual void DeleteOriginData(const GURL& origin, | 76 virtual void DeleteOriginData(const GURL& origin, |
70 StorageType type, | 77 StorageType type, |
78 int quota_client_mask, | |
71 const StatusCallback& callback) OVERRIDE; | 79 const StatusCallback& callback) OVERRIDE; |
72 | 80 |
73 private: | 81 private: |
74 class GetModifiedSinceTask; | 82 class GetModifiedSinceTask; |
75 class DeleteOriginDataTask; | 83 class DeleteOriginDataTask; |
76 | 84 |
77 // The list of stored origins that have been added via AddOrigin. | 85 // The list of stored origins that have been added via AddOrigin. |
78 std::vector<OriginInfo> origins_; | 86 std::vector<OriginInfo> origins_; |
79 | 87 |
80 DISALLOW_COPY_AND_ASSIGN(MockQuotaManager); | 88 DISALLOW_COPY_AND_ASSIGN(MockQuotaManager); |
81 }; | 89 }; |
82 | 90 |
83 } // namespace quota | 91 } // namespace quota |
84 | 92 |
85 #endif // WEBKIT_QUOTA_MOCK_QUOTA_MANAGER_H_ | 93 #endif // WEBKIT_QUOTA_MOCK_QUOTA_MANAGER_H_ |
OLD | NEW |