Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / public / test / mock_special_storage_policy.h
blob1220f6543e4359c8ff8d9f2c7305fa0a56faf3b7
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_PUBLIC_TEST_MOCK_SPECIAL_STORAGE_POLICY_H_
6 #define CONTENT_PUBLIC_TEST_MOCK_SPECIAL_STORAGE_POLICY_H_
8 #include <set>
9 #include <string>
11 #include "storage/browser/quota/special_storage_policy.h"
12 #include "url/gurl.h"
14 using storage::SpecialStoragePolicy;
16 namespace content {
18 class MockSpecialStoragePolicy : public storage::SpecialStoragePolicy {
19 public:
20 MockSpecialStoragePolicy();
22 bool IsStorageProtected(const GURL& origin) override;
23 bool IsStorageUnlimited(const GURL& origin) override;
24 bool IsStorageSessionOnly(const GURL& origin) override;
25 bool CanQueryDiskSize(const GURL& origin) override;
26 bool HasIsolatedStorage(const GURL& origin) override;
27 bool HasSessionOnlyOrigins() override;
29 void AddProtected(const GURL& origin) {
30 protected_.insert(origin);
33 void AddUnlimited(const GURL& origin) {
34 unlimited_.insert(origin);
37 void RemoveUnlimited(const GURL& origin) {
38 unlimited_.erase(origin);
41 void AddSessionOnly(const GURL& origin) {
42 session_only_.insert(origin);
45 void GrantQueryDiskSize(const GURL& origin) {
46 can_query_disk_size_.insert(origin);
49 void AddIsolated(const GURL& origin) {
50 isolated_.insert(origin);
53 void RemoveIsolated(const GURL& origin) {
54 isolated_.erase(origin);
57 void SetAllUnlimited(bool all_unlimited) {
58 all_unlimited_ = all_unlimited;
61 void Reset() {
62 protected_.clear();
63 unlimited_.clear();
64 session_only_.clear();
65 can_query_disk_size_.clear();
66 file_handlers_.clear();
67 isolated_.clear();
68 all_unlimited_ = false;
71 void NotifyGranted(const GURL& origin, int change_flags) {
72 SpecialStoragePolicy::NotifyGranted(origin, change_flags);
75 void NotifyRevoked(const GURL& origin, int change_flags) {
76 SpecialStoragePolicy::NotifyRevoked(origin, change_flags);
79 void NotifyCleared() {
80 SpecialStoragePolicy::NotifyCleared();
83 protected:
84 ~MockSpecialStoragePolicy() override;
86 private:
87 std::set<GURL> protected_;
88 std::set<GURL> unlimited_;
89 std::set<GURL> session_only_;
90 std::set<GURL> can_query_disk_size_;
91 std::set<GURL> isolated_;
92 std::set<std::string> file_handlers_;
94 bool all_unlimited_;
96 } // namespace content
98 #endif // CONTENT_PUBLIC_TEST_MOCK_SPECIAL_STORAGE_POLICY_H_