| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_PROXY_H_ | |
| 6 #define CONTENT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_PROXY_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "content/browser/quota/mock_quota_manager.h" | |
| 12 #include "storage/browser/quota/quota_client.h" | |
| 13 #include "storage/browser/quota/quota_manager_proxy.h" | |
| 14 #include "storage/common/quota/quota_types.h" | |
| 15 #include "url/gurl.h" | |
| 16 | |
| 17 using storage::QuotaManagerProxy; | |
| 18 | |
| 19 namespace content { | |
| 20 | |
| 21 class MockQuotaManager; | |
| 22 | |
| 23 class MockQuotaManagerProxy : public QuotaManagerProxy { | |
| 24 public: | |
| 25 // It is ok to give NULL to |quota_manager|. | |
| 26 MockQuotaManagerProxy(MockQuotaManager* quota_manager, | |
| 27 base::SingleThreadTaskRunner* task_runner); | |
| 28 | |
| 29 void RegisterClient(QuotaClient* client) override; | |
| 30 | |
| 31 void SimulateQuotaManagerDestroyed(); | |
| 32 | |
| 33 // We don't mock them. | |
| 34 void NotifyOriginInUse(const GURL& origin) override {} | |
| 35 void NotifyOriginNoLongerInUse(const GURL& origin) override {} | |
| 36 void SetUsageCacheEnabled(QuotaClient::ID client_id, | |
| 37 const GURL& origin, | |
| 38 StorageType type, | |
| 39 bool enabled) override {} | |
| 40 void GetUsageAndQuota( | |
| 41 base::SequencedTaskRunner* original_task_runner, | |
| 42 const GURL& origin, | |
| 43 StorageType type, | |
| 44 const QuotaManager::UsageAndQuotaCallback& callback) override; | |
| 45 | |
| 46 // Validates the |client_id| and updates the internal access count | |
| 47 // which can be accessed via notify_storage_accessed_count(). | |
| 48 // The also records the |origin| and |type| in last_notified_origin_ and | |
| 49 // last_notified_type_. | |
| 50 void NotifyStorageAccessed(QuotaClient::ID client_id, | |
| 51 const GURL& origin, | |
| 52 StorageType type) override; | |
| 53 | |
| 54 // Records the |origin|, |type| and |delta| as last_notified_origin_, | |
| 55 // last_notified_type_ and last_notified_delta_ respecitvely. | |
| 56 // If non-null MockQuotaManager is given to the constructor this also | |
| 57 // updates the manager's internal usage information. | |
| 58 void NotifyStorageModified(QuotaClient::ID client_id, | |
| 59 const GURL& origin, | |
| 60 StorageType type, | |
| 61 int64_t delta) override; | |
| 62 | |
| 63 int notify_storage_accessed_count() const { return storage_accessed_count_; } | |
| 64 int notify_storage_modified_count() const { return storage_modified_count_; } | |
| 65 GURL last_notified_origin() const { return last_notified_origin_; } | |
| 66 StorageType last_notified_type() const { return last_notified_type_; } | |
| 67 int64_t last_notified_delta() const { return last_notified_delta_; } | |
| 68 | |
| 69 protected: | |
| 70 ~MockQuotaManagerProxy() override; | |
| 71 | |
| 72 private: | |
| 73 MockQuotaManager* mock_manager() const { | |
| 74 return static_cast<MockQuotaManager*>(quota_manager()); | |
| 75 } | |
| 76 | |
| 77 int storage_accessed_count_; | |
| 78 int storage_modified_count_; | |
| 79 GURL last_notified_origin_; | |
| 80 StorageType last_notified_type_; | |
| 81 int64_t last_notified_delta_; | |
| 82 | |
| 83 QuotaClient* registered_client_; | |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(MockQuotaManagerProxy); | |
| 86 }; | |
| 87 | |
| 88 } // namespace content | |
| 89 | |
| 90 #endif // CONTENT_BROWSER_QUOTA_MOCK_QUOTA_MANAGER_PROXY_H_ | |
| OLD | NEW |