OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WEBKIT_QUOTA_MOCK_QUOTA_MANAGER_H_ |
| 6 #define WEBKIT_QUOTA_MOCK_QUOTA_MANAGER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <vector> |
| 10 #include <string> |
| 11 |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "googleurl/src/gurl.h" |
| 14 #include "webkit/quota/quota_client.h" |
| 15 #include "webkit/quota/quota_manager.h" |
| 16 #include "webkit/quota/quota_task.h" |
| 17 #include "webkit/quota/quota_types.h" |
| 18 |
| 19 namespace quota { |
| 20 |
| 21 // Mocks the pieces of QuotaManager's interface that are used for time-based |
| 22 // deletion of a profile's browsing data. Origins can be added to the mock by |
| 23 // calling AddOrigin, and that list of origins is then searched through in |
| 24 // GetOriginsModifiedSince. Neither GetOriginsModifiedSince nor DeleteOriginData |
| 25 // touches the actual origin data stored in the profile. |
| 26 class MockQuotaManager : public QuotaManager { |
| 27 public: |
| 28 // Contains the essential bits of information about an origin that the |
| 29 // MockQuotaManager needs to understand: the origin itself, the StorageType, |
| 30 // and its modification time. |
| 31 struct OriginInfo { |
| 32 OriginInfo(const GURL& origin, |
| 33 StorageType type, |
| 34 base::Time modified); |
| 35 ~OriginInfo(); |
| 36 |
| 37 GURL origin; |
| 38 StorageType type; |
| 39 base::Time modified; |
| 40 }; |
| 41 |
| 42 MockQuotaManager(bool is_incognito, |
| 43 const FilePath& profile_path, |
| 44 base::MessageLoopProxy* io_thread, |
| 45 base::MessageLoopProxy* db_thread, |
| 46 SpecialStoragePolicy* special_storage_policy); |
| 47 |
| 48 virtual ~MockQuotaManager(); |
| 49 |
| 50 // Adds an origin to the canned list that will be searched through via |
| 51 // GetOriginsModifiedSince. |
| 52 bool AddOrigin(const GURL& origin, StorageType type, base::Time modified); |
| 53 |
| 54 // 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 |
| 56 // canned list with the proper StorageType, returns true. |
| 57 bool OriginHasData(const GURL& origin, StorageType type) const; |
| 58 |
| 59 // Overrides QuotaManager's implementation with a canned implementation that |
| 60 // 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. |
| 62 virtual void GetOriginsModifiedSince(StorageType type, |
| 63 base::Time modified_since, |
| 64 GetOriginsCallback* callback) OVERRIDE; |
| 65 |
| 66 // Removes an origin from the canned list of origins, but doesn't touch |
| 67 // anything on disk. |
| 68 virtual void DeleteOriginData(const GURL& origin, |
| 69 StorageType type, |
| 70 StatusCallback* callback) OVERRIDE; |
| 71 private: |
| 72 class GetModifiedSinceTask; |
| 73 class DeleteOriginDataTask; |
| 74 |
| 75 // The list of stored origins that have been added via AddOrigin. |
| 76 std::vector<OriginInfo> origins_; |
| 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(MockQuotaManager); |
| 79 }; |
| 80 |
| 81 } // namespace quota |
| 82 |
| 83 #endif // WEBKIT_QUOTA_MOCK_QUOTA_MANAGER_H_ |
OLD | NEW |