aw: Rendering test harness and end-to-end smoke test
[chromium-blink-merge.git] / content / browser / quota / mock_quota_manager_proxy.h
blob0f52f6dcc8e860a8e337f7dccfd174c37f6ce787
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 void RegisterClient(QuotaClient* client) override;
28 void SimulateQuotaManagerDestroyed();
30 // We don't mock them.
31 void NotifyOriginInUse(const GURL& origin) override {}
32 void NotifyOriginNoLongerInUse(const GURL& origin) override {}
33 void SetUsageCacheEnabled(QuotaClient::ID client_id,
34 const GURL& origin,
35 StorageType type,
36 bool enabled) override {}
37 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 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 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 ~MockQuotaManagerProxy() override;
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_