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 "chrome/browser/browsing_data/browsing_data_remover.h" | 5 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 void BrowsingDataRemover::ClearedCache() { | 738 void BrowsingDataRemover::ClearedCache() { |
739 waiting_for_clear_cache_ = false; | 739 waiting_for_clear_cache_ = false; |
740 | 740 |
741 NotifyAndDeleteIfDone(); | 741 NotifyAndDeleteIfDone(); |
742 } | 742 } |
743 | 743 |
744 void BrowsingDataRemover::ClearCacheOnIOThread() { | 744 void BrowsingDataRemover::ClearCacheOnIOThread() { |
745 // This function should be called on the IO thread. | 745 // This function should be called on the IO thread. |
746 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 746 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
747 DCHECK_EQ(STATE_NONE, next_cache_state_); | 747 DCHECK_EQ(STATE_NONE, next_cache_state_); |
748 DCHECK(main_context_getter_); | 748 DCHECK(main_context_getter_.get()); |
749 DCHECK(media_context_getter_); | 749 DCHECK(media_context_getter_.get()); |
750 | 750 |
751 next_cache_state_ = STATE_CREATE_MAIN; | 751 next_cache_state_ = STATE_CREATE_MAIN; |
752 DoClearCache(net::OK); | 752 DoClearCache(net::OK); |
753 } | 753 } |
754 | 754 |
755 // The expected state sequence is STATE_NONE --> STATE_CREATE_MAIN --> | 755 // The expected state sequence is STATE_NONE --> STATE_CREATE_MAIN --> |
756 // STATE_DELETE_MAIN --> STATE_CREATE_MEDIA --> STATE_DELETE_MEDIA --> | 756 // STATE_DELETE_MAIN --> STATE_CREATE_MEDIA --> STATE_DELETE_MEDIA --> |
757 // STATE_DONE, and any errors are ignored. | 757 // STATE_DONE, and any errors are ignored. |
758 void BrowsingDataRemover::DoClearCache(int rv) { | 758 void BrowsingDataRemover::DoClearCache(int rv) { |
759 DCHECK_NE(STATE_NONE, next_cache_state_); | 759 DCHECK_NE(STATE_NONE, next_cache_state_); |
760 | 760 |
761 while (rv != net::ERR_IO_PENDING && next_cache_state_ != STATE_NONE) { | 761 while (rv != net::ERR_IO_PENDING && next_cache_state_ != STATE_NONE) { |
762 switch (next_cache_state_) { | 762 switch (next_cache_state_) { |
763 case STATE_CREATE_MAIN: | 763 case STATE_CREATE_MAIN: |
764 case STATE_CREATE_MEDIA: { | 764 case STATE_CREATE_MEDIA: { |
765 // Get a pointer to the cache. | 765 // Get a pointer to the cache. |
766 net::URLRequestContextGetter* getter = | 766 net::URLRequestContextGetter* getter = |
767 (next_cache_state_ == STATE_CREATE_MAIN) ? | 767 (next_cache_state_ == STATE_CREATE_MAIN) |
768 main_context_getter_ : media_context_getter_; | 768 ? main_context_getter_.get() |
| 769 : media_context_getter_.get(); |
769 net::HttpTransactionFactory* factory = | 770 net::HttpTransactionFactory* factory = |
770 getter->GetURLRequestContext()->http_transaction_factory(); | 771 getter->GetURLRequestContext()->http_transaction_factory(); |
771 | 772 |
772 next_cache_state_ = (next_cache_state_ == STATE_CREATE_MAIN) ? | 773 next_cache_state_ = (next_cache_state_ == STATE_CREATE_MAIN) ? |
773 STATE_DELETE_MAIN : STATE_DELETE_MEDIA; | 774 STATE_DELETE_MAIN : STATE_DELETE_MEDIA; |
774 rv = factory->GetCache()->GetBackend( | 775 rv = factory->GetCache()->GetBackend( |
775 &cache_, base::Bind(&BrowsingDataRemover::DoClearCache, | 776 &cache_, base::Bind(&BrowsingDataRemover::DoClearCache, |
776 base::Unretained(this))); | 777 base::Unretained(this))); |
777 break; | 778 break; |
778 } | 779 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 base::Bind(&BrowsingDataRemover::OnGotLocalStorageUsageInfo, | 871 base::Bind(&BrowsingDataRemover::OnGotLocalStorageUsageInfo, |
871 base::Unretained(this))); | 872 base::Unretained(this))); |
872 } | 873 } |
873 | 874 |
874 void BrowsingDataRemover::OnGotLocalStorageUsageInfo( | 875 void BrowsingDataRemover::OnGotLocalStorageUsageInfo( |
875 const std::vector<dom_storage::LocalStorageUsageInfo>& infos) { | 876 const std::vector<dom_storage::LocalStorageUsageInfo>& infos) { |
876 DCHECK(waiting_for_clear_local_storage_); | 877 DCHECK(waiting_for_clear_local_storage_); |
877 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 878 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
878 | 879 |
879 for (size_t i = 0; i < infos.size(); ++i) { | 880 for (size_t i = 0; i < infos.size(); ++i) { |
880 if (!BrowsingDataHelper::DoesOriginMatchMask(infos[i].origin, | 881 if (!BrowsingDataHelper::DoesOriginMatchMask( |
881 origin_set_mask_, | 882 infos[i].origin, origin_set_mask_, special_storage_policy_.get())) |
882 special_storage_policy_)) | |
883 continue; | 883 continue; |
884 | 884 |
885 if (infos[i].last_modified >= delete_begin_ && | 885 if (infos[i].last_modified >= delete_begin_ && |
886 infos[i].last_modified <= delete_end_) { | 886 infos[i].last_modified <= delete_end_) { |
887 dom_storage_context_->DeleteLocalStorage(infos[i].origin); | 887 dom_storage_context_->DeleteLocalStorage(infos[i].origin); |
888 } | 888 } |
889 } | 889 } |
890 waiting_for_clear_local_storage_ = false; | 890 waiting_for_clear_local_storage_ = false; |
891 NotifyAndDeleteIfDone(); | 891 NotifyAndDeleteIfDone(); |
892 } | 892 } |
893 | 893 |
894 void BrowsingDataRemover::ClearSessionStorageOnUIThread() { | 894 void BrowsingDataRemover::ClearSessionStorageOnUIThread() { |
895 DCHECK(waiting_for_clear_session_storage_); | 895 DCHECK(waiting_for_clear_session_storage_); |
896 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 896 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
897 | 897 |
898 dom_storage_context_->GetSessionStorageUsage( | 898 dom_storage_context_->GetSessionStorageUsage( |
899 base::Bind(&BrowsingDataRemover::OnGotSessionStorageUsageInfo, | 899 base::Bind(&BrowsingDataRemover::OnGotSessionStorageUsageInfo, |
900 base::Unretained(this))); | 900 base::Unretained(this))); |
901 } | 901 } |
902 | 902 |
903 void BrowsingDataRemover::OnGotSessionStorageUsageInfo( | 903 void BrowsingDataRemover::OnGotSessionStorageUsageInfo( |
904 const std::vector<dom_storage::SessionStorageUsageInfo>& infos) { | 904 const std::vector<dom_storage::SessionStorageUsageInfo>& infos) { |
905 DCHECK(waiting_for_clear_session_storage_); | 905 DCHECK(waiting_for_clear_session_storage_); |
906 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 906 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
907 | 907 |
908 for (size_t i = 0; i < infos.size(); ++i) { | 908 for (size_t i = 0; i < infos.size(); ++i) { |
909 if (!BrowsingDataHelper::DoesOriginMatchMask(infos[i].origin, | 909 if (!BrowsingDataHelper::DoesOriginMatchMask( |
910 origin_set_mask_, | 910 infos[i].origin, origin_set_mask_, special_storage_policy_.get())) |
911 special_storage_policy_)) | |
912 continue; | 911 continue; |
913 | 912 |
914 dom_storage_context_->DeleteSessionStorage(infos[i]); | 913 dom_storage_context_->DeleteSessionStorage(infos[i]); |
915 } | 914 } |
916 waiting_for_clear_session_storage_ = false; | 915 waiting_for_clear_session_storage_ = false; |
917 NotifyAndDeleteIfDone(); | 916 NotifyAndDeleteIfDone(); |
918 } | 917 } |
919 | 918 |
920 void BrowsingDataRemover::ClearQuotaManagedDataOnIOThread() { | 919 void BrowsingDataRemover::ClearQuotaManagedDataOnIOThread() { |
921 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 920 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 // Walk through the origins passed in, delete quota of |type| from each that | 960 // Walk through the origins passed in, delete quota of |type| from each that |
962 // matches the |origin_set_mask_|. | 961 // matches the |origin_set_mask_|. |
963 std::set<GURL>::const_iterator origin; | 962 std::set<GURL>::const_iterator origin; |
964 for (origin = origins.begin(); origin != origins.end(); ++origin) { | 963 for (origin = origins.begin(); origin != origins.end(); ++origin) { |
965 // TODO(mkwst): Clean this up, it's slow. http://crbug.com/130746 | 964 // TODO(mkwst): Clean this up, it's slow. http://crbug.com/130746 |
966 if (!remove_origin_.is_empty() && remove_origin_ != origin->GetOrigin()) | 965 if (!remove_origin_.is_empty() && remove_origin_ != origin->GetOrigin()) |
967 continue; | 966 continue; |
968 | 967 |
969 if (!BrowsingDataHelper::DoesOriginMatchMask(origin->GetOrigin(), | 968 if (!BrowsingDataHelper::DoesOriginMatchMask(origin->GetOrigin(), |
970 origin_set_mask_, | 969 origin_set_mask_, |
971 special_storage_policy_)) | 970 special_storage_policy_.get())) |
972 continue; | 971 continue; |
973 | 972 |
974 ++quota_managed_origins_to_delete_count_; | 973 ++quota_managed_origins_to_delete_count_; |
975 quota_manager_->DeleteOriginData( | 974 quota_manager_->DeleteOriginData( |
976 origin->GetOrigin(), type, | 975 origin->GetOrigin(), type, |
977 BrowsingDataRemover::GenerateQuotaClientMask(remove_mask_), | 976 BrowsingDataRemover::GenerateQuotaClientMask(remove_mask_), |
978 base::Bind(&BrowsingDataRemover::OnQuotaManagedOriginDeletion, | 977 base::Bind(&BrowsingDataRemover::OnQuotaManagedOriginDeletion, |
979 base::Unretained(this), origin->GetOrigin(), type)); | 978 base::Unretained(this), origin->GetOrigin(), type)); |
980 } | 979 } |
981 | 980 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1092 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1094 waiting_for_clear_form_ = false; | 1093 waiting_for_clear_form_ = false; |
1095 NotifyAndDeleteIfDone(); | 1094 NotifyAndDeleteIfDone(); |
1096 } | 1095 } |
1097 | 1096 |
1098 void BrowsingDataRemover::OnClearedAutofillOriginURLs() { | 1097 void BrowsingDataRemover::OnClearedAutofillOriginURLs() { |
1099 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1098 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1100 waiting_for_clear_autofill_origin_urls_ = false; | 1099 waiting_for_clear_autofill_origin_urls_ = false; |
1101 NotifyAndDeleteIfDone(); | 1100 NotifyAndDeleteIfDone(); |
1102 } | 1101 } |
OLD | NEW |