| OLD | NEW |
| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 quota::StorageType kTemporary = quota::kStorageTypeTemporary; |
| 53 const quota::StorageType kPersistent = quota::kStorageTypePersistent; | 53 const quota::StorageType kPersistent = quota::kStorageTypePersistent; |
| 54 | 54 |
| 55 const quota::QuotaClient::ID kClientFile = quota::QuotaClient::kFileSystem; | 55 const quota::QuotaClient::ID kClientFile = quota::QuotaClient::kFileSystem; |
| 56 | 56 |
| 57 const uint32 kAllQuotaRemoveMask = | 57 const uint32 kAllQuotaRemoveMask = |
| 58 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 59 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 58 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB | | 60 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB | |
| 59 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 61 StoragePartition::REMOVE_DATA_MASK_WEBSQL; |
| 60 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | |
| 61 StoragePartition::REMOVE_DATA_MASK_APPCACHE; | |
| 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) {} |
| 66 virtual ~AwaitCompletionHelper() {} | 66 virtual ~AwaitCompletionHelper() {} |
| 67 | 67 |
| 68 void BlockUntilNotified() { | 68 void BlockUntilNotified() { |
| 69 if (!already_quit_) { | 69 if (!already_quit_) { |
| 70 DCHECK(!start_); | 70 DCHECK(!start_); |
| 71 start_ = true; | 71 start_ = true; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 quota::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( | 249 partition->ClearData(kAllQuotaRemoveMask, |
| 250 kAllQuotaRemoveMask, | 250 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, GURL(), |
| 251 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, | 251 StoragePartition::OriginMatcherFunction(), base::Time(), |
| 252 GURL(), StoragePartition::OriginMatcherFunction(), | 252 base::Time::Max(), loop_to_quit->QuitClosure()); |
| 253 base::Time(), base::Time::Max(), loop_to_quit->QuitClosure()); | |
| 254 } | 253 } |
| 255 | 254 |
| 256 void ClearQuotaDataWithOriginMatcher( | 255 void ClearQuotaDataWithOriginMatcher( |
| 257 content::StoragePartition* partition, | 256 content::StoragePartition* partition, |
| 258 const GURL& remove_origin, | 257 const GURL& remove_origin, |
| 259 const StoragePartition::OriginMatcherFunction& origin_matcher, | 258 const StoragePartition::OriginMatcherFunction& origin_matcher, |
| 260 const base::Time delete_begin, | 259 const base::Time delete_begin, |
| 261 base::RunLoop* loop_to_quit) { | 260 base::RunLoop* loop_to_quit) { |
| 262 partition->ClearData(kAllQuotaRemoveMask, | 261 partition->ClearData(kAllQuotaRemoveMask, |
| 263 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, | 262 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, |
| 264 remove_origin, origin_matcher, delete_begin, | 263 remove_origin, origin_matcher, delete_begin, |
| 265 base::Time::Max(), loop_to_quit->QuitClosure()); | 264 base::Time::Max(), loop_to_quit->QuitClosure()); |
| 266 } | 265 } |
| 267 | 266 |
| 268 void ClearQuotaDataForOrigin( | 267 void ClearQuotaDataForOrigin( |
| 269 content::StoragePartition* partition, | 268 content::StoragePartition* partition, |
| 270 const GURL& remove_origin, | 269 const GURL& remove_origin, |
| 271 const base::Time delete_begin, | 270 const base::Time delete_begin, |
| 272 base::RunLoop* loop_to_quit) { | 271 base::RunLoop* loop_to_quit) { |
| 273 ClearQuotaDataWithOriginMatcher( | 272 ClearQuotaDataWithOriginMatcher( |
| 274 partition, remove_origin, | 273 partition, remove_origin, |
| 275 StoragePartition::OriginMatcherFunction(), delete_begin, | 274 StoragePartition::OriginMatcherFunction(), delete_begin, |
| 276 loop_to_quit); | 275 loop_to_quit); |
| 277 } | 276 } |
| 278 | 277 |
| 279 void ClearQuotaDataForNonPersistent( | 278 void ClearQuotaDataForNonPersistent( |
| 280 content::StoragePartition* partition, | 279 content::StoragePartition* partition, |
| 281 const base::Time delete_begin, | 280 const base::Time delete_begin, |
| 282 base::RunLoop* loop_to_quit) { | 281 base::RunLoop* loop_to_quit) { |
| 283 uint32 quota_storage_remove_mask_no_persistent = | |
| 284 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL & | |
| 285 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | |
| 286 partition->ClearData( | 282 partition->ClearData( |
| 287 kAllQuotaRemoveMask, quota_storage_remove_mask_no_persistent, | 283 kAllQuotaRemoveMask, |
| 288 GURL(), StoragePartition::OriginMatcherFunction(), | 284 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT, |
| 289 delete_begin, base::Time::Max(), loop_to_quit->QuitClosure()); | 285 GURL(), StoragePartition::OriginMatcherFunction(), delete_begin, |
| 286 base::Time::Max(), loop_to_quit->QuitClosure()); |
| 290 } | 287 } |
| 291 | 288 |
| 292 void ClearCookies(content::StoragePartition* partition, | 289 void ClearCookies(content::StoragePartition* partition, |
| 293 const base::Time delete_begin, | 290 const base::Time delete_begin, |
| 294 const base::Time delete_end, | 291 const base::Time delete_end, |
| 295 base::RunLoop* run_loop) { | 292 base::RunLoop* run_loop) { |
| 296 partition->ClearData( | 293 partition->ClearData( |
| 297 StoragePartition::REMOVE_DATA_MASK_COOKIES, | 294 StoragePartition::REMOVE_DATA_MASK_COOKIES, |
| 298 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, | 295 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, |
| 299 GURL(), StoragePartition::OriginMatcherFunction(), | 296 GURL(), StoragePartition::OriginMatcherFunction(), |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 EXPECT_EQ(quota::QuotaClient::kAppcache, | 422 EXPECT_EQ(quota::QuotaClient::kAppcache, |
| 426 StoragePartitionImpl::GenerateQuotaClientMask( | 423 StoragePartitionImpl::GenerateQuotaClientMask( |
| 427 StoragePartition::REMOVE_DATA_MASK_APPCACHE)); | 424 StoragePartition::REMOVE_DATA_MASK_APPCACHE)); |
| 428 EXPECT_EQ(quota::QuotaClient::kIndexedDatabase, | 425 EXPECT_EQ(quota::QuotaClient::kIndexedDatabase, |
| 429 StoragePartitionImpl::GenerateQuotaClientMask( | 426 StoragePartitionImpl::GenerateQuotaClientMask( |
| 430 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB)); | 427 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB)); |
| 431 EXPECT_EQ(quota::QuotaClient::kFileSystem | | 428 EXPECT_EQ(quota::QuotaClient::kFileSystem | |
| 432 quota::QuotaClient::kDatabase | | 429 quota::QuotaClient::kDatabase | |
| 433 quota::QuotaClient::kAppcache | | 430 quota::QuotaClient::kAppcache | |
| 434 quota::QuotaClient::kIndexedDatabase, | 431 quota::QuotaClient::kIndexedDatabase, |
| 435 StoragePartitionImpl::GenerateQuotaClientMask( | 432 StoragePartitionImpl::GenerateQuotaClientMask(kAllQuotaRemoveMask)); |
| 436 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | |
| 437 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | |
| 438 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | |
| 439 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB)); | |
| 440 } | 433 } |
| 441 | 434 |
| 442 void PopulateTestQuotaManagedPersistentData(MockQuotaManager* manager) { | 435 void PopulateTestQuotaManagedPersistentData(MockQuotaManager* manager) { |
| 443 manager->AddOrigin(kOrigin2, kPersistent, kClientFile, base::Time()); | 436 manager->AddOrigin(kOrigin2, kPersistent, kClientFile, base::Time()); |
| 444 manager->AddOrigin(kOrigin3, kPersistent, kClientFile, | 437 manager->AddOrigin(kOrigin3, kPersistent, kClientFile, |
| 445 base::Time::Now() - base::TimeDelta::FromDays(1)); | 438 base::Time::Now() - base::TimeDelta::FromDays(1)); |
| 446 | 439 |
| 447 EXPECT_FALSE(manager->OriginHasData(kOrigin1, kPersistent, kClientFile)); | 440 EXPECT_FALSE(manager->OriginHasData(kOrigin1, kPersistent, kClientFile)); |
| 448 EXPECT_TRUE(manager->OriginHasData(kOrigin2, kPersistent, kClientFile)); | 441 EXPECT_TRUE(manager->OriginHasData(kOrigin2, kPersistent, kClientFile)); |
| 449 EXPECT_TRUE(manager->OriginHasData(kOrigin3, kPersistent, kClientFile)); | 442 EXPECT_TRUE(manager->OriginHasData(kOrigin3, kPersistent, kClientFile)); |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 &run_loop)); | 921 &run_loop)); |
| 929 run_loop.Run(); | 922 run_loop.Run(); |
| 930 | 923 |
| 931 // kOrigin1 and kOrigin2 do not have age more than a week. | 924 // kOrigin1 and kOrigin2 do not have age more than a week. |
| 932 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin1)); | 925 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 933 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2)); | 926 EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 934 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); | 927 EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 935 } | 928 } |
| 936 | 929 |
| 937 } // namespace content | 930 } // namespace content |
| OLD | NEW |