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

Side by Side Diff: webkit/quota/quota_manager_unittest.cc

Issue 7168019: Implement QM::GetOriginsModifiedSince for browser data deleter support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes + upgradeschema Created 9 years, 6 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 | Annotate | Revision Log
OLDNEW
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 <set>
5 #include <sstream> 6 #include <sstream>
6 #include <vector> 7 #include <vector>
7 8
8 #include "base/file_util.h" 9 #include "base/file_util.h"
9 #include "base/memory/scoped_callback_factory.h" 10 #include "base/memory/scoped_callback_factory.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop.h" 12 #include "base/message_loop.h"
12 #include "base/message_loop_proxy.h" 13 #include "base/message_loop_proxy.h"
13 #include "base/scoped_temp_dir.h" 14 #include "base/scoped_temp_dir.h"
14 #include "base/stl_util-inl.h" 15 #include "base/stl_util-inl.h"
(...skipping 15 matching lines...) Expand all
30 namespace quota { 31 namespace quota {
31 32
32 // For shorter names. 33 // For shorter names.
33 const StorageType kTemp = kStorageTypeTemporary; 34 const StorageType kTemp = kStorageTypeTemporary;
34 const StorageType kPerm = kStorageTypePersistent; 35 const StorageType kPerm = kStorageTypePersistent;
35 36
36 class QuotaManagerTest : public testing::Test { 37 class QuotaManagerTest : public testing::Test {
37 protected: 38 protected:
38 typedef QuotaManager::QuotaTableEntry QuotaTableEntry; 39 typedef QuotaManager::QuotaTableEntry QuotaTableEntry;
39 typedef QuotaManager::QuotaTableEntries QuotaTableEntries; 40 typedef QuotaManager::QuotaTableEntries QuotaTableEntries;
40 typedef QuotaManager::LastAccessTimeTableEntry LastAccessTimeTableEntry; 41 typedef QuotaManager::OriginInfoTableEntry OriginInfoTableEntry;
41 typedef QuotaManager::LastAccessTimeTableEntries LastAccessTimeTableEntries; 42 typedef QuotaManager::OriginInfoTableEntries OriginInfoTableEntries;
42 43
43 public: 44 public:
44 QuotaManagerTest() 45 QuotaManagerTest()
45 : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 46 : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
46 virtual_time_counter_(0) { 47 virtual_time_counter_(0) {
47 } 48 }
48 49
49 void SetUp() { 50 void SetUp() {
50 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); 51 ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
51 mock_special_storage_policy_ = new MockSpecialStoragePolicy; 52 mock_special_storage_policy_ = new MockSpecialStoragePolicy;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 } 209 }
209 210
210 void NotifyOriginInUse(const GURL& origin) { 211 void NotifyOriginInUse(const GURL& origin) {
211 quota_manager_->NotifyOriginInUse(origin); 212 quota_manager_->NotifyOriginInUse(origin);
212 } 213 }
213 214
214 void NotifyOriginNoLongerInUse(const GURL& origin) { 215 void NotifyOriginNoLongerInUse(const GURL& origin) {
215 quota_manager_->NotifyOriginNoLongerInUse(origin); 216 quota_manager_->NotifyOriginNoLongerInUse(origin);
216 } 217 }
217 218
219 void GetOriginsModifiedSince(StorageType type, base::Time modified_since) {
220 modified_origins_.clear();
221 quota_manager_->GetOriginsModifiedSince(type, modified_since,
222 callback_factory_.NewCallback(
223 &QuotaManagerTest::DidGetModifiedOrigins));
224 }
225
218 void DumpQuotaTable() { 226 void DumpQuotaTable() {
219 quota_table_.clear(); 227 quota_table_.clear();
220 quota_manager_->DumpQuotaTable( 228 quota_manager_->DumpQuotaTable(
221 callback_factory_.NewCallback( 229 callback_factory_.NewCallback(
222 &QuotaManagerTest::DidDumpQuotaTable)); 230 &QuotaManagerTest::DidDumpQuotaTable));
223 } 231 }
224 232
225 void DumpLastAccessTimeTable() { 233 void DumpOriginInfoTable() {
226 last_access_time_table_.clear(); 234 last_access_time_table_.clear();
227 quota_manager_->DumpLastAccessTimeTable( 235 quota_manager_->DumpOriginInfoTable(
228 callback_factory_.NewCallback( 236 callback_factory_.NewCallback(
229 &QuotaManagerTest::DidDumpLastAccessTimeTable)); 237 &QuotaManagerTest::DidDumpOriginInfoTable));
230 } 238 }
231 239
232 void DidGetUsageAndQuota(QuotaStatusCode status, int64 usage, int64 quota) { 240 void DidGetUsageAndQuota(QuotaStatusCode status, int64 usage, int64 quota) {
233 quota_status_ = status; 241 quota_status_ = status;
234 usage_ = usage; 242 usage_ = usage;
235 quota_ = quota; 243 quota_ = quota;
236 } 244 }
237 245
238 void DidGetQuota(QuotaStatusCode status, 246 void DidGetQuota(QuotaStatusCode status,
239 StorageType type, 247 StorageType type,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 usage_ = usage; 295 usage_ = usage;
288 unlimited_usage_ = unlimited_usage; 296 unlimited_usage_ = unlimited_usage;
289 quota_ = quota; 297 quota_ = quota;
290 available_space_ = available_space; 298 available_space_ = available_space;
291 } 299 }
292 300
293 void DidGetLRUOrigin(const GURL& origin) { 301 void DidGetLRUOrigin(const GURL& origin) {
294 lru_origin_ = origin; 302 lru_origin_ = origin;
295 } 303 }
296 304
305 void DidGetModifiedOrigins(const std::set<GURL>& origins) {
306 modified_origins_.insert(origins.begin(), origins.end());
michaeln 2011/07/01 00:17:39 would an assignment work here?
kinuko 2011/07/04 07:43:52 Done.
307 }
308
297 void DidDumpQuotaTable(const QuotaTableEntries& entries) { 309 void DidDumpQuotaTable(const QuotaTableEntries& entries) {
298 quota_table_ = entries; 310 quota_table_ = entries;
299 } 311 }
300 312
301 void DidDumpLastAccessTimeTable(const LastAccessTimeTableEntries& entries) { 313 void DidDumpOriginInfoTable(const OriginInfoTableEntries& entries) {
302 last_access_time_table_ = entries; 314 last_access_time_table_ = entries;
303 } 315 }
304 316
305 void GetUsage_WithModifyTestBody(const StorageType type); 317 void GetUsage_WithModifyTestBody(const StorageType type);
306 318
307 void set_additional_callback_count(int c) { additional_callback_count_ = c; } 319 void set_additional_callback_count(int c) { additional_callback_count_ = c; }
308 int additional_callback_count() const { return additional_callback_count_; } 320 int additional_callback_count() const { return additional_callback_count_; }
309 void DidGetUsageAndQuotaAdditional( 321 void DidGetUsageAndQuotaAdditional(
310 QuotaStatusCode status, int64 usage, int64 quota) { 322 QuotaStatusCode status, int64 usage, int64 quota) {
311 ++additional_callback_count_; 323 ++additional_callback_count_;
312 } 324 }
313 325
314 QuotaManager* quota_manager() const { return quota_manager_.get(); } 326 QuotaManager* quota_manager() const { return quota_manager_.get(); }
315 void set_quota_manager(QuotaManager* quota_manager) { 327 void set_quota_manager(QuotaManager* quota_manager) {
316 quota_manager_ = quota_manager; 328 quota_manager_ = quota_manager;
317 } 329 }
318 330
319 MockSpecialStoragePolicy* mock_special_storage_policy() const { 331 MockSpecialStoragePolicy* mock_special_storage_policy() const {
320 return mock_special_storage_policy_.get(); 332 return mock_special_storage_policy_.get();
321 } 333 }
322 334
323 QuotaStatusCode status() const { return quota_status_; } 335 QuotaStatusCode status() const { return quota_status_; }
324 const std::string& host() const { return host_; } 336 const std::string& host() const { return host_; }
325 StorageType type() const { return type_; } 337 StorageType type() const { return type_; }
326 int64 usage() const { return usage_; } 338 int64 usage() const { return usage_; }
327 int64 unlimited_usage() const { return unlimited_usage_; } 339 int64 unlimited_usage() const { return unlimited_usage_; }
328 int64 quota() const { return quota_; } 340 int64 quota() const { return quota_; }
329 int64 available_space() const { return available_space_; } 341 int64 available_space() const { return available_space_; }
330 const GURL& lru_origin() const { return lru_origin_; } 342 const GURL& lru_origin() const { return lru_origin_; }
343 const std::set<GURL>& modified_origins() const { return modified_origins_; }
331 const QuotaTableEntries& quota_table() const { return quota_table_; } 344 const QuotaTableEntries& quota_table() const { return quota_table_; }
332 const LastAccessTimeTableEntries& last_access_time_table() const { 345 const OriginInfoTableEntries& last_access_time_table() const {
333 return last_access_time_table_; 346 return last_access_time_table_;
334 } 347 }
335 FilePath profile_path() const { return data_dir_.path(); } 348 FilePath profile_path() const { return data_dir_.path(); }
336 349
337 private: 350 private:
338 base::Time GetCurrentMockTime() { 351 base::Time GetCurrentMockTime() {
339 ++virtual_time_counter_; 352 ++virtual_time_counter_;
340 return base::Time::FromDoubleT(virtual_time_counter_ * 10.0); 353 return base::Time::FromDoubleT(virtual_time_counter_ * 10.0);
341 } 354 }
342 355
343 ScopedTempDir data_dir_; 356 ScopedTempDir data_dir_;
344 base::ScopedCallbackFactory<QuotaManagerTest> callback_factory_; 357 base::ScopedCallbackFactory<QuotaManagerTest> callback_factory_;
345 358
346 scoped_refptr<QuotaManager> quota_manager_; 359 scoped_refptr<QuotaManager> quota_manager_;
347 scoped_refptr<MockSpecialStoragePolicy> mock_special_storage_policy_; 360 scoped_refptr<MockSpecialStoragePolicy> mock_special_storage_policy_;
348 361
349 QuotaStatusCode quota_status_; 362 QuotaStatusCode quota_status_;
350 std::string host_; 363 std::string host_;
351 StorageType type_; 364 StorageType type_;
352 int64 usage_; 365 int64 usage_;
353 int64 unlimited_usage_; 366 int64 unlimited_usage_;
354 int64 quota_; 367 int64 quota_;
355 int64 available_space_; 368 int64 available_space_;
356 GURL lru_origin_; 369 GURL lru_origin_;
370 std::set<GURL> modified_origins_;
357 QuotaTableEntries quota_table_; 371 QuotaTableEntries quota_table_;
358 LastAccessTimeTableEntries last_access_time_table_; 372 OriginInfoTableEntries last_access_time_table_;
359 373
360 int additional_callback_count_; 374 int additional_callback_count_;
361 375
362 int virtual_time_counter_; 376 int virtual_time_counter_;
363 377
364 DISALLOW_COPY_AND_ASSIGN(QuotaManagerTest); 378 DISALLOW_COPY_AND_ASSIGN(QuotaManagerTest);
365 }; 379 };
366 380
367 TEST_F(QuotaManagerTest, GetUsageAndQuota_Simple) { 381 TEST_F(QuotaManagerTest, GetUsageAndQuota_Simple) {
368 static const MockOriginData kData[] = { 382 static const MockOriginData kData[] = {
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 quota_manager()->NotifyStorageAccessed(QuotaClient::kMockStart, 1047 quota_manager()->NotifyStorageAccessed(QuotaClient::kMockStart,
1034 GURL(kData1[i].origin), kData1[i].type); 1048 GURL(kData1[i].origin), kData1[i].type);
1035 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData2); ++i) 1049 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData2); ++i)
1036 quota_manager()->NotifyStorageAccessed(QuotaClient::kMockStart, 1050 quota_manager()->NotifyStorageAccessed(QuotaClient::kMockStart,
1037 GURL(kData2[i].origin), kData2[i].type); 1051 GURL(kData2[i].origin), kData2[i].type);
1038 MessageLoop::current()->RunAllPending(); 1052 MessageLoop::current()->RunAllPending();
1039 1053
1040 EvictOriginData(GURL("http://foo.com/"), kTemp); 1054 EvictOriginData(GURL("http://foo.com/"), kTemp);
1041 MessageLoop::current()->RunAllPending(); 1055 MessageLoop::current()->RunAllPending();
1042 1056
1043 DumpLastAccessTimeTable(); 1057 DumpOriginInfoTable();
1044 MessageLoop::current()->RunAllPending(); 1058 MessageLoop::current()->RunAllPending();
1045 1059
1046 typedef LastAccessTimeTableEntries::const_iterator iterator; 1060 typedef OriginInfoTableEntries::const_iterator iterator;
1047 for (iterator itr(last_access_time_table().begin()), 1061 for (iterator itr(last_access_time_table().begin()),
1048 end(last_access_time_table().end()); 1062 end(last_access_time_table().end());
1049 itr != end; ++itr) { 1063 itr != end; ++itr) {
1050 if (itr->type == kTemp) 1064 if (itr->type == kTemp)
1051 EXPECT_NE(std::string("http://foo.com/"), itr->origin.spec()); 1065 EXPECT_NE(std::string("http://foo.com/"), itr->origin.spec());
1052 } 1066 }
1053 1067
1054 GetGlobalUsage(kTemp); 1068 GetGlobalUsage(kTemp);
1055 MessageLoop::current()->RunAllPending(); 1069 MessageLoop::current()->RunAllPending();
1056 EXPECT_EQ(predelete_global_tmp - (1 + 50000), usage()); 1070 EXPECT_EQ(predelete_global_tmp - (1 + 50000), usage());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 client->AddOriginToErrorSet(GURL("http://foo.com/"), kTemp); 1108 client->AddOriginToErrorSet(GURL("http://foo.com/"), kTemp);
1095 1109
1096 for (int i = 0; 1110 for (int i = 0;
1097 i < QuotaManager::kThresholdOfErrorsToBeBlacklisted + 1; 1111 i < QuotaManager::kThresholdOfErrorsToBeBlacklisted + 1;
1098 ++i) { 1112 ++i) {
1099 EvictOriginData(GURL("http://foo.com/"), kTemp); 1113 EvictOriginData(GURL("http://foo.com/"), kTemp);
1100 MessageLoop::current()->RunAllPending(); 1114 MessageLoop::current()->RunAllPending();
1101 EXPECT_EQ(kQuotaErrorInvalidModification, status()); 1115 EXPECT_EQ(kQuotaErrorInvalidModification, status());
1102 } 1116 }
1103 1117
1104 DumpLastAccessTimeTable(); 1118 DumpOriginInfoTable();
1105 MessageLoop::current()->RunAllPending(); 1119 MessageLoop::current()->RunAllPending();
1106 1120
1107 bool found_origin_in_database = false; 1121 bool found_origin_in_database = false;
1108 typedef LastAccessTimeTableEntries::const_iterator iterator; 1122 typedef OriginInfoTableEntries::const_iterator iterator;
1109 for (iterator itr(last_access_time_table().begin()), 1123 for (iterator itr(last_access_time_table().begin()),
1110 end(last_access_time_table().end()); 1124 end(last_access_time_table().end());
1111 itr != end; ++itr) { 1125 itr != end; ++itr) {
1112 if (itr->type == kTemp && 1126 if (itr->type == kTemp &&
1113 GURL("http://foo.com/") == itr->origin) { 1127 GURL("http://foo.com/") == itr->origin) {
1114 found_origin_in_database = true; 1128 found_origin_in_database = true;
1115 break; 1129 break;
1116 } 1130 }
1117 } 1131 }
1118 // The origin "http://foo.com/" should be in the database. 1132 // The origin "http://foo.com/" should be in the database.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 // see empty result here. 1313 // see empty result here.
1300 EXPECT_TRUE(lru_origin().is_empty()); 1314 EXPECT_TRUE(lru_origin().is_empty());
1301 1315
1302 NotifyOriginNoLongerInUse(GURL("http://a.com/")); 1316 NotifyOriginNoLongerInUse(GURL("http://a.com/"));
1303 NotifyOriginNoLongerInUse(GURL("https://a.com/")); 1317 NotifyOriginNoLongerInUse(GURL("https://a.com/"));
1304 GetLRUOrigin(kTemp); 1318 GetLRUOrigin(kTemp);
1305 MessageLoop::current()->RunAllPending(); 1319 MessageLoop::current()->RunAllPending();
1306 EXPECT_EQ("http://a.com/", lru_origin().spec()); 1320 EXPECT_EQ("http://a.com/", lru_origin().spec());
1307 } 1321 }
1308 1322
1323 TEST_F(QuotaManagerTest, GetOriginsModifiedSince) {
1324 static const MockOriginData kData[] = {
1325 { "http://a.com/", kTemp, 0 },
1326 { "http://a.com:1/", kTemp, 0 },
1327 { "https://a.com/", kTemp, 0 },
1328 { "http://b.com/", kPerm, 0 }, // persistent
1329 { "http://c.com/", kTemp, 0 },
1330 };
1331 MockStorageClient* client = CreateClient(kData, ARRAYSIZE_UNSAFE(kData));
1332 RegisterClient(client);
1333
1334 GetOriginsModifiedSince(kTemp, base::Time());
1335 MessageLoop::current()->RunAllPending();
1336 EXPECT_TRUE(modified_origins().empty());
1337
1338 base::Time time1 = client->GetCurrentMockTime();
1339 client->ModifyOriginAndNotify(GURL("http://a.com/"), kTemp, 10);
1340 client->ModifyOriginAndNotify(GURL("http://a.com:1/"), kTemp, 10);
michaeln 2011/07/01 00:17:39 maybe modify the kPerm origin here to ensure it do
kinuko 2011/07/04 07:43:52 Done.
1341 base::Time time2 = client->GetCurrentMockTime();
1342 client->ModifyOriginAndNotify(GURL("https://a.com/"), kTemp, 10);
1343 client->ModifyOriginAndNotify(GURL("http://c.com/"), kTemp, 10);
1344 base::Time time3 = client->GetCurrentMockTime();
1345
1346 GetOriginsModifiedSince(kTemp, time1);
1347 MessageLoop::current()->RunAllPending();
1348 EXPECT_EQ(4U, modified_origins().size());
1349 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kData); ++i) {
1350 if (kData[i].type == kTemp)
1351 EXPECT_EQ(1U, modified_origins().count(GURL(kData[i].origin)));
1352 }
1353
1354 GetOriginsModifiedSince(kTemp, time2);
1355 MessageLoop::current()->RunAllPending();
1356 EXPECT_EQ(2U, modified_origins().size());
1357
1358 GetOriginsModifiedSince(kTemp, time3);
1359 MessageLoop::current()->RunAllPending();
1360 EXPECT_TRUE(modified_origins().empty());
1361
1362 client->ModifyOriginAndNotify(GURL("http://a.com/"), kTemp, 10);
1363
1364 GetOriginsModifiedSince(kTemp, time3);
1365 MessageLoop::current()->RunAllPending();
1366 EXPECT_EQ(1U, modified_origins().size());
1367 EXPECT_EQ(1U, modified_origins().count(GURL("http://a.com/")));
1368 }
1369
1309 TEST_F(QuotaManagerTest, DumpQuotaTable) { 1370 TEST_F(QuotaManagerTest, DumpQuotaTable) {
1310 SetPersistentHostQuota("example1.com", 1); 1371 SetPersistentHostQuota("example1.com", 1);
1311 SetPersistentHostQuota("example2.com", 20); 1372 SetPersistentHostQuota("example2.com", 20);
1312 SetPersistentHostQuota("example3.com", 300); 1373 SetPersistentHostQuota("example3.com", 300);
1313 MessageLoop::current()->RunAllPending(); 1374 MessageLoop::current()->RunAllPending();
1314 1375
1315 DumpQuotaTable(); 1376 DumpQuotaTable();
1316 MessageLoop::current()->RunAllPending(); 1377 MessageLoop::current()->RunAllPending();
1317 1378
1318 const QuotaTableEntry kEntries[] = { 1379 const QuotaTableEntry kEntries[] = {
1319 {"example1.com", kPerm, 1}, 1380 {"example1.com", kPerm, 1},
1320 {"example2.com", kPerm, 20}, 1381 {"example2.com", kPerm, 20},
1321 {"example3.com", kPerm, 300}, 1382 {"example3.com", kPerm, 300},
1322 }; 1383 };
1323 std::set<QuotaTableEntry> entries 1384 std::set<QuotaTableEntry> entries
1324 (kEntries, kEntries + ARRAYSIZE_UNSAFE(kEntries)); 1385 (kEntries, kEntries + ARRAYSIZE_UNSAFE(kEntries));
1325 1386
1326 typedef QuotaTableEntries::const_iterator iterator; 1387 typedef QuotaTableEntries::const_iterator iterator;
1327 for (iterator itr(quota_table().begin()), end(quota_table().end()); 1388 for (iterator itr(quota_table().begin()), end(quota_table().end());
1328 itr != end; ++itr) { 1389 itr != end; ++itr) {
1329 SCOPED_TRACE(testing::Message() 1390 SCOPED_TRACE(testing::Message()
1330 << "host = " << itr->host << ", " 1391 << "host = " << itr->host << ", "
1331 << "quota = " << itr->quota); 1392 << "quota = " << itr->quota);
1332 EXPECT_EQ(1u, entries.erase(*itr)); 1393 EXPECT_EQ(1u, entries.erase(*itr));
1333 } 1394 }
1334 EXPECT_TRUE(entries.empty()); 1395 EXPECT_TRUE(entries.empty());
1335 } 1396 }
1336 1397
1337 TEST_F(QuotaManagerTest, DumpLastAccessTimeTable) { 1398 TEST_F(QuotaManagerTest, DumpOriginInfoTable) {
1338 using std::make_pair; 1399 using std::make_pair;
1339 1400
1340 quota_manager()->NotifyStorageAccessed( 1401 quota_manager()->NotifyStorageAccessed(
1341 QuotaClient::kMockStart, 1402 QuotaClient::kMockStart,
1342 GURL("http://example.com/"), 1403 GURL("http://example.com/"),
1343 kTemp); 1404 kTemp);
1344 quota_manager()->NotifyStorageAccessed( 1405 quota_manager()->NotifyStorageAccessed(
1345 QuotaClient::kMockStart, 1406 QuotaClient::kMockStart,
1346 GURL("http://example.com/"), 1407 GURL("http://example.com/"),
1347 kPerm); 1408 kPerm);
1348 quota_manager()->NotifyStorageAccessed( 1409 quota_manager()->NotifyStorageAccessed(
1349 QuotaClient::kMockStart, 1410 QuotaClient::kMockStart,
1350 GURL("http://example.com/"), 1411 GURL("http://example.com/"),
1351 kPerm); 1412 kPerm);
1352 MessageLoop::current()->RunAllPending(); 1413 MessageLoop::current()->RunAllPending();
1353 1414
1354 DumpLastAccessTimeTable(); 1415 DumpOriginInfoTable();
1355 MessageLoop::current()->RunAllPending(); 1416 MessageLoop::current()->RunAllPending();
1356 1417
1357 typedef std::pair<GURL, StorageType> TypedOrigin; 1418 typedef std::pair<GURL, StorageType> TypedOrigin;
1358 typedef std::pair<TypedOrigin, int> Entry; 1419 typedef std::pair<TypedOrigin, int> Entry;
1359 const Entry kEntries[] = { 1420 const Entry kEntries[] = {
1360 make_pair(make_pair(GURL("http://example.com/"), kTemp), 1), 1421 make_pair(make_pair(GURL("http://example.com/"), kTemp), 1),
1361 make_pair(make_pair(GURL("http://example.com/"), kPerm), 2), 1422 make_pair(make_pair(GURL("http://example.com/"), kPerm), 2),
1362 }; 1423 };
1363 std::set<Entry> entries 1424 std::set<Entry> entries
1364 (kEntries, kEntries + ARRAYSIZE_UNSAFE(kEntries)); 1425 (kEntries, kEntries + ARRAYSIZE_UNSAFE(kEntries));
1365 1426
1366 typedef LastAccessTimeTableEntries::const_iterator iterator; 1427 typedef OriginInfoTableEntries::const_iterator iterator;
1367 for (iterator itr(last_access_time_table().begin()), 1428 for (iterator itr(last_access_time_table().begin()),
1368 end(last_access_time_table().end()); 1429 end(last_access_time_table().end());
1369 itr != end; ++itr) { 1430 itr != end; ++itr) {
1370 SCOPED_TRACE(testing::Message() 1431 SCOPED_TRACE(testing::Message()
1371 << "host = " << itr->origin << ", " 1432 << "host = " << itr->origin << ", "
1372 << "type = " << itr->type << ", " 1433 << "type = " << itr->type << ", "
1373 << "used_count = " << itr->used_count); 1434 << "used_count = " << itr->used_count);
1374 EXPECT_EQ(1u, entries.erase( 1435 EXPECT_EQ(1u, entries.erase(
1375 make_pair(make_pair(itr->origin, itr->type), 1436 make_pair(make_pair(itr->origin, itr->type),
1376 itr->used_count))); 1437 itr->used_count)));
1377 } 1438 }
1378 EXPECT_TRUE(entries.empty()); 1439 EXPECT_TRUE(entries.empty());
1379 } 1440 }
1380 1441
1381 TEST_F(QuotaManagerTest, QuotaForEmptyHost) { 1442 TEST_F(QuotaManagerTest, QuotaForEmptyHost) {
1382 GetPersistentHostQuota(std::string()); 1443 GetPersistentHostQuota(std::string());
1383 MessageLoop::current()->RunAllPending(); 1444 MessageLoop::current()->RunAllPending();
1384 EXPECT_EQ(kQuotaStatusOk, status()); 1445 EXPECT_EQ(kQuotaStatusOk, status());
1385 EXPECT_EQ(0, quota()); 1446 EXPECT_EQ(0, quota());
1386 1447
1387 SetPersistentHostQuota(std::string(), 10); 1448 SetPersistentHostQuota(std::string(), 10);
1388 MessageLoop::current()->RunAllPending(); 1449 MessageLoop::current()->RunAllPending();
1389 EXPECT_EQ(kQuotaErrorNotSupported, status()); 1450 EXPECT_EQ(kQuotaErrorNotSupported, status());
1390 } 1451 }
1391 } // namespace quota 1452 } // namespace quota
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698