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