Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: content/public/test/mock_storage_client.h

Issue 2368913003: Populate storage_unittests target. (Closed)
Patch Set: Removed unnecessary include from storage/browser/blob/blob_storage_context_unittest.cc. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 CONTENT_PUBLIC_TEST_MOCK_STORAGE_CLIENT_H_
6 #define CONTENT_PUBLIC_TEST_MOCK_STORAGE_CLIENT_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <map>
12 #include <set>
13 #include <string>
14 #include <utility>
15
16 #include "base/compiler_specific.h"
17 #include "base/macros.h"
18 #include "base/memory/weak_ptr.h"
19 #include "base/time/time.h"
20 #include "storage/browser/quota/quota_client.h"
21 #include "url/gurl.h"
22
23 namespace storage {
24 class QuotaManagerProxy;
25 }
26
27 using storage::QuotaClient;
28 using storage::QuotaManagerProxy;
29 using storage::StorageType;
30
31 namespace content {
32
33 struct MockOriginData {
34 const char* origin;
35 StorageType type;
36 int64_t usage;
37 };
38
39 // Mock storage class for testing.
40 class MockStorageClient : public QuotaClient {
41 public:
42 MockStorageClient(QuotaManagerProxy* quota_manager_proxy,
43 const MockOriginData* mock_data,
44 QuotaClient::ID id,
45 size_t mock_data_size);
46 ~MockStorageClient() override;
47
48 // To add or modify mock data in this client.
49 void AddOriginAndNotify(const GURL& origin_url,
50 StorageType type,
51 int64_t size);
52 void ModifyOriginAndNotify(const GURL& origin_url,
53 StorageType type,
54 int64_t delta);
55 void TouchAllOriginsAndNotify();
56
57 void AddOriginToErrorSet(const GURL& origin_url, StorageType type);
58
59 base::Time IncrementMockTime();
60
61 // QuotaClient methods.
62 QuotaClient::ID id() const override;
63 void OnQuotaManagerDestroyed() override;
64 void GetOriginUsage(const GURL& origin_url,
65 StorageType type,
66 const GetUsageCallback& callback) override;
67 void GetOriginsForType(StorageType type,
68 const GetOriginsCallback& callback) override;
69 void GetOriginsForHost(StorageType type,
70 const std::string& host,
71 const GetOriginsCallback& callback) override;
72 void DeleteOriginData(const GURL& origin,
73 StorageType type,
74 const DeletionCallback& callback) override;
75 bool DoesSupport(storage::StorageType type) const override;
76
77 private:
78 void RunGetOriginUsage(const GURL& origin_url,
79 StorageType type,
80 const GetUsageCallback& callback);
81 void RunGetOriginsForType(StorageType type,
82 const GetOriginsCallback& callback);
83 void RunGetOriginsForHost(StorageType type,
84 const std::string& host,
85 const GetOriginsCallback& callback);
86 void RunDeleteOriginData(const GURL& origin_url,
87 StorageType type,
88 const DeletionCallback& callback);
89
90 void Populate(const MockOriginData* mock_data, size_t mock_data_size);
91
92 scoped_refptr<QuotaManagerProxy> quota_manager_proxy_;
93 const ID id_;
94
95 typedef std::map<std::pair<GURL, StorageType>, int64_t> OriginDataMap;
96 OriginDataMap origin_data_;
97 typedef std::set<std::pair<GURL, StorageType> > ErrorOriginSet;
98 ErrorOriginSet error_origins_;
99
100 int mock_time_counter_;
101
102 base::WeakPtrFactory<MockStorageClient> weak_factory_;
103
104 DISALLOW_COPY_AND_ASSIGN(MockStorageClient);
105 };
106
107 } // namespace content
108
109 #endif // CONTENT_PUBLIC_TEST_MOCK_STORAGE_CLIENT_H_
OLDNEW
« no previous file with comments | « content/public/test/mock_special_storage_policy.cc ('k') | content/public/test/mock_storage_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698