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 "content/browser/storage_partition_impl.h" | 5 #include "content/browser/storage_partition_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 end, | 66 end, |
67 base::Bind(&OnClearedCookies, callback)); | 67 base::Bind(&OnClearedCookies, callback)); |
68 } else { | 68 } else { |
69 cookie_store->DeleteAllCreatedBetweenForHostAsync( | 69 cookie_store->DeleteAllCreatedBetweenForHostAsync( |
70 begin, | 70 begin, |
71 end, | 71 end, |
72 storage_origin, base::Bind(&OnClearedCookies, callback)); | 72 storage_origin, base::Bind(&OnClearedCookies, callback)); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
| 76 void ClearCookiesOnIOThreadWithCookieMatcher( |
| 77 const scoped_refptr<net::URLRequestContextGetter>& rq_context, |
| 78 const base::Time begin, |
| 79 const base::Time end, |
| 80 const StoragePartition::CookieMatcherFunction& cookie_matcher, |
| 81 const base::Closure& callback) { |
| 82 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 83 net::CookieStore* cookie_store = |
| 84 rq_context->GetURLRequestContext()->cookie_store(); |
| 85 if (cookie_matcher.is_null()) { |
| 86 cookie_store->DeleteAllCreatedBetweenAsync( |
| 87 begin, end, base::Bind(&OnClearedCookies, callback)); |
| 88 } else { |
| 89 cookie_store->DeleteAllCreatedBetweenWithPredicateAsync( |
| 90 begin, end, cookie_matcher, base::Bind(&OnClearedCookies, callback)); |
| 91 } |
| 92 } |
| 93 |
76 void CheckQuotaManagedDataDeletionStatus(size_t* deletion_task_count, | 94 void CheckQuotaManagedDataDeletionStatus(size_t* deletion_task_count, |
77 const base::Closure& callback) { | 95 const base::Closure& callback) { |
78 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 96 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
79 if (*deletion_task_count == 0) { | 97 if (*deletion_task_count == 0) { |
80 delete deletion_task_count; | 98 delete deletion_task_count; |
81 callback.Run(); | 99 callback.Run(); |
82 } | 100 } |
83 } | 101 } |
84 | 102 |
85 void OnQuotaManagedOriginDeleted(const GURL& origin, | 103 void OnQuotaManagedOriginDeleted(const GURL& origin, |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 void DecrementTaskCountOnIO(); | 258 void DecrementTaskCountOnIO(); |
241 | 259 |
242 void ClearDataOnIOThread( | 260 void ClearDataOnIOThread( |
243 const scoped_refptr<storage::QuotaManager>& quota_manager, | 261 const scoped_refptr<storage::QuotaManager>& quota_manager, |
244 const base::Time begin, | 262 const base::Time begin, |
245 const scoped_refptr<storage::SpecialStoragePolicy>& | 263 const scoped_refptr<storage::SpecialStoragePolicy>& |
246 special_storage_policy, | 264 special_storage_policy, |
247 const StoragePartition::OriginMatcherFunction& origin_matcher); | 265 const StoragePartition::OriginMatcherFunction& origin_matcher); |
248 | 266 |
249 void ClearOriginsOnIOThread( | 267 void ClearOriginsOnIOThread( |
| 268 |
250 storage::QuotaManager* quota_manager, | 269 storage::QuotaManager* quota_manager, |
251 const scoped_refptr<storage::SpecialStoragePolicy>& | 270 const scoped_refptr<storage::SpecialStoragePolicy>& |
252 special_storage_policy, | 271 special_storage_policy, |
253 const StoragePartition::OriginMatcherFunction& origin_matcher, | 272 const StoragePartition::OriginMatcherFunction& origin_matcher, |
254 const base::Closure& callback, | 273 const base::Closure& callback, |
255 const std::set<GURL>& origins, | 274 const std::set<GURL>& origins, |
256 storage::StorageType quota_storage_type); | 275 storage::StorageType quota_storage_type); |
257 | 276 |
258 // All of these data are accessed on IO thread. | 277 // All of these data are accessed on IO thread. |
259 uint32_t remove_mask; | 278 uint32_t remove_mask; |
(...skipping 21 matching lines...) Expand all Loading... |
281 quota_storage_remove_mask(quota_storage_remove_mask), | 300 quota_storage_remove_mask(quota_storage_remove_mask), |
282 callback(callback), | 301 callback(callback), |
283 task_count(0) {} | 302 task_count(0) {} |
284 | 303 |
285 void IncrementTaskCountOnUI(); | 304 void IncrementTaskCountOnUI(); |
286 void DecrementTaskCountOnUI(); | 305 void DecrementTaskCountOnUI(); |
287 | 306 |
288 void ClearDataOnUIThread( | 307 void ClearDataOnUIThread( |
289 const GURL& storage_origin, | 308 const GURL& storage_origin, |
290 const OriginMatcherFunction& origin_matcher, | 309 const OriginMatcherFunction& origin_matcher, |
| 310 const CookieMatcherFunction& cookie_matcher, |
291 const base::FilePath& path, | 311 const base::FilePath& path, |
292 net::URLRequestContextGetter* rq_context, | 312 net::URLRequestContextGetter* rq_context, |
293 DOMStorageContextWrapper* dom_storage_context, | 313 DOMStorageContextWrapper* dom_storage_context, |
294 storage::QuotaManager* quota_manager, | 314 storage::QuotaManager* quota_manager, |
295 storage::SpecialStoragePolicy* special_storage_policy, | 315 storage::SpecialStoragePolicy* special_storage_policy, |
296 WebRTCIdentityStore* webrtc_identity_store, | 316 WebRTCIdentityStore* webrtc_identity_store, |
297 const base::Time begin, | 317 const base::Time begin, |
298 const base::Time end); | 318 const base::Time end); |
299 | 319 |
300 void ClearQuotaManagedDataOnIOThread( | 320 void ClearQuotaManagedDataOnIOThread( |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 const mojo::String& origin, | 614 const mojo::String& origin, |
595 mojo::InterfaceRequest<LevelDBWrapper> request) { | 615 mojo::InterfaceRequest<LevelDBWrapper> request) { |
596 dom_storage_context_->OpenLocalStorage(origin, std::move(request)); | 616 dom_storage_context_->OpenLocalStorage(origin, std::move(request)); |
597 } | 617 } |
598 | 618 |
599 void StoragePartitionImpl::ClearDataImpl( | 619 void StoragePartitionImpl::ClearDataImpl( |
600 uint32_t remove_mask, | 620 uint32_t remove_mask, |
601 uint32_t quota_storage_remove_mask, | 621 uint32_t quota_storage_remove_mask, |
602 const GURL& storage_origin, | 622 const GURL& storage_origin, |
603 const OriginMatcherFunction& origin_matcher, | 623 const OriginMatcherFunction& origin_matcher, |
| 624 const CookieMatcherFunction& cookie_matcher, |
604 net::URLRequestContextGetter* rq_context, | 625 net::URLRequestContextGetter* rq_context, |
605 const base::Time begin, | 626 const base::Time begin, |
606 const base::Time end, | 627 const base::Time end, |
607 const base::Closure& callback) { | 628 const base::Closure& callback) { |
608 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 629 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
609 DataDeletionHelper* helper = new DataDeletionHelper(remove_mask, | 630 DataDeletionHelper* helper = new DataDeletionHelper(remove_mask, |
610 quota_storage_remove_mask, | 631 quota_storage_remove_mask, |
611 callback); | 632 callback); |
612 // |helper| deletes itself when done in | 633 // |helper| deletes itself when done in |
613 // DataDeletionHelper::DecrementTaskCountOnUI(). | 634 // DataDeletionHelper::DecrementTaskCountOnUI(). |
614 helper->ClearDataOnUIThread(storage_origin, | 635 helper->ClearDataOnUIThread( |
615 origin_matcher, | 636 storage_origin, origin_matcher, cookie_matcher, GetPath(), rq_context, |
616 GetPath(), | 637 dom_storage_context_.get(), quota_manager_.get(), |
617 rq_context, | 638 special_storage_policy_.get(), webrtc_identity_store_.get(), begin, end); |
618 dom_storage_context_.get(), | |
619 quota_manager_.get(), | |
620 special_storage_policy_.get(), | |
621 webrtc_identity_store_.get(), | |
622 begin, | |
623 end); | |
624 } | 639 } |
625 | 640 |
626 void StoragePartitionImpl:: | 641 void StoragePartitionImpl:: |
627 QuotaManagedDataDeletionHelper::IncrementTaskCountOnIO() { | 642 QuotaManagedDataDeletionHelper::IncrementTaskCountOnIO() { |
628 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 643 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
629 ++task_count; | 644 ++task_count; |
630 } | 645 } |
631 | 646 |
632 void StoragePartitionImpl:: | 647 void StoragePartitionImpl:: |
633 QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO() { | 648 QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO() { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 --task_count; | 773 --task_count; |
759 if (!task_count) { | 774 if (!task_count) { |
760 callback.Run(); | 775 callback.Run(); |
761 delete this; | 776 delete this; |
762 } | 777 } |
763 } | 778 } |
764 | 779 |
765 void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread( | 780 void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread( |
766 const GURL& storage_origin, | 781 const GURL& storage_origin, |
767 const OriginMatcherFunction& origin_matcher, | 782 const OriginMatcherFunction& origin_matcher, |
| 783 const CookieMatcherFunction& cookie_matcher, |
768 const base::FilePath& path, | 784 const base::FilePath& path, |
769 net::URLRequestContextGetter* rq_context, | 785 net::URLRequestContextGetter* rq_context, |
770 DOMStorageContextWrapper* dom_storage_context, | 786 DOMStorageContextWrapper* dom_storage_context, |
771 storage::QuotaManager* quota_manager, | 787 storage::QuotaManager* quota_manager, |
772 storage::SpecialStoragePolicy* special_storage_policy, | 788 storage::SpecialStoragePolicy* special_storage_policy, |
773 WebRTCIdentityStore* webrtc_identity_store, | 789 WebRTCIdentityStore* webrtc_identity_store, |
774 const base::Time begin, | 790 const base::Time begin, |
775 const base::Time end) { | 791 const base::Time end) { |
776 DCHECK_NE(remove_mask, 0u); | 792 DCHECK_NE(remove_mask, 0u); |
777 DCHECK(!callback.is_null()); | 793 DCHECK(!callback.is_null()); |
778 | 794 |
779 IncrementTaskCountOnUI(); | 795 IncrementTaskCountOnUI(); |
780 base::Closure decrement_callback = base::Bind( | 796 base::Closure decrement_callback = base::Bind( |
781 &DataDeletionHelper::DecrementTaskCountOnUI, base::Unretained(this)); | 797 &DataDeletionHelper::DecrementTaskCountOnUI, base::Unretained(this)); |
782 | 798 |
783 if (remove_mask & REMOVE_DATA_MASK_COOKIES) { | 799 if (remove_mask & REMOVE_DATA_MASK_COOKIES) { |
784 // Handle the cookies. | 800 // Handle the cookies. |
785 IncrementTaskCountOnUI(); | 801 IncrementTaskCountOnUI(); |
786 BrowserThread::PostTask( | 802 // We will never have both a storage_origin and a cookie_matcher. |
787 BrowserThread::IO, FROM_HERE, | 803 if (cookie_matcher.is_null()) { |
788 base::Bind(&ClearCookiesOnIOThread, | 804 BrowserThread::PostTask( |
789 make_scoped_refptr(rq_context), begin, end, storage_origin, | 805 BrowserThread::IO, FROM_HERE, |
790 decrement_callback)); | 806 base::Bind(&ClearCookiesOnIOThread, make_scoped_refptr(rq_context), |
| 807 begin, end, storage_origin, decrement_callback)); |
| 808 } else { |
| 809 BrowserThread::PostTask( |
| 810 BrowserThread::IO, FROM_HERE, |
| 811 base::Bind(&ClearCookiesOnIOThreadWithCookieMatcher, |
| 812 make_scoped_refptr(rq_context), begin, end, cookie_matcher, |
| 813 decrement_callback)); |
| 814 } |
791 } | 815 } |
792 | 816 |
793 if (remove_mask & REMOVE_DATA_MASK_INDEXEDDB || | 817 if (remove_mask & REMOVE_DATA_MASK_INDEXEDDB || |
794 remove_mask & REMOVE_DATA_MASK_WEBSQL || | 818 remove_mask & REMOVE_DATA_MASK_WEBSQL || |
795 remove_mask & REMOVE_DATA_MASK_APPCACHE || | 819 remove_mask & REMOVE_DATA_MASK_APPCACHE || |
796 remove_mask & REMOVE_DATA_MASK_FILE_SYSTEMS || | 820 remove_mask & REMOVE_DATA_MASK_FILE_SYSTEMS || |
797 remove_mask & REMOVE_DATA_MASK_SERVICE_WORKERS || | 821 remove_mask & REMOVE_DATA_MASK_SERVICE_WORKERS || |
798 remove_mask & REMOVE_DATA_MASK_CACHE_STORAGE) { | 822 remove_mask & REMOVE_DATA_MASK_CACHE_STORAGE) { |
799 IncrementTaskCountOnUI(); | 823 IncrementTaskCountOnUI(); |
800 BrowserThread::PostTask( | 824 BrowserThread::PostTask( |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 DecrementTaskCountOnUI(); | 878 DecrementTaskCountOnUI(); |
855 } | 879 } |
856 | 880 |
857 void StoragePartitionImpl::ClearDataForOrigin( | 881 void StoragePartitionImpl::ClearDataForOrigin( |
858 uint32_t remove_mask, | 882 uint32_t remove_mask, |
859 uint32_t quota_storage_remove_mask, | 883 uint32_t quota_storage_remove_mask, |
860 const GURL& storage_origin, | 884 const GURL& storage_origin, |
861 net::URLRequestContextGetter* request_context_getter, | 885 net::URLRequestContextGetter* request_context_getter, |
862 const base::Closure& callback) { | 886 const base::Closure& callback) { |
863 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 887 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
864 ClearDataImpl(remove_mask, | 888 ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin, |
865 quota_storage_remove_mask, | 889 OriginMatcherFunction(), CookieMatcherFunction(), |
866 storage_origin, | 890 request_context_getter, base::Time(), base::Time::Max(), |
867 OriginMatcherFunction(), | |
868 request_context_getter, | |
869 base::Time(), | |
870 base::Time::Max(), | |
871 callback); | 891 callback); |
872 } | 892 } |
873 | 893 |
874 void StoragePartitionImpl::ClearData( | 894 void StoragePartitionImpl::ClearData( |
875 uint32_t remove_mask, | 895 uint32_t remove_mask, |
876 uint32_t quota_storage_remove_mask, | 896 uint32_t quota_storage_remove_mask, |
877 const GURL& storage_origin, | 897 const GURL& storage_origin, |
878 const OriginMatcherFunction& origin_matcher, | 898 const OriginMatcherFunction& origin_matcher, |
879 const base::Time begin, | 899 const base::Time begin, |
880 const base::Time end, | 900 const base::Time end, |
881 const base::Closure& callback) { | 901 const base::Closure& callback) { |
882 ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin, | 902 ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin, |
883 origin_matcher, GetURLRequestContext(), begin, end, callback); | 903 origin_matcher, CookieMatcherFunction(), GetURLRequestContext(), |
| 904 begin, end, callback); |
| 905 } |
| 906 |
| 907 void StoragePartitionImpl::ClearData( |
| 908 uint32_t remove_mask, |
| 909 uint32_t quota_storage_remove_mask, |
| 910 const OriginMatcherFunction& origin_matcher, |
| 911 const CookieMatcherFunction& cookie_matcher, |
| 912 const base::Time begin, |
| 913 const base::Time end, |
| 914 const base::Closure& callback) { |
| 915 ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(), origin_matcher, |
| 916 cookie_matcher, GetURLRequestContext(), begin, end, callback); |
884 } | 917 } |
885 | 918 |
886 void StoragePartitionImpl::Flush() { | 919 void StoragePartitionImpl::Flush() { |
887 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 920 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
888 if (GetDOMStorageContext()) | 921 if (GetDOMStorageContext()) |
889 GetDOMStorageContext()->Flush(); | 922 GetDOMStorageContext()->Flush(); |
890 } | 923 } |
891 | 924 |
892 WebRTCIdentityStore* StoragePartitionImpl::GetWebRTCIdentityStore() { | 925 WebRTCIdentityStore* StoragePartitionImpl::GetWebRTCIdentityStore() { |
893 return webrtc_identity_store_.get(); | 926 return webrtc_identity_store_.get(); |
(...skipping 22 matching lines...) Expand all Loading... |
916 net::URLRequestContextGetter* url_request_context) { | 949 net::URLRequestContextGetter* url_request_context) { |
917 url_request_context_ = url_request_context; | 950 url_request_context_ = url_request_context; |
918 } | 951 } |
919 | 952 |
920 void StoragePartitionImpl::SetMediaURLRequestContext( | 953 void StoragePartitionImpl::SetMediaURLRequestContext( |
921 net::URLRequestContextGetter* media_url_request_context) { | 954 net::URLRequestContextGetter* media_url_request_context) { |
922 media_url_request_context_ = media_url_request_context; | 955 media_url_request_context_ = media_url_request_context; |
923 } | 956 } |
924 | 957 |
925 } // namespace content | 958 } // namespace content |
OLD | NEW |