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