Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_STORAGE_CLIENT_H_ | 5 #ifndef WEBKIT_QUOTA_MOCK_STORAGE_CLIENT_H_ |
| 6 #define WEBKIT_QUOTA_MOCK_STORAGE_CLIENT_H_ | 6 #define WEBKIT_QUOTA_MOCK_STORAGE_CLIENT_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/task.h" | 13 #include "base/task.h" |
| 14 #include "base/time.h" | |
| 14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 15 #include "webkit/quota/quota_client.h" | 16 #include "webkit/quota/quota_client.h" |
| 16 | 17 |
| 17 namespace quota { | 18 namespace quota { |
| 18 | 19 |
| 19 class QuotaManagerProxy; | 20 class QuotaManagerProxy; |
| 20 | 21 |
| 21 struct MockOriginData { | 22 struct MockOriginData { |
| 22 const char* origin; | 23 const char* origin; |
| 23 StorageType type; | 24 StorageType type; |
| 24 int64 usage; | 25 int64 usage; |
| 25 }; | 26 }; |
| 26 | 27 |
| 27 // Mock storage class for testing. | 28 // Mock storage class for testing. |
| 28 class MockStorageClient : public QuotaClient { | 29 class MockStorageClient : public QuotaClient { |
| 29 public: | 30 public: |
| 30 MockStorageClient(QuotaManagerProxy* quota_manager_proxy, | 31 MockStorageClient(QuotaManagerProxy* quota_manager_proxy, |
| 31 const MockOriginData* mock_data, size_t mock_data_size); | 32 const MockOriginData* mock_data, size_t mock_data_size); |
| 32 virtual ~MockStorageClient(); | 33 virtual ~MockStorageClient(); |
| 33 | 34 |
| 34 // To add or modify mock data in this client. | 35 // To add or modify mock data in this client. |
| 35 void AddOriginAndNotify( | 36 void AddOriginAndNotify( |
| 36 const GURL& origin_url, StorageType type, int64 size); | 37 const GURL& origin_url, StorageType type, int64 size); |
| 37 void ModifyOriginAndNotify( | 38 void ModifyOriginAndNotify( |
| 38 const GURL& origin_url, StorageType type, int64 delta); | 39 const GURL& origin_url, StorageType type, int64 delta); |
| 39 | 40 |
| 40 void AddOriginToErrorSet(const GURL& origin_url, StorageType type); | 41 void AddOriginToErrorSet(const GURL& origin_url, StorageType type); |
| 41 | 42 |
| 43 base::Time GetCurrentMockTime(); | |
|
michaeln
2011/07/01 00:17:39
Would IncrementMockTime() be more accurate?
kinuko
2011/07/04 07:43:52
Done.
| |
| 44 | |
| 42 // QuotaClient methods. | 45 // QuotaClient methods. |
| 43 virtual QuotaClient::ID id() const OVERRIDE; | 46 virtual QuotaClient::ID id() const OVERRIDE; |
| 44 virtual void OnQuotaManagerDestroyed() OVERRIDE; | 47 virtual void OnQuotaManagerDestroyed() OVERRIDE; |
| 45 virtual void GetOriginUsage(const GURL& origin_url, | 48 virtual void GetOriginUsage(const GURL& origin_url, |
| 46 StorageType type, | 49 StorageType type, |
| 47 GetUsageCallback* callback) OVERRIDE; | 50 GetUsageCallback* callback) OVERRIDE; |
| 48 virtual void GetOriginsForType(StorageType type, | 51 virtual void GetOriginsForType(StorageType type, |
| 49 GetOriginsCallback* callback) OVERRIDE; | 52 GetOriginsCallback* callback) OVERRIDE; |
| 50 virtual void GetOriginsForHost(StorageType type, const std::string& host, | 53 virtual void GetOriginsForHost(StorageType type, const std::string& host, |
| 51 GetOriginsCallback* callback) OVERRIDE; | 54 GetOriginsCallback* callback) OVERRIDE; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 71 | 74 |
| 72 typedef std::map<std::pair<GURL, StorageType>, int64> OriginDataMap; | 75 typedef std::map<std::pair<GURL, StorageType>, int64> OriginDataMap; |
| 73 OriginDataMap origin_data_; | 76 OriginDataMap origin_data_; |
| 74 typedef std::set<std::pair<GURL, StorageType> > ErrorOriginSet; | 77 typedef std::set<std::pair<GURL, StorageType> > ErrorOriginSet; |
| 75 ErrorOriginSet error_origins_; | 78 ErrorOriginSet error_origins_; |
| 76 | 79 |
| 77 std::set<GetUsageCallback*> usage_callbacks_; | 80 std::set<GetUsageCallback*> usage_callbacks_; |
| 78 std::set<GetOriginsCallback*> origins_callbacks_; | 81 std::set<GetOriginsCallback*> origins_callbacks_; |
| 79 std::set<DeletionCallback*> deletion_callbacks_; | 82 std::set<DeletionCallback*> deletion_callbacks_; |
| 80 | 83 |
| 84 int virtual_time_counter_; | |
|
michaeln
2011/07/01 00:17:39
nit: mock_time_counter_ would line up with the met
kinuko
2011/07/04 07:43:52
Done.
| |
| 85 | |
| 81 ScopedRunnableMethodFactory<MockStorageClient> runnable_factory_; | 86 ScopedRunnableMethodFactory<MockStorageClient> runnable_factory_; |
| 82 | 87 |
| 83 DISALLOW_COPY_AND_ASSIGN(MockStorageClient); | 88 DISALLOW_COPY_AND_ASSIGN(MockStorageClient); |
| 84 }; | 89 }; |
| 85 | 90 |
| 86 } // namespace quota | 91 } // namespace quota |
| 87 | 92 |
| 88 #endif // WEBKIT_QUOTA_MOCK_STORAGE_CLIENT_H_ | 93 #endif // WEBKIT_QUOTA_MOCK_STORAGE_CLIENT_H_ |
| OLD | NEW |