OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 5 #include <set> |
6 #include <sstream> | 6 #include <sstream> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 121 } |
122 | 122 |
123 void GetPersistentHostQuota(const std::string& host) { | 123 void GetPersistentHostQuota(const std::string& host) { |
124 quota_status_ = kQuotaStatusUnknown; | 124 quota_status_ = kQuotaStatusUnknown; |
125 host_.clear(); | 125 host_.clear(); |
126 type_ = kStorageTypeUnknown; | 126 type_ = kStorageTypeUnknown; |
127 quota_ = -1; | 127 quota_ = -1; |
128 quota_manager_->GetPersistentHostQuota( | 128 quota_manager_->GetPersistentHostQuota( |
129 host, | 129 host, |
130 base::Bind(&QuotaManagerTest::DidGetHostQuota, | 130 base::Bind(&QuotaManagerTest::DidGetHostQuota, |
131 weak_factory_.GetWeakPtr())); | 131 weak_factory_.GetWeakPtr(), host, type_)); |
132 } | 132 } |
133 | 133 |
134 void SetPersistentHostQuota(const std::string& host, int64 new_quota) { | 134 void SetPersistentHostQuota(const std::string& host, int64 new_quota) { |
135 quota_status_ = kQuotaStatusUnknown; | 135 quota_status_ = kQuotaStatusUnknown; |
136 host_.clear(); | 136 host_.clear(); |
137 type_ = kStorageTypeUnknown; | 137 type_ = kStorageTypeUnknown; |
138 quota_ = -1; | 138 quota_ = -1; |
139 quota_manager_->SetPersistentHostQuota( | 139 quota_manager_->SetPersistentHostQuota( |
140 host, new_quota, | 140 host, new_quota, |
141 base::Bind(&QuotaManagerTest::DidGetHostQuota, | 141 base::Bind(&QuotaManagerTest::DidGetHostQuota, |
142 weak_factory_.GetWeakPtr())); | 142 weak_factory_.GetWeakPtr(), host, type_)); |
143 } | 143 } |
144 | 144 |
145 void GetGlobalUsage(StorageType type) { | 145 void GetGlobalUsage(StorageType type) { |
146 type_ = kStorageTypeUnknown; | 146 type_ = kStorageTypeUnknown; |
147 usage_ = -1; | 147 usage_ = -1; |
148 unlimited_usage_ = -1; | 148 unlimited_usage_ = -1; |
149 quota_manager_->GetGlobalUsage( | 149 quota_manager_->GetGlobalUsage( |
150 type, | 150 type, |
151 base::Bind(&QuotaManagerTest::DidGetGlobalUsage, | 151 base::Bind(&QuotaManagerTest::DidGetGlobalUsage, |
152 weak_factory_.GetWeakPtr())); | 152 weak_factory_.GetWeakPtr())); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 quota_status_ = status; | 301 quota_status_ = status; |
302 type_ = type; | 302 type_ = type; |
303 quota_ = quota; | 303 quota_ = quota; |
304 } | 304 } |
305 | 305 |
306 void DidGetAvailableSpace(QuotaStatusCode status, int64 available_space) { | 306 void DidGetAvailableSpace(QuotaStatusCode status, int64 available_space) { |
307 quota_status_ = status; | 307 quota_status_ = status; |
308 available_space_ = available_space; | 308 available_space_ = available_space; |
309 } | 309 } |
310 | 310 |
311 void DidGetHostQuota(QuotaStatusCode status, | 311 void DidGetHostQuota(const std::string& host, |
312 const std::string& host, | |
313 StorageType type, | 312 StorageType type, |
| 313 QuotaStatusCode status, |
314 int64 quota) { | 314 int64 quota) { |
315 quota_status_ = status; | |
316 host_ = host; | 315 host_ = host; |
317 type_ = type; | 316 type_ = type; |
| 317 quota_status_ = status; |
318 quota_ = quota; | 318 quota_ = quota; |
319 } | 319 } |
320 | 320 |
321 void DidGetGlobalUsage(StorageType type, int64 usage, | 321 void DidGetGlobalUsage(StorageType type, int64 usage, |
322 int64 unlimited_usage) { | 322 int64 unlimited_usage) { |
323 type_ = type; | 323 type_ = type; |
324 usage_ = usage; | 324 usage_ = usage; |
325 unlimited_usage_ = unlimited_usage; | 325 unlimited_usage_ = unlimited_usage; |
326 } | 326 } |
327 | 327 |
(...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2052 EXPECT_EQ(predelete_foo_tmp - 2 - 1, usage()); | 2052 EXPECT_EQ(predelete_foo_tmp - 2 - 1, usage()); |
2053 | 2053 |
2054 DeleteHostData("foo.com", kTemp, | 2054 DeleteHostData("foo.com", kTemp, |
2055 QuotaClient::kDatabase | QuotaClient::kIndexedDatabase); | 2055 QuotaClient::kDatabase | QuotaClient::kIndexedDatabase); |
2056 MessageLoop::current()->RunAllPending(); | 2056 MessageLoop::current()->RunAllPending(); |
2057 GetHostUsage("foo.com", kTemp); | 2057 GetHostUsage("foo.com", kTemp); |
2058 MessageLoop::current()->RunAllPending(); | 2058 MessageLoop::current()->RunAllPending(); |
2059 EXPECT_EQ(predelete_foo_tmp - 8 - 4 - 2 - 1, usage()); | 2059 EXPECT_EQ(predelete_foo_tmp - 8 - 4 - 2 - 1, usage()); |
2060 } | 2060 } |
2061 } // namespace quota | 2061 } // namespace quota |
OLD | NEW |