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

Side by Side Diff: content/browser/storage_partition_impl_unittest.cc

Issue 492873002: Collapse fileapi, webkit_blob, webkit_database, quota, and webkit_common namespaces into single sto… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos build Created 6 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/message_loop/message_loop_proxy.h" 6 #include "base/message_loop/message_loop_proxy.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/threading/thread.h" 8 #include "base/threading/thread.h"
9 #include "content/browser/browser_thread_impl.h" 9 #include "content/browser/browser_thread_impl.h"
10 #include "content/browser/gpu/shader_disk_cache.h" 10 #include "content/browser/gpu/shader_disk_cache.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 const base::FilePath::CharType kDomStorageOrigin1[] = 43 const base::FilePath::CharType kDomStorageOrigin1[] =
44 FILE_PATH_LITERAL("http_host1_1.localstorage"); 44 FILE_PATH_LITERAL("http_host1_1.localstorage");
45 45
46 const base::FilePath::CharType kDomStorageOrigin2[] = 46 const base::FilePath::CharType kDomStorageOrigin2[] =
47 FILE_PATH_LITERAL("http_host2_1.localstorage"); 47 FILE_PATH_LITERAL("http_host2_1.localstorage");
48 48
49 const base::FilePath::CharType kDomStorageOrigin3[] = 49 const base::FilePath::CharType kDomStorageOrigin3[] =
50 FILE_PATH_LITERAL("http_host3_1.localstorage"); 50 FILE_PATH_LITERAL("http_host3_1.localstorage");
51 51
52 const quota::StorageType kTemporary = quota::kStorageTypeTemporary; 52 const storage::StorageType kTemporary = storage::kStorageTypeTemporary;
53 const quota::StorageType kPersistent = quota::kStorageTypePersistent; 53 const storage::StorageType kPersistent = storage::kStorageTypePersistent;
54 54
55 const quota::QuotaClient::ID kClientFile = quota::QuotaClient::kFileSystem; 55 const storage::QuotaClient::ID kClientFile = storage::QuotaClient::kFileSystem;
56 56
57 const uint32 kAllQuotaRemoveMask = 57 const uint32 kAllQuotaRemoveMask =
58 StoragePartition::REMOVE_DATA_MASK_APPCACHE | 58 StoragePartition::REMOVE_DATA_MASK_APPCACHE |
59 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | 59 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS |
60 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB | 60 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB |
61 StoragePartition::REMOVE_DATA_MASK_WEBSQL; 61 StoragePartition::REMOVE_DATA_MASK_WEBSQL;
62 62
63 class AwaitCompletionHelper { 63 class AwaitCompletionHelper {
64 public: 64 public:
65 AwaitCompletionHelper() : start_(false), already_quit_(false) {} 65 AwaitCompletionHelper() : start_(false), already_quit_(false) {}
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 DISALLOW_COPY_AND_ASSIGN(RemoveLocalStorageTester); 219 DISALLOW_COPY_AND_ASSIGN(RemoveLocalStorageTester);
220 }; 220 };
221 221
222 bool IsWebSafeSchemeForTest(const std::string& scheme) { 222 bool IsWebSafeSchemeForTest(const std::string& scheme) {
223 return scheme == "http"; 223 return scheme == "http";
224 } 224 }
225 225
226 bool DoesOriginMatchForUnprotectedWeb( 226 bool DoesOriginMatchForUnprotectedWeb(
227 const GURL& origin, 227 const GURL& origin,
228 quota::SpecialStoragePolicy* special_storage_policy) { 228 storage::SpecialStoragePolicy* special_storage_policy) {
229 if (IsWebSafeSchemeForTest(origin.scheme())) 229 if (IsWebSafeSchemeForTest(origin.scheme()))
230 return !special_storage_policy->IsStorageProtected(origin.GetOrigin()); 230 return !special_storage_policy->IsStorageProtected(origin.GetOrigin());
231 231
232 return false; 232 return false;
233 } 233 }
234 234
235 bool DoesOriginMatchForBothProtectedAndUnprotectedWeb( 235 bool DoesOriginMatchForBothProtectedAndUnprotectedWeb(
236 const GURL& origin, 236 const GURL& origin,
237 quota::SpecialStoragePolicy* special_storage_policy) { 237 storage::SpecialStoragePolicy* special_storage_policy) {
238 return true; 238 return true;
239 } 239 }
240 240
241 bool DoesOriginMatchUnprotected( 241 bool DoesOriginMatchUnprotected(
242 const GURL& origin, 242 const GURL& origin,
243 quota::SpecialStoragePolicy* special_storage_policy) { 243 storage::SpecialStoragePolicy* special_storage_policy) {
244 return origin.GetOrigin().scheme() != kOriginDevTools.scheme(); 244 return origin.GetOrigin().scheme() != kOriginDevTools.scheme();
245 } 245 }
246 246
247 void ClearQuotaData(content::StoragePartition* partition, 247 void ClearQuotaData(content::StoragePartition* partition,
248 base::RunLoop* loop_to_quit) { 248 base::RunLoop* loop_to_quit) {
249 partition->ClearData(kAllQuotaRemoveMask, 249 partition->ClearData(kAllQuotaRemoveMask,
250 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, GURL(), 250 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, GURL(),
251 StoragePartition::OriginMatcherFunction(), base::Time(), 251 StoragePartition::OriginMatcherFunction(), base::Time(),
252 base::Time::Max(), loop_to_quit->QuitClosure()); 252 base::Time::Max(), loop_to_quit->QuitClosure());
253 } 253 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 base::MessageLoop::current()->PostTask( 406 base::MessageLoop::current()->PostTask(
407 FROM_HERE, base::Bind( 407 FROM_HERE, base::Bind(
408 &ClearData, 408 &ClearData,
409 BrowserContext::GetDefaultStoragePartition(browser_context()), 409 BrowserContext::GetDefaultStoragePartition(browser_context()),
410 &run_loop)); 410 &run_loop));
411 run_loop.Run(); 411 run_loop.Run();
412 EXPECT_EQ(0u, Size()); 412 EXPECT_EQ(0u, Size());
413 } 413 }
414 414
415 TEST_F(StoragePartitionImplTest, QuotaClientMaskGeneration) { 415 TEST_F(StoragePartitionImplTest, QuotaClientMaskGeneration) {
416 EXPECT_EQ(quota::QuotaClient::kFileSystem, 416 EXPECT_EQ(storage::QuotaClient::kFileSystem,
417 StoragePartitionImpl::GenerateQuotaClientMask( 417 StoragePartitionImpl::GenerateQuotaClientMask(
418 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS)); 418 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS));
419 EXPECT_EQ(quota::QuotaClient::kDatabase, 419 EXPECT_EQ(storage::QuotaClient::kDatabase,
420 StoragePartitionImpl::GenerateQuotaClientMask( 420 StoragePartitionImpl::GenerateQuotaClientMask(
421 StoragePartition::REMOVE_DATA_MASK_WEBSQL)); 421 StoragePartition::REMOVE_DATA_MASK_WEBSQL));
422 EXPECT_EQ(quota::QuotaClient::kAppcache, 422 EXPECT_EQ(storage::QuotaClient::kAppcache,
423 StoragePartitionImpl::GenerateQuotaClientMask( 423 StoragePartitionImpl::GenerateQuotaClientMask(
424 StoragePartition::REMOVE_DATA_MASK_APPCACHE)); 424 StoragePartition::REMOVE_DATA_MASK_APPCACHE));
425 EXPECT_EQ(quota::QuotaClient::kIndexedDatabase, 425 EXPECT_EQ(storage::QuotaClient::kIndexedDatabase,
426 StoragePartitionImpl::GenerateQuotaClientMask( 426 StoragePartitionImpl::GenerateQuotaClientMask(
427 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB)); 427 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB));
428 EXPECT_EQ(quota::QuotaClient::kFileSystem | 428 EXPECT_EQ(storage::QuotaClient::kFileSystem |
429 quota::QuotaClient::kDatabase | 429 storage::QuotaClient::kDatabase |
430 quota::QuotaClient::kAppcache | 430 storage::QuotaClient::kAppcache |
431 quota::QuotaClient::kIndexedDatabase, 431 storage::QuotaClient::kIndexedDatabase,
432 StoragePartitionImpl::GenerateQuotaClientMask(kAllQuotaRemoveMask)); 432 StoragePartitionImpl::GenerateQuotaClientMask(kAllQuotaRemoveMask));
433 } 433 }
434 434
435 void PopulateTestQuotaManagedPersistentData(MockQuotaManager* manager) { 435 void PopulateTestQuotaManagedPersistentData(MockQuotaManager* manager) {
436 manager->AddOrigin(kOrigin2, kPersistent, kClientFile, base::Time()); 436 manager->AddOrigin(kOrigin2, kPersistent, kClientFile, base::Time());
437 manager->AddOrigin(kOrigin3, kPersistent, kClientFile, 437 manager->AddOrigin(kOrigin3, kPersistent, kClientFile,
438 base::Time::Now() - base::TimeDelta::FromDays(1)); 438 base::Time::Now() - base::TimeDelta::FromDays(1));
439 439
440 EXPECT_FALSE(manager->OriginHasData(kOrigin1, kPersistent, kClientFile)); 440 EXPECT_FALSE(manager->OriginHasData(kOrigin1, kPersistent, kClientFile));
441 EXPECT_TRUE(manager->OriginHasData(kOrigin2, kPersistent, kClientFile)); 441 EXPECT_TRUE(manager->OriginHasData(kOrigin2, kPersistent, kClientFile));
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 &run_loop)); 921 &run_loop));
922 run_loop.Run(); 922 run_loop.Run();
923 923
924 // kOrigin1 and kOrigin2 do not have age more than a week. 924 // kOrigin1 and kOrigin2 do not have age more than a week.
925 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin1)); 925 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin1));
926 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2)); 926 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2));
927 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); 927 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3));
928 } 928 }
929 929
930 } // namespace content 930 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/storage_partition_impl_map.cc ('k') | content/child/fileapi/file_system_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698