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