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

Side by Side Diff: storage/browser/test/mock_special_storage_policy.h

Issue 2815743002: Move a couple of blob tests next to the files they cover. (Closed)
Patch Set: Fix gn check, take 2. Created 3 years, 8 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
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_PUBLIC_TEST_MOCK_SPECIAL_STORAGE_POLICY_H_ 5 #ifndef STORAGE_BROWSER_TEST_MOCK_SPECIAL_STORAGE_POLICY_H_
6 #define CONTENT_PUBLIC_TEST_MOCK_SPECIAL_STORAGE_POLICY_H_ 6 #define STORAGE_BROWSER_TEST_MOCK_SPECIAL_STORAGE_POLICY_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "storage/browser/quota/special_storage_policy.h" 11 #include "storage/browser/quota/special_storage_policy.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 using storage::SpecialStoragePolicy; 14 using storage::SpecialStoragePolicy;
15 15
16 namespace content { 16 namespace content {
17 17
18 class MockSpecialStoragePolicy : public storage::SpecialStoragePolicy { 18 class MockSpecialStoragePolicy : public storage::SpecialStoragePolicy {
19 public: 19 public:
20 MockSpecialStoragePolicy(); 20 MockSpecialStoragePolicy();
21 21
22 bool IsStorageProtected(const GURL& origin) override; 22 bool IsStorageProtected(const GURL& origin) override;
23 bool IsStorageUnlimited(const GURL& origin) override; 23 bool IsStorageUnlimited(const GURL& origin) override;
24 bool IsStorageSessionOnly(const GURL& origin) override; 24 bool IsStorageSessionOnly(const GURL& origin) override;
25 bool HasIsolatedStorage(const GURL& origin) override; 25 bool HasIsolatedStorage(const GURL& origin) override;
26 bool HasSessionOnlyOrigins() override; 26 bool HasSessionOnlyOrigins() override;
27 bool IsStorageDurable(const GURL& origin) override; 27 bool IsStorageDurable(const GURL& origin) override;
28 28
29 void AddProtected(const GURL& origin) { 29 void AddProtected(const GURL& origin) { protected_.insert(origin); }
30 protected_.insert(origin);
31 }
32 30
33 void AddUnlimited(const GURL& origin) { 31 void AddUnlimited(const GURL& origin) { unlimited_.insert(origin); }
34 unlimited_.insert(origin);
35 }
36 32
37 void RemoveUnlimited(const GURL& origin) { 33 void RemoveUnlimited(const GURL& origin) { unlimited_.erase(origin); }
38 unlimited_.erase(origin);
39 }
40 34
41 void AddSessionOnly(const GURL& origin) { 35 void AddSessionOnly(const GURL& origin) { session_only_.insert(origin); }
42 session_only_.insert(origin);
43 }
44 36
45 void AddIsolated(const GURL& origin) { 37 void AddIsolated(const GURL& origin) { isolated_.insert(origin); }
46 isolated_.insert(origin);
47 }
48 38
49 void RemoveIsolated(const GURL& origin) { 39 void RemoveIsolated(const GURL& origin) { isolated_.erase(origin); }
50 isolated_.erase(origin);
51 }
52 40
53 void SetAllUnlimited(bool all_unlimited) { 41 void SetAllUnlimited(bool all_unlimited) { all_unlimited_ = all_unlimited; }
54 all_unlimited_ = all_unlimited;
55 }
56 42
57 void AddDurable(const GURL& origin) { 43 void AddDurable(const GURL& origin) { durable_.insert(origin); }
58 durable_.insert(origin);
59 }
60 44
61 void Reset() { 45 void Reset() {
62 protected_.clear(); 46 protected_.clear();
63 unlimited_.clear(); 47 unlimited_.clear();
64 session_only_.clear(); 48 session_only_.clear();
65 file_handlers_.clear(); 49 file_handlers_.clear();
66 isolated_.clear(); 50 isolated_.clear();
67 all_unlimited_ = false; 51 all_unlimited_ = false;
68 } 52 }
69 53
70 void NotifyGranted(const GURL& origin, int change_flags) { 54 void NotifyGranted(const GURL& origin, int change_flags) {
71 SpecialStoragePolicy::NotifyGranted(origin, change_flags); 55 SpecialStoragePolicy::NotifyGranted(origin, change_flags);
72 } 56 }
73 57
74 void NotifyRevoked(const GURL& origin, int change_flags) { 58 void NotifyRevoked(const GURL& origin, int change_flags) {
75 SpecialStoragePolicy::NotifyRevoked(origin, change_flags); 59 SpecialStoragePolicy::NotifyRevoked(origin, change_flags);
76 } 60 }
77 61
78 void NotifyCleared() { 62 void NotifyCleared() { SpecialStoragePolicy::NotifyCleared(); }
79 SpecialStoragePolicy::NotifyCleared();
80 }
81 63
82 protected: 64 protected:
83 ~MockSpecialStoragePolicy() override; 65 ~MockSpecialStoragePolicy() override;
84 66
85 private: 67 private:
86 std::set<GURL> protected_; 68 std::set<GURL> protected_;
87 std::set<GURL> unlimited_; 69 std::set<GURL> unlimited_;
88 std::set<GURL> session_only_; 70 std::set<GURL> session_only_;
89 std::set<GURL> isolated_; 71 std::set<GURL> isolated_;
90 std::set<GURL> durable_; 72 std::set<GURL> durable_;
91 std::set<std::string> file_handlers_; 73 std::set<std::string> file_handlers_;
92 74
93 bool all_unlimited_; 75 bool all_unlimited_;
94 }; 76 };
95 } // namespace content 77 } // namespace content
96 78
97 #endif // CONTENT_PUBLIC_TEST_MOCK_SPECIAL_STORAGE_POLICY_H_ 79 #endif // STORAGE_BROWSER_TEST_MOCK_SPECIAL_STORAGE_POLICY_H_
OLDNEW
« no previous file with comments | « storage/browser/test/async_file_test_helper.cc ('k') | storage/browser/test/mock_special_storage_policy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698