| 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 "base/sequenced_task_runner.h" | 7 #include "base/sequenced_task_runner.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/browser/browser_main_loop.h" | 9 #include "content/browser/browser_main_loop.h" |
| 10 #include "content/browser/fileapi/browser_file_system_helper.h" | 10 #include "content/browser/fileapi/browser_file_system_helper.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "net/cookies/cookie_monster.h" | 21 #include "net/cookies/cookie_monster.h" |
| 22 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
| 23 #include "net/url_request/url_request_context_getter.h" | 23 #include "net/url_request/url_request_context_getter.h" |
| 24 #include "webkit/browser/database/database_tracker.h" | 24 #include "webkit/browser/database/database_tracker.h" |
| 25 #include "webkit/browser/quota/quota_manager.h" | 25 #include "webkit/browser/quota/quota_manager.h" |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 int GenerateQuotaClientMask(uint32 remove_mask) { | |
| 32 int quota_client_mask = 0; | |
| 33 | |
| 34 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS) | |
| 35 quota_client_mask |= quota::QuotaClient::kFileSystem; | |
| 36 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_WEBSQL) | |
| 37 quota_client_mask |= quota::QuotaClient::kDatabase; | |
| 38 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_APPCACHE) | |
| 39 quota_client_mask |= quota::QuotaClient::kAppcache; | |
| 40 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_INDEXEDDB) | |
| 41 quota_client_mask |= quota::QuotaClient::kIndexedDatabase; | |
| 42 | |
| 43 return quota_client_mask; | |
| 44 } | |
| 45 | |
| 46 void OnClearedCookies(const base::Closure& callback, int num_deleted) { | 31 void OnClearedCookies(const base::Closure& callback, int num_deleted) { |
| 47 // The final callback needs to happen from UI thread. | 32 // The final callback needs to happen from UI thread. |
| 48 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 33 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 49 BrowserThread::PostTask( | 34 BrowserThread::PostTask( |
| 50 BrowserThread::UI, FROM_HERE, | 35 BrowserThread::UI, FROM_HERE, |
| 51 base::Bind(&OnClearedCookies, callback, num_deleted)); | 36 base::Bind(&OnClearedCookies, callback, num_deleted)); |
| 52 return; | 37 return; |
| 53 } | 38 } |
| 54 | 39 |
| 55 callback.Run(); | 40 callback.Run(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 70 end, | 55 end, |
| 71 base::Bind(&OnClearedCookies, callback)); | 56 base::Bind(&OnClearedCookies, callback)); |
| 72 } else { | 57 } else { |
| 73 cookie_store->GetCookieMonster()->DeleteAllCreatedBetweenForHostAsync( | 58 cookie_store->GetCookieMonster()->DeleteAllCreatedBetweenForHostAsync( |
| 74 begin, | 59 begin, |
| 75 end, | 60 end, |
| 76 remove_origin, base::Bind(&OnClearedCookies, callback)); | 61 remove_origin, base::Bind(&OnClearedCookies, callback)); |
| 77 } | 62 } |
| 78 } | 63 } |
| 79 | 64 |
| 65 void CheckQuotaManagedDataDeletionStatus(size_t* deletion_task_count, |
| 66 const base::Closure& callback) { |
| 67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 68 if (*deletion_task_count == 0) { |
| 69 delete deletion_task_count; |
| 70 callback.Run(); |
| 71 } |
| 72 } |
| 73 |
| 80 void OnQuotaManagedOriginDeleted(const GURL& origin, | 74 void OnQuotaManagedOriginDeleted(const GURL& origin, |
| 81 quota::StorageType type, | 75 quota::StorageType type, |
| 82 size_t* origins_to_delete_count, | 76 size_t* deletion_task_count, |
| 83 const base::Closure& callback, | 77 const base::Closure& callback, |
| 84 quota::QuotaStatusCode status) { | 78 quota::QuotaStatusCode status) { |
| 85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 86 DCHECK_GT(*origins_to_delete_count, 0u); | 80 DCHECK_GT(*deletion_task_count, 0u); |
| 87 if (status != quota::kQuotaStatusOk) { | 81 if (status != quota::kQuotaStatusOk) { |
| 88 DLOG(ERROR) << "Couldn't remove data of type " << type << " for origin " | 82 DLOG(ERROR) << "Couldn't remove data of type " << type << " for origin " |
| 89 << origin << ". Status: " << status; | 83 << origin << ". Status: " << status; |
| 90 } | 84 } |
| 91 | 85 |
| 92 (*origins_to_delete_count)--; | 86 (*deletion_task_count)--; |
| 93 if (*origins_to_delete_count == 0) { | 87 CheckQuotaManagedDataDeletionStatus(deletion_task_count, callback); |
| 94 delete origins_to_delete_count; | |
| 95 callback.Run(); | |
| 96 } | |
| 97 } | |
| 98 | |
| 99 void ClearQuotaManagedOriginsOnIOThread(quota::QuotaManager* quota_manager, | |
| 100 uint32 remove_mask, | |
| 101 const base::Closure& callback, | |
| 102 const std::set<GURL>& origins, | |
| 103 quota::StorageType quota_storage_type) { | |
| 104 // The QuotaManager manages all storage other than cookies, LocalStorage, | |
| 105 // and SessionStorage. This loop wipes out most HTML5 storage for the given | |
| 106 // origins. | |
| 107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 108 | |
| 109 if (!origins.size()) { | |
| 110 // No origins to clear. | |
| 111 callback.Run(); | |
| 112 return; | |
| 113 } | |
| 114 | |
| 115 size_t* origins_to_delete_count = new size_t(origins.size()); | |
| 116 for (std::set<GURL>::const_iterator origin = origins.begin(); | |
| 117 origin != origins.end(); ++origin) { | |
| 118 quota_manager->DeleteOriginData( | |
| 119 *origin, quota_storage_type, | |
| 120 GenerateQuotaClientMask(remove_mask), | |
| 121 base::Bind(&OnQuotaManagedOriginDeleted, | |
| 122 origin->GetOrigin(), quota_storage_type, | |
| 123 origins_to_delete_count, callback)); | |
| 124 } | |
| 125 } | 88 } |
| 126 | 89 |
| 127 void ClearedShaderCache(const base::Closure& callback) { | 90 void ClearedShaderCache(const base::Closure& callback) { |
| 128 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 91 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 129 BrowserThread::PostTask( | 92 BrowserThread::PostTask( |
| 130 BrowserThread::UI, FROM_HERE, | 93 BrowserThread::UI, FROM_HERE, |
| 131 base::Bind(&ClearedShaderCache, callback)); | 94 base::Bind(&ClearedShaderCache, callback)); |
| 132 return; | 95 return; |
| 133 } | 96 } |
| 134 callback.Run(); | 97 callback.Run(); |
| 135 } | 98 } |
| 136 | 99 |
| 137 void ClearShaderCacheOnIOThread(const base::FilePath& path, | 100 void ClearShaderCacheOnIOThread(const base::FilePath& path, |
| 138 const base::Time begin, | 101 const base::Time begin, |
| 139 const base::Time end, | 102 const base::Time end, |
| 140 const base::Closure& callback) { | 103 const base::Closure& callback) { |
| 141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 104 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 142 ShaderCacheFactory::GetInstance()->ClearByPath( | 105 ShaderCacheFactory::GetInstance()->ClearByPath( |
| 143 path, begin, end, base::Bind(&ClearedShaderCache, callback)); | 106 path, begin, end, base::Bind(&ClearedShaderCache, callback)); |
| 144 } | 107 } |
| 145 | 108 |
| 146 void OnLocalStorageUsageInfo( | 109 void OnLocalStorageUsageInfo( |
| 147 const scoped_refptr<DOMStorageContextWrapper>& dom_storage_context, | 110 const scoped_refptr<DOMStorageContextWrapper>& dom_storage_context, |
| 111 const scoped_refptr<quota::SpecialStoragePolicy>& special_storage_policy, |
| 112 const StoragePartition::OriginMatcherFunction& origin_matcher, |
| 148 const base::Time delete_begin, | 113 const base::Time delete_begin, |
| 149 const base::Time delete_end, | 114 const base::Time delete_end, |
| 150 const base::Closure& callback, | 115 const base::Closure& callback, |
| 151 const std::vector<LocalStorageUsageInfo>& infos) { | 116 const std::vector<LocalStorageUsageInfo>& infos) { |
| 152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 153 | 118 |
| 154 for (size_t i = 0; i < infos.size(); ++i) { | 119 for (size_t i = 0; i < infos.size(); ++i) { |
| 120 if (!origin_matcher.is_null() && |
| 121 !origin_matcher.Run(infos[i].origin, special_storage_policy.get())) { |
| 122 continue; |
| 123 } |
| 124 |
| 155 if (infos[i].last_modified >= delete_begin && | 125 if (infos[i].last_modified >= delete_begin && |
| 156 infos[i].last_modified <= delete_end) { | 126 infos[i].last_modified <= delete_end) { |
| 157 dom_storage_context->DeleteLocalStorage(infos[i].origin); | 127 dom_storage_context->DeleteLocalStorage(infos[i].origin); |
| 158 } | 128 } |
| 159 } | 129 } |
| 160 callback.Run(); | 130 callback.Run(); |
| 161 } | 131 } |
| 162 | 132 |
| 163 void OnSessionStorageUsageInfo( | 133 void OnSessionStorageUsageInfo( |
| 164 const scoped_refptr<DOMStorageContextWrapper>& dom_storage_context, | 134 const scoped_refptr<DOMStorageContextWrapper>& dom_storage_context, |
| 135 const scoped_refptr<quota::SpecialStoragePolicy>& special_storage_policy, |
| 136 const StoragePartition::OriginMatcherFunction& origin_matcher, |
| 165 const base::Closure& callback, | 137 const base::Closure& callback, |
| 166 const std::vector<SessionStorageUsageInfo>& infos) { | 138 const std::vector<SessionStorageUsageInfo>& infos) { |
| 167 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 168 | 140 |
| 169 for (size_t i = 0; i < infos.size(); ++i) | 141 for (size_t i = 0; i < infos.size(); ++i) { |
| 142 if (!origin_matcher.is_null() && |
| 143 !origin_matcher.Run(infos[i].origin, special_storage_policy.get())) { |
| 144 continue; |
| 145 } |
| 170 dom_storage_context->DeleteSessionStorage(infos[i]); | 146 dom_storage_context->DeleteSessionStorage(infos[i]); |
| 147 } |
| 171 | 148 |
| 172 callback.Run(); | 149 callback.Run(); |
| 173 } | 150 } |
| 174 | 151 |
| 175 void ClearLocalStorageOnUIThread( | 152 void ClearLocalStorageOnUIThread( |
| 176 const scoped_refptr<DOMStorageContextWrapper>& dom_storage_context, | 153 const scoped_refptr<DOMStorageContextWrapper>& dom_storage_context, |
| 154 const scoped_refptr<quota::SpecialStoragePolicy>& special_storage_policy, |
| 155 const StoragePartition::OriginMatcherFunction& origin_matcher, |
| 177 const GURL& remove_origin, | 156 const GURL& remove_origin, |
| 178 const base::Time begin, | 157 const base::Time begin, |
| 179 const base::Time end, | 158 const base::Time end, |
| 180 const base::Closure& callback) { | 159 const base::Closure& callback) { |
| 181 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 182 | 161 |
| 183 if (!remove_origin.is_empty()) { | 162 if (!remove_origin.is_empty()) { |
| 184 dom_storage_context->DeleteLocalStorage(remove_origin); | 163 bool can_delete = origin_matcher.is_null() || |
| 164 origin_matcher.Run(remove_origin, |
| 165 special_storage_policy.get()); |
| 166 if (can_delete) |
| 167 dom_storage_context->DeleteLocalStorage(remove_origin); |
| 168 |
| 185 callback.Run(); | 169 callback.Run(); |
| 186 return; | 170 return; |
| 187 } | 171 } |
| 188 | 172 |
| 189 dom_storage_context->GetLocalStorageUsage( | 173 dom_storage_context->GetLocalStorageUsage( |
| 190 base::Bind(&OnLocalStorageUsageInfo, | 174 base::Bind(&OnLocalStorageUsageInfo, |
| 191 dom_storage_context, begin, end, callback)); | 175 dom_storage_context, special_storage_policy, origin_matcher, |
| 176 begin, end, callback)); |
| 192 } | 177 } |
| 193 | 178 |
| 194 void ClearSessionStorageOnUIThread( | 179 void ClearSessionStorageOnUIThread( |
| 195 const scoped_refptr<DOMStorageContextWrapper>& dom_storage_context, | 180 const scoped_refptr<DOMStorageContextWrapper>& dom_storage_context, |
| 181 const scoped_refptr<quota::SpecialStoragePolicy>& special_storage_policy, |
| 182 const StoragePartition::OriginMatcherFunction& origin_matcher, |
| 196 const base::Closure& callback) { | 183 const base::Closure& callback) { |
| 197 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 184 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 198 | 185 |
| 199 dom_storage_context->GetSessionStorageUsage( | 186 dom_storage_context->GetSessionStorageUsage( |
| 200 base::Bind(&OnSessionStorageUsageInfo, dom_storage_context, callback)); | 187 base::Bind(&OnSessionStorageUsageInfo, dom_storage_context, |
| 188 special_storage_policy, origin_matcher, |
| 189 callback)); |
| 201 } | 190 } |
| 202 | 191 |
| 203 } // namespace | 192 } // namespace |
| 204 | 193 |
| 194 // Static. |
| 195 int StoragePartitionImpl::GenerateQuotaClientMask(uint32 remove_mask) { |
| 196 int quota_client_mask = 0; |
| 197 |
| 198 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS) |
| 199 quota_client_mask |= quota::QuotaClient::kFileSystem; |
| 200 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_WEBSQL) |
| 201 quota_client_mask |= quota::QuotaClient::kDatabase; |
| 202 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_APPCACHE) |
| 203 quota_client_mask |= quota::QuotaClient::kAppcache; |
| 204 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_INDEXEDDB) |
| 205 quota_client_mask |= quota::QuotaClient::kIndexedDatabase; |
| 206 |
| 207 return quota_client_mask; |
| 208 } |
| 209 |
| 205 // Helper for deleting quota managed data from a partition. | 210 // Helper for deleting quota managed data from a partition. |
| 206 // | 211 // |
| 207 // Most of the operations in this class are done on IO thread. | 212 // Most of the operations in this class are done on IO thread. |
| 208 struct StoragePartitionImpl::QuotaManagedDataDeletionHelper { | 213 struct StoragePartitionImpl::QuotaManagedDataDeletionHelper { |
| 209 QuotaManagedDataDeletionHelper(const base::Closure& callback) | 214 QuotaManagedDataDeletionHelper(uint32 remove_mask, |
| 210 : callback(callback), task_count(0) { | 215 uint32 quota_storage_remove_mask, |
| 216 const GURL& remove_origin, |
| 217 const base::Closure& callback) |
| 218 : remove_mask(remove_mask), |
| 219 quota_storage_remove_mask(quota_storage_remove_mask), |
| 220 remove_origin(remove_origin), |
| 221 callback(callback), |
| 222 task_count(0) { |
| 211 } | 223 } |
| 212 | 224 |
| 213 void IncrementTaskCountOnIO(); | 225 void IncrementTaskCountOnIO(); |
| 214 void DecrementTaskCountOnIO(); | 226 void DecrementTaskCountOnIO(); |
| 215 | 227 |
| 216 void ClearDataOnIOThread( | 228 void ClearDataOnIOThread( |
| 217 const scoped_refptr<quota::QuotaManager>& quota_manager, | 229 const scoped_refptr<quota::QuotaManager>& quota_manager, |
| 218 const base::Time begin, | 230 const base::Time begin, |
| 219 uint32 remove_mask, | 231 const scoped_refptr<quota::SpecialStoragePolicy>& special_storage_policy, |
| 220 uint32 quota_storage_remove_mask, | 232 const StoragePartition::OriginMatcherFunction& origin_matcher); |
| 221 const GURL& remove_origin); | |
| 222 | 233 |
| 223 // Accessed on IO thread. | 234 void ClearOriginsOnIOThread( |
| 235 quota::QuotaManager* quota_manager, |
| 236 const scoped_refptr<quota::SpecialStoragePolicy>& special_storage_policy, |
| 237 const StoragePartition::OriginMatcherFunction& origin_matcher, |
| 238 const base::Closure& callback, |
| 239 const std::set<GURL>& origins, |
| 240 quota::StorageType quota_storage_type); |
| 241 |
| 242 // All of these data are accessed on IO thread. |
| 243 uint32 remove_mask; |
| 244 uint32 quota_storage_remove_mask; |
| 245 GURL remove_origin; |
| 224 const base::Closure callback; | 246 const base::Closure callback; |
| 225 // Accessed on IO thread. | |
| 226 int task_count; | 247 int task_count; |
| 227 }; | 248 }; |
| 228 | 249 |
| 229 // Helper for deleting all sorts of data from a partition, keeps track of | 250 // Helper for deleting all sorts of data from a partition, keeps track of |
| 230 // deletion status. | 251 // deletion status. |
| 231 // | 252 // |
| 232 // StoragePartitionImpl creates an instance of this class to keep track of | 253 // StoragePartitionImpl creates an instance of this class to keep track of |
| 233 // data deletion progress. Deletion requires deleting multiple bits of data | 254 // data deletion progress. Deletion requires deleting multiple bits of data |
| 234 // (e.g. cookies, local storage, session storage etc.) and hopping between UI | 255 // (e.g. cookies, local storage, session storage etc.) and hopping between UI |
| 235 // and IO thread. An instance of this class is created in the beginning of | 256 // and IO thread. An instance of this class is created in the beginning of |
| 236 // deletion process (StoragePartitionImpl::ClearDataImpl) and the instance is | 257 // deletion process (StoragePartitionImpl::ClearDataImpl) and the instance is |
| 237 // forwarded and updated on each (sub) deletion's callback. The instance is | 258 // forwarded and updated on each (sub) deletion's callback. The instance is |
| 238 // finally destroyed when deletion completes (and |callback| is invoked). | 259 // finally destroyed when deletion completes (and |callback| is invoked). |
| 239 struct StoragePartitionImpl::DataDeletionHelper { | 260 struct StoragePartitionImpl::DataDeletionHelper { |
| 240 DataDeletionHelper(const base::Closure& callback) | 261 DataDeletionHelper(uint32 remove_mask, |
| 241 : callback(callback), task_count(0) { | 262 uint32 quota_storage_remove_mask, |
| 263 const base::Closure& callback) |
| 264 : remove_mask(remove_mask), |
| 265 quota_storage_remove_mask(quota_storage_remove_mask), |
| 266 callback(callback), |
| 267 task_count(0) { |
| 242 } | 268 } |
| 243 | 269 |
| 244 void IncrementTaskCountOnUI(); | 270 void IncrementTaskCountOnUI(); |
| 245 void DecrementTaskCountOnUI(); | 271 void DecrementTaskCountOnUI(); |
| 246 | 272 |
| 247 void ClearDataOnUIThread(uint32 remove_mask, | 273 void ClearDataOnUIThread(const GURL& remove_origin, |
| 248 uint32 quota_storage_remove_mask, | 274 const OriginMatcherFunction& origin_matcher, |
| 249 const GURL& remove_origin, | |
| 250 const base::FilePath& path, | 275 const base::FilePath& path, |
| 251 net::URLRequestContextGetter* rq_context, | 276 net::URLRequestContextGetter* rq_context, |
| 252 DOMStorageContextWrapper* dom_storage_context, | 277 DOMStorageContextWrapper* dom_storage_context, |
| 253 quota::QuotaManager* quota_manager, | 278 quota::QuotaManager* quota_manager, |
| 279 quota::SpecialStoragePolicy* special_storage_policy, |
| 254 WebRTCIdentityStore* webrtc_identity_store, | 280 WebRTCIdentityStore* webrtc_identity_store, |
| 255 const base::Time begin, | 281 const base::Time begin, |
| 256 const base::Time end); | 282 const base::Time end); |
| 257 | 283 |
| 284 void ClearQuotaManagedDataOnIOThread( |
| 285 const scoped_refptr<quota::QuotaManager>& quota_manager, |
| 286 const base::Time begin, |
| 287 const GURL& remove_origin, |
| 288 const scoped_refptr<quota::SpecialStoragePolicy>& special_storage_policy, |
| 289 const StoragePartition::OriginMatcherFunction& origin_matcher, |
| 290 const base::Closure& callback); |
| 291 |
| 292 uint32 remove_mask; |
| 293 uint32 quota_storage_remove_mask; |
| 294 |
| 258 // Accessed on UI thread. | 295 // Accessed on UI thread. |
| 259 const base::Closure callback; | 296 const base::Closure callback; |
| 260 // Accessed on UI thread. | 297 // Accessed on UI thread. |
| 261 int task_count; | 298 int task_count; |
| 262 }; | 299 }; |
| 263 | 300 |
| 264 void ClearQuotaManagedDataOnIOThread( | 301 void StoragePartitionImpl::DataDeletionHelper::ClearQuotaManagedDataOnIOThread( |
| 265 const scoped_refptr<quota::QuotaManager>& quota_manager, | 302 const scoped_refptr<quota::QuotaManager>& quota_manager, |
| 266 const base::Time begin, | 303 const base::Time begin, |
| 267 uint32 remove_mask, | |
| 268 uint32 quota_storage_remove_mask, | |
| 269 const GURL& remove_origin, | 304 const GURL& remove_origin, |
| 305 const scoped_refptr<quota::SpecialStoragePolicy>& special_storage_policy, |
| 306 const StoragePartition::OriginMatcherFunction& origin_matcher, |
| 270 const base::Closure& callback) { | 307 const base::Closure& callback) { |
| 271 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 272 | 309 |
| 273 StoragePartitionImpl::QuotaManagedDataDeletionHelper* helper = | 310 StoragePartitionImpl::QuotaManagedDataDeletionHelper* helper = |
| 274 new StoragePartitionImpl::QuotaManagedDataDeletionHelper(callback); | 311 new StoragePartitionImpl::QuotaManagedDataDeletionHelper( |
| 275 helper->ClearDataOnIOThread(quota_manager, begin, | 312 remove_mask, |
| 276 remove_mask, quota_storage_remove_mask, remove_origin); | 313 quota_storage_remove_mask, |
| 314 remove_origin, |
| 315 callback); |
| 316 helper->ClearDataOnIOThread(quota_manager, begin, special_storage_policy, |
| 317 origin_matcher); |
| 277 } | 318 } |
| 278 | 319 |
| 279 StoragePartitionImpl::StoragePartitionImpl( | 320 StoragePartitionImpl::StoragePartitionImpl( |
| 280 const base::FilePath& partition_path, | 321 const base::FilePath& partition_path, |
| 281 quota::QuotaManager* quota_manager, | 322 quota::QuotaManager* quota_manager, |
| 282 ChromeAppCacheService* appcache_service, | 323 ChromeAppCacheService* appcache_service, |
| 283 fileapi::FileSystemContext* filesystem_context, | 324 fileapi::FileSystemContext* filesystem_context, |
| 284 webkit_database::DatabaseTracker* database_tracker, | 325 webkit_database::DatabaseTracker* database_tracker, |
| 285 DOMStorageContextWrapper* dom_storage_context, | 326 DOMStorageContextWrapper* dom_storage_context, |
| 286 IndexedDBContextImpl* indexed_db_context, | 327 IndexedDBContextImpl* indexed_db_context, |
| 287 ServiceWorkerContext* service_worker_context, | 328 ServiceWorkerContext* service_worker_context, |
| 288 WebRTCIdentityStore* webrtc_identity_store) | 329 WebRTCIdentityStore* webrtc_identity_store, |
| 330 quota::SpecialStoragePolicy* special_storage_policy) |
| 289 : partition_path_(partition_path), | 331 : partition_path_(partition_path), |
| 290 quota_manager_(quota_manager), | 332 quota_manager_(quota_manager), |
| 291 appcache_service_(appcache_service), | 333 appcache_service_(appcache_service), |
| 292 filesystem_context_(filesystem_context), | 334 filesystem_context_(filesystem_context), |
| 293 database_tracker_(database_tracker), | 335 database_tracker_(database_tracker), |
| 294 dom_storage_context_(dom_storage_context), | 336 dom_storage_context_(dom_storage_context), |
| 295 indexed_db_context_(indexed_db_context), | 337 indexed_db_context_(indexed_db_context), |
| 296 service_worker_context_(service_worker_context), | 338 service_worker_context_(service_worker_context), |
| 297 webrtc_identity_store_(webrtc_identity_store) {} | 339 webrtc_identity_store_(webrtc_identity_store), |
| 340 special_storage_policy_(special_storage_policy) {} |
| 298 | 341 |
| 299 StoragePartitionImpl::~StoragePartitionImpl() { | 342 StoragePartitionImpl::~StoragePartitionImpl() { |
| 300 // These message loop checks are just to avoid leaks in unittests. | 343 // These message loop checks are just to avoid leaks in unittests. |
| 301 if (GetDatabaseTracker() && | 344 if (GetDatabaseTracker() && |
| 302 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { | 345 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { |
| 303 BrowserThread::PostTask( | 346 BrowserThread::PostTask( |
| 304 BrowserThread::FILE, FROM_HERE, | 347 BrowserThread::FILE, FROM_HERE, |
| 305 base::Bind(&webkit_database::DatabaseTracker::Shutdown, | 348 base::Bind(&webkit_database::DatabaseTracker::Shutdown, |
| 306 GetDatabaseTracker())); | 349 GetDatabaseTracker())); |
| 307 } | 350 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 414 |
| 372 scoped_refptr<ServiceWorkerContext> service_worker_context = | 415 scoped_refptr<ServiceWorkerContext> service_worker_context = |
| 373 new ServiceWorkerContext(path, quota_manager->proxy()); | 416 new ServiceWorkerContext(path, quota_manager->proxy()); |
| 374 | 417 |
| 375 scoped_refptr<ChromeAppCacheService> appcache_service = | 418 scoped_refptr<ChromeAppCacheService> appcache_service = |
| 376 new ChromeAppCacheService(quota_manager->proxy()); | 419 new ChromeAppCacheService(quota_manager->proxy()); |
| 377 | 420 |
| 378 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store( | 421 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store( |
| 379 new WebRTCIdentityStore(path, context->GetSpecialStoragePolicy())); | 422 new WebRTCIdentityStore(path, context->GetSpecialStoragePolicy())); |
| 380 | 423 |
| 424 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy( |
| 425 context->GetSpecialStoragePolicy()); |
| 426 |
| 381 return new StoragePartitionImpl(partition_path, | 427 return new StoragePartitionImpl(partition_path, |
| 382 quota_manager.get(), | 428 quota_manager.get(), |
| 383 appcache_service.get(), | 429 appcache_service.get(), |
| 384 filesystem_context.get(), | 430 filesystem_context.get(), |
| 385 database_tracker.get(), | 431 database_tracker.get(), |
| 386 dom_storage_context.get(), | 432 dom_storage_context.get(), |
| 387 indexed_db_context.get(), | 433 indexed_db_context.get(), |
| 388 service_worker_context.get(), | 434 service_worker_context.get(), |
| 389 webrtc_identity_store.get()); | 435 webrtc_identity_store.get(), |
| 436 special_storage_policy.get()); |
| 390 } | 437 } |
| 391 | 438 |
| 392 base::FilePath StoragePartitionImpl::GetPath() { | 439 base::FilePath StoragePartitionImpl::GetPath() { |
| 393 return partition_path_; | 440 return partition_path_; |
| 394 } | 441 } |
| 395 | 442 |
| 396 net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() { | 443 net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() { |
| 397 return url_request_context_.get(); | 444 return url_request_context_.get(); |
| 398 } | 445 } |
| 399 | 446 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 427 } | 474 } |
| 428 | 475 |
| 429 ServiceWorkerContext* StoragePartitionImpl::GetServiceWorkerContext() { | 476 ServiceWorkerContext* StoragePartitionImpl::GetServiceWorkerContext() { |
| 430 return service_worker_context_.get(); | 477 return service_worker_context_.get(); |
| 431 } | 478 } |
| 432 | 479 |
| 433 void StoragePartitionImpl::ClearDataImpl( | 480 void StoragePartitionImpl::ClearDataImpl( |
| 434 uint32 remove_mask, | 481 uint32 remove_mask, |
| 435 uint32 quota_storage_remove_mask, | 482 uint32 quota_storage_remove_mask, |
| 436 const GURL& remove_origin, | 483 const GURL& remove_origin, |
| 484 const OriginMatcherFunction& origin_matcher, |
| 437 net::URLRequestContextGetter* rq_context, | 485 net::URLRequestContextGetter* rq_context, |
| 438 const base::Time begin, | 486 const base::Time begin, |
| 439 const base::Time end, | 487 const base::Time end, |
| 440 const base::Closure& callback) { | 488 const base::Closure& callback) { |
| 441 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 489 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 442 DataDeletionHelper* helper = new DataDeletionHelper(callback); | 490 DataDeletionHelper* helper = new DataDeletionHelper(remove_mask, |
| 491 quota_storage_remove_mask, |
| 492 callback); |
| 443 // |helper| deletes itself when done in | 493 // |helper| deletes itself when done in |
| 444 // DataDeletionHelper::DecrementTaskCountOnUI(). | 494 // DataDeletionHelper::DecrementTaskCountOnUI(). |
| 445 helper->ClearDataOnUIThread( | 495 helper->ClearDataOnUIThread(remove_origin, origin_matcher, GetPath(), |
| 446 remove_mask, quota_storage_remove_mask, remove_origin, | 496 rq_context, dom_storage_context_, quota_manager_, |
| 447 GetPath(), rq_context, dom_storage_context_, quota_manager_, | 497 special_storage_policy_.get(), |
| 448 webrtc_identity_store_, begin, end); | 498 webrtc_identity_store_, begin, end); |
| 449 } | 499 } |
| 450 | 500 |
| 451 void StoragePartitionImpl:: | 501 void StoragePartitionImpl:: |
| 452 QuotaManagedDataDeletionHelper::IncrementTaskCountOnIO() { | 502 QuotaManagedDataDeletionHelper::IncrementTaskCountOnIO() { |
| 453 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 503 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 454 ++task_count; | 504 ++task_count; |
| 455 } | 505 } |
| 456 | 506 |
| 457 void StoragePartitionImpl:: | 507 void StoragePartitionImpl:: |
| 458 QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO() { | 508 QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO() { |
| 459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 509 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 460 DCHECK_GT(task_count, 0); | 510 DCHECK_GT(task_count, 0); |
| 461 --task_count; | 511 --task_count; |
| 462 if (task_count) | 512 if (task_count) |
| 463 return; | 513 return; |
| 464 | 514 |
| 465 callback.Run(); | 515 callback.Run(); |
| 466 delete this; | 516 delete this; |
| 467 } | 517 } |
| 468 | 518 |
| 469 void StoragePartitionImpl::QuotaManagedDataDeletionHelper::ClearDataOnIOThread( | 519 void StoragePartitionImpl::QuotaManagedDataDeletionHelper::ClearDataOnIOThread( |
| 470 const scoped_refptr<quota::QuotaManager>& quota_manager, | 520 const scoped_refptr<quota::QuotaManager>& quota_manager, |
| 471 const base::Time begin, | 521 const base::Time begin, |
| 472 uint32 remove_mask, | 522 const scoped_refptr<quota::SpecialStoragePolicy>& special_storage_policy, |
| 473 uint32 quota_storage_remove_mask, | 523 const StoragePartition::OriginMatcherFunction& origin_matcher) { |
| 474 const GURL& remove_origin) { | |
| 475 std::set<GURL> origins; | |
| 476 if (!remove_origin.is_empty()) | |
| 477 origins.insert(remove_origin); | |
| 478 | |
| 479 IncrementTaskCountOnIO(); | 524 IncrementTaskCountOnIO(); |
| 480 base::Closure decrement_callback = base::Bind( | 525 base::Closure decrement_callback = base::Bind( |
| 481 &QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO, | 526 &QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO, |
| 482 base::Unretained(this)); | 527 base::Unretained(this)); |
| 483 | 528 |
| 484 if (quota_storage_remove_mask & QUOTA_MANAGED_STORAGE_MASK_PERSISTENT) { | 529 if (quota_storage_remove_mask & QUOTA_MANAGED_STORAGE_MASK_PERSISTENT) { |
| 485 IncrementTaskCountOnIO(); | 530 IncrementTaskCountOnIO(); |
| 486 if (origins.empty()) { // Remove for all origins. | 531 // Ask the QuotaManager for all origins with persistent quota modified |
| 487 // Ask the QuotaManager for all origins with temporary quota modified | 532 // within the user-specified timeframe, and deal with the resulting set in |
| 488 // within the user-specified timeframe, and deal with the resulting set in | 533 // ClearQuotaManagedOriginsOnIOThread(). |
| 489 // ClearQuotaManagedOriginsOnIOThread(). | 534 quota_manager->GetOriginsModifiedSince( |
| 490 quota_manager->GetOriginsModifiedSince( | 535 quota::kStorageTypePersistent, begin, |
| 491 quota::kStorageTypePersistent, begin, | 536 base::Bind(&QuotaManagedDataDeletionHelper::ClearOriginsOnIOThread, |
| 492 base::Bind(&ClearQuotaManagedOriginsOnIOThread, | 537 base::Unretained(this), |
| 493 quota_manager, remove_mask, decrement_callback)); | 538 quota_manager, |
| 494 } else { | 539 special_storage_policy, |
| 495 ClearQuotaManagedOriginsOnIOThread( | 540 origin_matcher, |
| 496 quota_manager, remove_mask, decrement_callback, | 541 decrement_callback)); |
| 497 origins, quota::kStorageTypePersistent); | |
| 498 } | |
| 499 } | 542 } |
| 500 | 543 |
| 501 // Do the same for temporary quota. | 544 // Do the same for temporary quota. |
| 502 if (quota_storage_remove_mask & QUOTA_MANAGED_STORAGE_MASK_TEMPORARY) { | 545 if (quota_storage_remove_mask & QUOTA_MANAGED_STORAGE_MASK_TEMPORARY) { |
| 503 IncrementTaskCountOnIO(); | 546 IncrementTaskCountOnIO(); |
| 504 if (origins.empty()) { // Remove for all origins. | 547 quota_manager->GetOriginsModifiedSince( |
| 505 quota_manager->GetOriginsModifiedSince( | 548 quota::kStorageTypeTemporary, begin, |
| 506 quota::kStorageTypeTemporary, begin, | 549 base::Bind(&QuotaManagedDataDeletionHelper::ClearOriginsOnIOThread, |
| 507 base::Bind(&ClearQuotaManagedOriginsOnIOThread, | 550 base::Unretained(this), |
| 508 quota_manager, remove_mask, decrement_callback)); | 551 quota_manager, |
| 509 } else { | 552 special_storage_policy, |
| 510 ClearQuotaManagedOriginsOnIOThread( | 553 origin_matcher, |
| 511 quota_manager, remove_mask, decrement_callback, | 554 decrement_callback)); |
| 512 origins, quota::kStorageTypeTemporary); | |
| 513 } | |
| 514 } | 555 } |
| 515 | 556 |
| 516 // Do the same for syncable quota. | 557 // Do the same for syncable quota. |
| 517 if (quota_storage_remove_mask & QUOTA_MANAGED_STORAGE_MASK_SYNCABLE) { | 558 if (quota_storage_remove_mask & QUOTA_MANAGED_STORAGE_MASK_SYNCABLE) { |
| 518 IncrementTaskCountOnIO(); | 559 IncrementTaskCountOnIO(); |
| 519 if (origins.empty()) { // Remove for all origins. | 560 quota_manager->GetOriginsModifiedSince( |
| 520 quota_manager->GetOriginsModifiedSince( | 561 quota::kStorageTypeSyncable, begin, |
| 521 quota::kStorageTypeSyncable, begin, | 562 base::Bind(&QuotaManagedDataDeletionHelper::ClearOriginsOnIOThread, |
| 522 base::Bind(&ClearQuotaManagedOriginsOnIOThread, | 563 base::Unretained(this), |
| 523 quota_manager, remove_mask, decrement_callback)); | 564 quota_manager, |
| 524 } else { | 565 special_storage_policy, |
| 525 ClearQuotaManagedOriginsOnIOThread( | 566 origin_matcher, |
| 526 quota_manager, remove_mask, decrement_callback, | 567 decrement_callback)); |
| 527 origins, quota::kStorageTypeSyncable); | |
| 528 } | |
| 529 } | 568 } |
| 530 | 569 |
| 531 DecrementTaskCountOnIO(); | 570 DecrementTaskCountOnIO(); |
| 532 } | 571 } |
| 533 | 572 |
| 573 void StoragePartitionImpl:: |
| 574 QuotaManagedDataDeletionHelper::ClearOriginsOnIOThread( |
| 575 quota::QuotaManager* quota_manager, |
| 576 const scoped_refptr<quota::SpecialStoragePolicy>& |
| 577 special_storage_policy, |
| 578 const StoragePartition::OriginMatcherFunction& origin_matcher, |
| 579 const base::Closure& callback, |
| 580 const std::set<GURL>& origins, |
| 581 quota::StorageType quota_storage_type) { |
| 582 // The QuotaManager manages all storage other than cookies, LocalStorage, |
| 583 // and SessionStorage. This loop wipes out most HTML5 storage for the given |
| 584 // origins. |
| 585 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 586 if (!origins.size()) { |
| 587 callback.Run(); |
| 588 return; |
| 589 } |
| 590 |
| 591 size_t* deletion_task_count = new size_t(0u); |
| 592 (*deletion_task_count)++; |
| 593 for (std::set<GURL>::const_iterator origin = origins.begin(); |
| 594 origin != origins.end(); ++origin) { |
| 595 // TODO(mkwst): Clean this up, it's slow. http://crbug.com/130746 |
| 596 if (!remove_origin.is_empty() && origin->GetOrigin() != remove_origin) |
| 597 continue; |
| 598 |
| 599 if (!origin_matcher.is_null() && |
| 600 !origin_matcher.Run(*origin, special_storage_policy.get())) { |
| 601 continue; |
| 602 } |
| 603 |
| 604 (*deletion_task_count)++; |
| 605 quota_manager->DeleteOriginData( |
| 606 *origin, quota_storage_type, |
| 607 StoragePartitionImpl::GenerateQuotaClientMask(remove_mask), |
| 608 base::Bind(&OnQuotaManagedOriginDeleted, |
| 609 origin->GetOrigin(), quota_storage_type, |
| 610 deletion_task_count, callback)); |
| 611 } |
| 612 (*deletion_task_count)--; |
| 613 |
| 614 CheckQuotaManagedDataDeletionStatus(deletion_task_count, callback); |
| 615 } |
| 616 |
| 534 void StoragePartitionImpl::DataDeletionHelper::IncrementTaskCountOnUI() { | 617 void StoragePartitionImpl::DataDeletionHelper::IncrementTaskCountOnUI() { |
| 535 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 618 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 536 ++task_count; | 619 ++task_count; |
| 537 } | 620 } |
| 538 | 621 |
| 539 void StoragePartitionImpl::DataDeletionHelper::DecrementTaskCountOnUI() { | 622 void StoragePartitionImpl::DataDeletionHelper::DecrementTaskCountOnUI() { |
| 540 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 623 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 541 BrowserThread::PostTask( | 624 BrowserThread::PostTask( |
| 542 BrowserThread::UI, FROM_HERE, | 625 BrowserThread::UI, FROM_HERE, |
| 543 base::Bind(&DataDeletionHelper::DecrementTaskCountOnUI, | 626 base::Bind(&DataDeletionHelper::DecrementTaskCountOnUI, |
| 544 base::Unretained(this))); | 627 base::Unretained(this))); |
| 545 return; | 628 return; |
| 546 } | 629 } |
| 547 DCHECK_GT(task_count, 0); | 630 DCHECK_GT(task_count, 0); |
| 548 --task_count; | 631 --task_count; |
| 549 if (!task_count) { | 632 if (!task_count) { |
| 550 callback.Run(); | 633 callback.Run(); |
| 551 delete this; | 634 delete this; |
| 552 } | 635 } |
| 553 } | 636 } |
| 554 | 637 |
| 555 void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread( | 638 void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread( |
| 556 uint32 remove_mask, | |
| 557 uint32 quota_storage_remove_mask, | |
| 558 const GURL& remove_origin, | 639 const GURL& remove_origin, |
| 640 const OriginMatcherFunction& origin_matcher, |
| 559 const base::FilePath& path, | 641 const base::FilePath& path, |
| 560 net::URLRequestContextGetter* rq_context, | 642 net::URLRequestContextGetter* rq_context, |
| 561 DOMStorageContextWrapper* dom_storage_context, | 643 DOMStorageContextWrapper* dom_storage_context, |
| 562 quota::QuotaManager* quota_manager, | 644 quota::QuotaManager* quota_manager, |
| 645 quota::SpecialStoragePolicy* special_storage_policy, |
| 563 WebRTCIdentityStore* webrtc_identity_store, | 646 WebRTCIdentityStore* webrtc_identity_store, |
| 564 const base::Time begin, | 647 const base::Time begin, |
| 565 const base::Time end) { | 648 const base::Time end) { |
| 566 DCHECK_NE(remove_mask, 0u); | 649 DCHECK_NE(remove_mask, 0u); |
| 567 DCHECK(!callback.is_null()); | 650 DCHECK(!callback.is_null()); |
| 568 | 651 |
| 569 IncrementTaskCountOnUI(); | 652 IncrementTaskCountOnUI(); |
| 570 base::Closure decrement_callback = base::Bind( | 653 base::Closure decrement_callback = base::Bind( |
| 571 &DataDeletionHelper::DecrementTaskCountOnUI, base::Unretained(this)); | 654 &DataDeletionHelper::DecrementTaskCountOnUI, base::Unretained(this)); |
| 572 | 655 |
| 573 if (remove_mask & REMOVE_DATA_MASK_COOKIES) { | 656 if (remove_mask & REMOVE_DATA_MASK_COOKIES) { |
| 574 // Handle the cookies. | 657 // Handle the cookies. |
| 575 IncrementTaskCountOnUI(); | 658 IncrementTaskCountOnUI(); |
| 576 BrowserThread::PostTask( | 659 BrowserThread::PostTask( |
| 577 BrowserThread::IO, FROM_HERE, | 660 BrowserThread::IO, FROM_HERE, |
| 578 base::Bind(&ClearCookiesOnIOThread, | 661 base::Bind(&ClearCookiesOnIOThread, |
| 579 make_scoped_refptr(rq_context), begin, end, remove_origin, | 662 make_scoped_refptr(rq_context), begin, end, remove_origin, |
| 580 decrement_callback)); | 663 decrement_callback)); |
| 581 } | 664 } |
| 582 | 665 |
| 583 if (remove_mask & REMOVE_DATA_MASK_INDEXEDDB || | 666 if (remove_mask & REMOVE_DATA_MASK_INDEXEDDB || |
| 584 remove_mask & REMOVE_DATA_MASK_WEBSQL || | 667 remove_mask & REMOVE_DATA_MASK_WEBSQL || |
| 585 remove_mask & REMOVE_DATA_MASK_APPCACHE || | 668 remove_mask & REMOVE_DATA_MASK_APPCACHE || |
| 586 remove_mask & REMOVE_DATA_MASK_FILE_SYSTEMS) { | 669 remove_mask & REMOVE_DATA_MASK_FILE_SYSTEMS) { |
| 587 IncrementTaskCountOnUI(); | 670 IncrementTaskCountOnUI(); |
| 588 BrowserThread::PostTask( | 671 BrowserThread::PostTask( |
| 589 BrowserThread::IO, FROM_HERE, | 672 BrowserThread::IO, FROM_HERE, |
| 590 base::Bind(&ClearQuotaManagedDataOnIOThread, | 673 base::Bind(&DataDeletionHelper::ClearQuotaManagedDataOnIOThread, |
| 591 make_scoped_refptr(quota_manager), begin, | 674 base::Unretained(this), |
| 592 remove_mask, quota_storage_remove_mask, remove_origin, | 675 make_scoped_refptr(quota_manager), |
| 676 begin, |
| 677 remove_origin, |
| 678 make_scoped_refptr(special_storage_policy), |
| 679 origin_matcher, |
| 593 decrement_callback)); | 680 decrement_callback)); |
| 594 } | 681 } |
| 595 | 682 |
| 596 if (remove_mask & REMOVE_DATA_MASK_LOCAL_STORAGE) { | 683 if (remove_mask & REMOVE_DATA_MASK_LOCAL_STORAGE) { |
| 597 IncrementTaskCountOnUI(); | 684 IncrementTaskCountOnUI(); |
| 598 ClearLocalStorageOnUIThread( | 685 ClearLocalStorageOnUIThread( |
| 599 make_scoped_refptr(dom_storage_context), | 686 make_scoped_refptr(dom_storage_context), |
| 600 remove_origin, begin, end, decrement_callback); | 687 make_scoped_refptr(special_storage_policy), |
| 688 origin_matcher, |
| 689 remove_origin, begin, end, |
| 690 decrement_callback); |
| 601 | 691 |
| 602 // ClearDataImpl cannot clear session storage data when a particular origin | 692 // ClearDataImpl cannot clear session storage data when a particular origin |
| 603 // is specified. Therefore we ignore clearing session storage in this case. | 693 // is specified. Therefore we ignore clearing session storage in this case. |
| 604 // TODO(lazyboy): Fix. | 694 // TODO(lazyboy): Fix. |
| 605 if (remove_origin.is_empty()) { | 695 if (remove_origin.is_empty()) { |
| 606 IncrementTaskCountOnUI(); | 696 IncrementTaskCountOnUI(); |
| 607 ClearSessionStorageOnUIThread( | 697 ClearSessionStorageOnUIThread( |
| 608 make_scoped_refptr(dom_storage_context), decrement_callback); | 698 make_scoped_refptr(dom_storage_context), |
| 699 make_scoped_refptr(special_storage_policy), |
| 700 origin_matcher, |
| 701 decrement_callback); |
| 609 } | 702 } |
| 610 } | 703 } |
| 611 | 704 |
| 612 if (remove_mask & REMOVE_DATA_MASK_SHADER_CACHE) { | 705 if (remove_mask & REMOVE_DATA_MASK_SHADER_CACHE) { |
| 613 IncrementTaskCountOnUI(); | 706 IncrementTaskCountOnUI(); |
| 614 BrowserThread::PostTask( | 707 BrowserThread::PostTask( |
| 615 BrowserThread::IO, FROM_HERE, | 708 BrowserThread::IO, FROM_HERE, |
| 616 base::Bind(&ClearShaderCacheOnIOThread, | 709 base::Bind(&ClearShaderCacheOnIOThread, |
| 617 path, begin, end, decrement_callback)); | 710 path, begin, end, decrement_callback)); |
| 618 } | 711 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 633 } | 726 } |
| 634 | 727 |
| 635 | 728 |
| 636 void StoragePartitionImpl::ClearDataForOrigin( | 729 void StoragePartitionImpl::ClearDataForOrigin( |
| 637 uint32 remove_mask, | 730 uint32 remove_mask, |
| 638 uint32 quota_storage_remove_mask, | 731 uint32 quota_storage_remove_mask, |
| 639 const GURL& storage_origin, | 732 const GURL& storage_origin, |
| 640 net::URLRequestContextGetter* request_context_getter) { | 733 net::URLRequestContextGetter* request_context_getter) { |
| 641 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 734 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 642 ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin, | 735 ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin, |
| 643 request_context_getter, base::Time(), base::Time::Max(), | 736 OriginMatcherFunction(), request_context_getter, |
| 644 base::Bind(&base::DoNothing)); | 737 base::Time(), base::Time::Max(), base::Bind(&base::DoNothing)); |
| 645 } | 738 } |
| 646 | 739 |
| 647 void StoragePartitionImpl::ClearDataForUnboundedRange( | 740 void StoragePartitionImpl::ClearDataForUnboundedRange( |
| 648 uint32 remove_mask, | 741 uint32 remove_mask, |
| 649 uint32 quota_storage_remove_mask) { | 742 uint32 quota_storage_remove_mask) { |
| 650 ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(), | 743 ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(), |
| 651 GetURLRequestContext(), base::Time(), base::Time::Max(), | 744 OriginMatcherFunction(), GetURLRequestContext(), |
| 652 base::Bind(&base::DoNothing)); | 745 base::Time(), base::Time::Max(), base::Bind(&base::DoNothing)); |
| 653 } | 746 } |
| 654 | 747 |
| 655 void StoragePartitionImpl::ClearDataForRange(uint32 remove_mask, | 748 void StoragePartitionImpl::ClearDataForRange(uint32 remove_mask, |
| 656 uint32 quota_storage_remove_mask, | 749 uint32 quota_storage_remove_mask, |
| 657 const base::Time& begin, | 750 const base::Time begin, |
| 658 const base::Time& end, | 751 const base::Time end, |
| 659 const base::Closure& callback) { | 752 const base::Closure& callback) { |
| 660 ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(), | 753 ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(), |
| 754 OriginMatcherFunction(), |
| 661 GetURLRequestContext(), begin, end, callback); | 755 GetURLRequestContext(), begin, end, callback); |
| 662 } | 756 } |
| 663 | 757 |
| 758 void StoragePartitionImpl::ClearDataForOriginWithinRange( |
| 759 uint32 remove_mask, |
| 760 uint32 quota_storage_remove_mask, |
| 761 const GURL& storage_origin, |
| 762 const OriginMatcherFunction& origin_matcher, |
| 763 const base::Time begin, |
| 764 const base::Time end, |
| 765 const base::Closure& callback) { |
| 766 ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin, |
| 767 origin_matcher, GetURLRequestContext(), begin, end, callback); |
| 768 } |
| 769 |
| 664 WebRTCIdentityStore* StoragePartitionImpl::GetWebRTCIdentityStore() { | 770 WebRTCIdentityStore* StoragePartitionImpl::GetWebRTCIdentityStore() { |
| 665 return webrtc_identity_store_.get(); | 771 return webrtc_identity_store_.get(); |
| 666 } | 772 } |
| 667 | 773 |
| 774 void StoragePartitionImpl::OverrideQuotaManagerForTesting( |
| 775 quota::QuotaManager* quota_manager) { |
| 776 quota_manager_ = quota_manager; |
| 777 } |
| 778 |
| 779 void StoragePartitionImpl::OverrideSpecialStoragePolicyForTesting( |
| 780 quota::SpecialStoragePolicy* special_storage_policy) { |
| 781 special_storage_policy_ = special_storage_policy; |
| 782 } |
| 783 |
| 668 void StoragePartitionImpl::SetURLRequestContext( | 784 void StoragePartitionImpl::SetURLRequestContext( |
| 669 net::URLRequestContextGetter* url_request_context) { | 785 net::URLRequestContextGetter* url_request_context) { |
| 670 url_request_context_ = url_request_context; | 786 url_request_context_ = url_request_context; |
| 671 } | 787 } |
| 672 | 788 |
| 673 void StoragePartitionImpl::SetMediaURLRequestContext( | 789 void StoragePartitionImpl::SetMediaURLRequestContext( |
| 674 net::URLRequestContextGetter* media_url_request_context) { | 790 net::URLRequestContextGetter* media_url_request_context) { |
| 675 media_url_request_context_ = media_url_request_context; | 791 media_url_request_context_ = media_url_request_context; |
| 676 } | 792 } |
| 677 | 793 |
| 678 } // namespace content | 794 } // namespace content |
| OLD | NEW |