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