OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "webkit/quota/mock_quota_manager.h" | 5 #include "webkit/quota/mock_quota_manager.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 | 68 |
69 private: | 69 private: |
70 scoped_ptr<StatusCallback> callback_; | 70 scoped_ptr<StatusCallback> callback_; |
71 | 71 |
72 DISALLOW_COPY_AND_ASSIGN(DeleteOriginDataTask); | 72 DISALLOW_COPY_AND_ASSIGN(DeleteOriginDataTask); |
73 }; | 73 }; |
74 | 74 |
75 MockQuotaManager::OriginInfo::OriginInfo( | 75 MockQuotaManager::OriginInfo::OriginInfo( |
76 const GURL& origin, | 76 const GURL& origin, |
77 StorageType type, | 77 StorageType type, |
78 int client_mask, | |
jochen (gone - plz use gerrit)
2011/09/12 11:23:00
in the header this is quota_client_mask
| |
78 base::Time modified) | 79 base::Time modified) |
79 : origin(origin), | 80 : origin(origin), |
80 type(type), | 81 type(type), |
82 mask(client_mask), | |
81 modified(modified) { | 83 modified(modified) { |
82 } | 84 } |
83 | 85 |
84 MockQuotaManager::OriginInfo::~OriginInfo() {} | 86 MockQuotaManager::OriginInfo::~OriginInfo() {} |
85 | 87 |
86 MockQuotaManager::MockQuotaManager(bool is_incognito, | 88 MockQuotaManager::MockQuotaManager(bool is_incognito, |
87 const FilePath& profile_path, base::MessageLoopProxy* io_thread, | 89 const FilePath& profile_path, base::MessageLoopProxy* io_thread, |
88 base::MessageLoopProxy* db_thread, | 90 base::MessageLoopProxy* db_thread, |
89 SpecialStoragePolicy* special_storage_policy) | 91 SpecialStoragePolicy* special_storage_policy) |
90 : QuotaManager(is_incognito, profile_path, io_thread, db_thread, | 92 : QuotaManager(is_incognito, profile_path, io_thread, db_thread, |
91 special_storage_policy) { | 93 special_storage_policy) { |
92 } | 94 } |
93 | 95 |
94 MockQuotaManager::~MockQuotaManager() {} | 96 MockQuotaManager::~MockQuotaManager() {} |
95 | 97 |
96 bool MockQuotaManager::AddOrigin(const GURL& origin, StorageType type, | 98 bool MockQuotaManager::AddOrigin(const GURL& origin, StorageType type, |
97 base::Time modified) { | 99 int quota_client_mask, base::Time modified) { |
98 origins_.push_back(OriginInfo(origin, type, modified)); | 100 origins_.push_back(OriginInfo(origin, type, quota_client_mask, modified)); |
99 return true; | 101 return true; |
100 } | 102 } |
101 | 103 |
102 bool MockQuotaManager::OriginHasData(const GURL& origin, | 104 bool MockQuotaManager::OriginHasData(const GURL& origin, |
103 StorageType type) const { | 105 StorageType type, QuotaClient::ID quota_client) const { |
104 for (std::vector<OriginInfo>::const_iterator current = origins_.begin(); | 106 for (std::vector<OriginInfo>::const_iterator current = origins_.begin(); |
105 current != origins_.end(); | 107 current != origins_.end(); |
106 ++current) { | 108 ++current) { |
107 if (current->origin == origin && current->type == type) | 109 if (current->origin == origin && current->type == type && |
110 (current->mask & quota_client)) | |
108 return true; | 111 return true; |
109 } | 112 } |
110 return false; | 113 return false; |
111 } | 114 } |
112 | 115 |
113 void MockQuotaManager::GetOriginsModifiedSince(StorageType type, | 116 void MockQuotaManager::GetOriginsModifiedSince(StorageType type, |
114 base::Time modified_since, GetOriginsCallback* callback) { | 117 base::Time modified_since, GetOriginsCallback* callback) { |
115 std::set<GURL> origins_to_return; | 118 std::set<GURL> origins_to_return; |
116 for (std::vector<OriginInfo>::const_iterator current = origins_.begin(); | 119 for (std::vector<OriginInfo>::const_iterator current = origins_.begin(); |
117 current != origins_.end(); | 120 current != origins_.end(); |
118 ++current) { | 121 ++current) { |
119 if (current->type == type && current->modified >= modified_since) | 122 if (current->type == type && current->modified >= modified_since) |
120 origins_to_return.insert(current->origin); | 123 origins_to_return.insert(current->origin); |
121 } | 124 } |
122 make_scoped_refptr(new GetModifiedSinceTask(this, origins_to_return, type, | 125 make_scoped_refptr(new GetModifiedSinceTask(this, origins_to_return, type, |
123 callback))->Start(); | 126 callback))->Start(); |
124 } | 127 } |
125 | 128 |
126 void MockQuotaManager::DeleteOriginData(const GURL& origin, StorageType type, | 129 void MockQuotaManager::DeleteOriginData(const GURL& origin, StorageType type, |
127 StatusCallback* callback) { | 130 int quota_client_mask, StatusCallback* callback) { |
128 for (std::vector<OriginInfo>::iterator current = origins_.begin(); | 131 for (std::vector<OriginInfo>::iterator current = origins_.begin(); |
129 current != origins_.end(); | 132 current != origins_.end(); |
130 ++current) { | 133 ++current) { |
131 if (current->origin == origin && current->type == type) { | 134 if (current->origin == origin && current->type == type) { |
132 origins_.erase(current); | 135 // Modify the current bitmask, and if it's 0 after "deletion", remove the |
136 // origin entirely. | |
137 current->mask &= ~quota_client_mask; | |
138 if (current->mask == 0) | |
139 origins_.erase(current); | |
133 break; | 140 break; |
134 } | 141 } |
135 } | 142 } |
136 make_scoped_refptr(new DeleteOriginDataTask(this, callback))->Start(); | 143 make_scoped_refptr(new DeleteOriginDataTask(this, callback))->Start(); |
137 } | 144 } |
138 | 145 |
139 } // namespace quota | 146 } // namespace quota |
OLD | NEW |