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> |
| 8 |
7 #include <set> | 9 #include <set> |
8 #include <vector> | 10 #include <vector> |
9 | 11 |
10 #include "base/location.h" | 12 #include "base/location.h" |
11 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
12 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
13 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
14 #include "content/browser/browser_main_loop.h" | 16 #include "content/browser/browser_main_loop.h" |
15 #include "content/browser/fileapi/browser_file_system_helper.h" | 17 #include "content/browser/fileapi/browser_file_system_helper.h" |
16 #include "content/browser/geofencing/geofencing_manager.h" | 18 #include "content/browser/geofencing/geofencing_manager.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 196 |
195 dom_storage_context->GetSessionStorageUsage( | 197 dom_storage_context->GetSessionStorageUsage( |
196 base::Bind(&OnSessionStorageUsageInfo, dom_storage_context, | 198 base::Bind(&OnSessionStorageUsageInfo, dom_storage_context, |
197 special_storage_policy, origin_matcher, | 199 special_storage_policy, origin_matcher, |
198 callback)); | 200 callback)); |
199 } | 201 } |
200 | 202 |
201 } // namespace | 203 } // namespace |
202 | 204 |
203 // Static. | 205 // Static. |
204 int StoragePartitionImpl::GenerateQuotaClientMask(uint32 remove_mask) { | 206 int StoragePartitionImpl::GenerateQuotaClientMask(uint32_t remove_mask) { |
205 int quota_client_mask = 0; | 207 int quota_client_mask = 0; |
206 | 208 |
207 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS) | 209 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS) |
208 quota_client_mask |= storage::QuotaClient::kFileSystem; | 210 quota_client_mask |= storage::QuotaClient::kFileSystem; |
209 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_WEBSQL) | 211 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_WEBSQL) |
210 quota_client_mask |= storage::QuotaClient::kDatabase; | 212 quota_client_mask |= storage::QuotaClient::kDatabase; |
211 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_APPCACHE) | 213 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_APPCACHE) |
212 quota_client_mask |= storage::QuotaClient::kAppcache; | 214 quota_client_mask |= storage::QuotaClient::kAppcache; |
213 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_INDEXEDDB) | 215 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_INDEXEDDB) |
214 quota_client_mask |= storage::QuotaClient::kIndexedDatabase; | 216 quota_client_mask |= storage::QuotaClient::kIndexedDatabase; |
215 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS) | 217 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS) |
216 quota_client_mask |= storage::QuotaClient::kServiceWorker; | 218 quota_client_mask |= storage::QuotaClient::kServiceWorker; |
217 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE) | 219 if (remove_mask & StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE) |
218 quota_client_mask |= storage::QuotaClient::kServiceWorkerCache; | 220 quota_client_mask |= storage::QuotaClient::kServiceWorkerCache; |
219 | 221 |
220 return quota_client_mask; | 222 return quota_client_mask; |
221 } | 223 } |
222 | 224 |
223 // Helper for deleting quota managed data from a partition. | 225 // Helper for deleting quota managed data from a partition. |
224 // | 226 // |
225 // Most of the operations in this class are done on IO thread. | 227 // Most of the operations in this class are done on IO thread. |
226 struct StoragePartitionImpl::QuotaManagedDataDeletionHelper { | 228 struct StoragePartitionImpl::QuotaManagedDataDeletionHelper { |
227 QuotaManagedDataDeletionHelper(uint32 remove_mask, | 229 QuotaManagedDataDeletionHelper(uint32_t remove_mask, |
228 uint32 quota_storage_remove_mask, | 230 uint32_t quota_storage_remove_mask, |
229 const GURL& storage_origin, | 231 const GURL& storage_origin, |
230 const base::Closure& callback) | 232 const base::Closure& callback) |
231 : remove_mask(remove_mask), | 233 : remove_mask(remove_mask), |
232 quota_storage_remove_mask(quota_storage_remove_mask), | 234 quota_storage_remove_mask(quota_storage_remove_mask), |
233 storage_origin(storage_origin), | 235 storage_origin(storage_origin), |
234 callback(callback), | 236 callback(callback), |
235 task_count(0) { | 237 task_count(0) {} |
236 } | |
237 | 238 |
238 void IncrementTaskCountOnIO(); | 239 void IncrementTaskCountOnIO(); |
239 void DecrementTaskCountOnIO(); | 240 void DecrementTaskCountOnIO(); |
240 | 241 |
241 void ClearDataOnIOThread( | 242 void ClearDataOnIOThread( |
242 const scoped_refptr<storage::QuotaManager>& quota_manager, | 243 const scoped_refptr<storage::QuotaManager>& quota_manager, |
243 const base::Time begin, | 244 const base::Time begin, |
244 const scoped_refptr<storage::SpecialStoragePolicy>& | 245 const scoped_refptr<storage::SpecialStoragePolicy>& |
245 special_storage_policy, | 246 special_storage_policy, |
246 const StoragePartition::OriginMatcherFunction& origin_matcher); | 247 const StoragePartition::OriginMatcherFunction& origin_matcher); |
247 | 248 |
248 void ClearOriginsOnIOThread( | 249 void ClearOriginsOnIOThread( |
249 storage::QuotaManager* quota_manager, | 250 storage::QuotaManager* quota_manager, |
250 const scoped_refptr<storage::SpecialStoragePolicy>& | 251 const scoped_refptr<storage::SpecialStoragePolicy>& |
251 special_storage_policy, | 252 special_storage_policy, |
252 const StoragePartition::OriginMatcherFunction& origin_matcher, | 253 const StoragePartition::OriginMatcherFunction& origin_matcher, |
253 const base::Closure& callback, | 254 const base::Closure& callback, |
254 const std::set<GURL>& origins, | 255 const std::set<GURL>& origins, |
255 storage::StorageType quota_storage_type); | 256 storage::StorageType quota_storage_type); |
256 | 257 |
257 // All of these data are accessed on IO thread. | 258 // All of these data are accessed on IO thread. |
258 uint32 remove_mask; | 259 uint32_t remove_mask; |
259 uint32 quota_storage_remove_mask; | 260 uint32_t quota_storage_remove_mask; |
260 GURL storage_origin; | 261 GURL storage_origin; |
261 const base::Closure callback; | 262 const base::Closure callback; |
262 int task_count; | 263 int task_count; |
263 }; | 264 }; |
264 | 265 |
265 // Helper for deleting all sorts of data from a partition, keeps track of | 266 // Helper for deleting all sorts of data from a partition, keeps track of |
266 // deletion status. | 267 // deletion status. |
267 // | 268 // |
268 // StoragePartitionImpl creates an instance of this class to keep track of | 269 // StoragePartitionImpl creates an instance of this class to keep track of |
269 // data deletion progress. Deletion requires deleting multiple bits of data | 270 // data deletion progress. Deletion requires deleting multiple bits of data |
270 // (e.g. cookies, local storage, session storage etc.) and hopping between UI | 271 // (e.g. cookies, local storage, session storage etc.) and hopping between UI |
271 // and IO thread. An instance of this class is created in the beginning of | 272 // and IO thread. An instance of this class is created in the beginning of |
272 // deletion process (StoragePartitionImpl::ClearDataImpl) and the instance is | 273 // deletion process (StoragePartitionImpl::ClearDataImpl) and the instance is |
273 // forwarded and updated on each (sub) deletion's callback. The instance is | 274 // forwarded and updated on each (sub) deletion's callback. The instance is |
274 // finally destroyed when deletion completes (and |callback| is invoked). | 275 // finally destroyed when deletion completes (and |callback| is invoked). |
275 struct StoragePartitionImpl::DataDeletionHelper { | 276 struct StoragePartitionImpl::DataDeletionHelper { |
276 DataDeletionHelper(uint32 remove_mask, | 277 DataDeletionHelper(uint32_t remove_mask, |
277 uint32 quota_storage_remove_mask, | 278 uint32_t quota_storage_remove_mask, |
278 const base::Closure& callback) | 279 const base::Closure& callback) |
279 : remove_mask(remove_mask), | 280 : remove_mask(remove_mask), |
280 quota_storage_remove_mask(quota_storage_remove_mask), | 281 quota_storage_remove_mask(quota_storage_remove_mask), |
281 callback(callback), | 282 callback(callback), |
282 task_count(0) { | 283 task_count(0) {} |
283 } | |
284 | 284 |
285 void IncrementTaskCountOnUI(); | 285 void IncrementTaskCountOnUI(); |
286 void DecrementTaskCountOnUI(); | 286 void DecrementTaskCountOnUI(); |
287 | 287 |
288 void ClearDataOnUIThread( | 288 void ClearDataOnUIThread( |
289 const GURL& storage_origin, | 289 const GURL& storage_origin, |
290 const OriginMatcherFunction& origin_matcher, | 290 const OriginMatcherFunction& origin_matcher, |
291 const base::FilePath& path, | 291 const base::FilePath& path, |
292 net::URLRequestContextGetter* rq_context, | 292 net::URLRequestContextGetter* rq_context, |
293 DOMStorageContextWrapper* dom_storage_context, | 293 DOMStorageContextWrapper* dom_storage_context, |
294 storage::QuotaManager* quota_manager, | 294 storage::QuotaManager* quota_manager, |
295 storage::SpecialStoragePolicy* special_storage_policy, | 295 storage::SpecialStoragePolicy* special_storage_policy, |
296 WebRTCIdentityStore* webrtc_identity_store, | 296 WebRTCIdentityStore* webrtc_identity_store, |
297 const base::Time begin, | 297 const base::Time begin, |
298 const base::Time end); | 298 const base::Time end); |
299 | 299 |
300 void ClearQuotaManagedDataOnIOThread( | 300 void ClearQuotaManagedDataOnIOThread( |
301 const scoped_refptr<storage::QuotaManager>& quota_manager, | 301 const scoped_refptr<storage::QuotaManager>& quota_manager, |
302 const base::Time begin, | 302 const base::Time begin, |
303 const GURL& storage_origin, | 303 const GURL& storage_origin, |
304 const scoped_refptr<storage::SpecialStoragePolicy>& | 304 const scoped_refptr<storage::SpecialStoragePolicy>& |
305 special_storage_policy, | 305 special_storage_policy, |
306 const StoragePartition::OriginMatcherFunction& origin_matcher, | 306 const StoragePartition::OriginMatcherFunction& origin_matcher, |
307 const base::Closure& callback); | 307 const base::Closure& callback); |
308 | 308 |
309 uint32 remove_mask; | 309 uint32_t remove_mask; |
310 uint32 quota_storage_remove_mask; | 310 uint32_t quota_storage_remove_mask; |
311 | 311 |
312 // Accessed on UI thread. | 312 // Accessed on UI thread. |
313 const base::Closure callback; | 313 const base::Closure callback; |
314 // Accessed on UI thread. | 314 // Accessed on UI thread. |
315 int task_count; | 315 int task_count; |
316 }; | 316 }; |
317 | 317 |
318 void StoragePartitionImpl::DataDeletionHelper::ClearQuotaManagedDataOnIOThread( | 318 void StoragePartitionImpl::DataDeletionHelper::ClearQuotaManagedDataOnIOThread( |
319 const scoped_refptr<storage::QuotaManager>& quota_manager, | 319 const scoped_refptr<storage::QuotaManager>& quota_manager, |
320 const base::Time begin, | 320 const base::Time begin, |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 PlatformNotificationContextImpl* | 585 PlatformNotificationContextImpl* |
586 StoragePartitionImpl::GetPlatformNotificationContext() { | 586 StoragePartitionImpl::GetPlatformNotificationContext() { |
587 return platform_notification_context_.get(); | 587 return platform_notification_context_.get(); |
588 } | 588 } |
589 | 589 |
590 BackgroundSyncContextImpl* StoragePartitionImpl::GetBackgroundSyncContext() { | 590 BackgroundSyncContextImpl* StoragePartitionImpl::GetBackgroundSyncContext() { |
591 return background_sync_context_.get(); | 591 return background_sync_context_.get(); |
592 } | 592 } |
593 | 593 |
594 void StoragePartitionImpl::ClearDataImpl( | 594 void StoragePartitionImpl::ClearDataImpl( |
595 uint32 remove_mask, | 595 uint32_t remove_mask, |
596 uint32 quota_storage_remove_mask, | 596 uint32_t quota_storage_remove_mask, |
597 const GURL& storage_origin, | 597 const GURL& storage_origin, |
598 const OriginMatcherFunction& origin_matcher, | 598 const OriginMatcherFunction& origin_matcher, |
599 net::URLRequestContextGetter* rq_context, | 599 net::URLRequestContextGetter* rq_context, |
600 const base::Time begin, | 600 const base::Time begin, |
601 const base::Time end, | 601 const base::Time end, |
602 const base::Closure& callback) { | 602 const base::Closure& callback) { |
603 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 603 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
604 DataDeletionHelper* helper = new DataDeletionHelper(remove_mask, | 604 DataDeletionHelper* helper = new DataDeletionHelper(remove_mask, |
605 quota_storage_remove_mask, | 605 quota_storage_remove_mask, |
606 callback); | 606 callback); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 webrtc_identity_store, | 843 webrtc_identity_store, |
844 begin, | 844 begin, |
845 end, | 845 end, |
846 decrement_callback)); | 846 decrement_callback)); |
847 } | 847 } |
848 | 848 |
849 DecrementTaskCountOnUI(); | 849 DecrementTaskCountOnUI(); |
850 } | 850 } |
851 | 851 |
852 void StoragePartitionImpl::ClearDataForOrigin( | 852 void StoragePartitionImpl::ClearDataForOrigin( |
853 uint32 remove_mask, | 853 uint32_t remove_mask, |
854 uint32 quota_storage_remove_mask, | 854 uint32_t quota_storage_remove_mask, |
855 const GURL& storage_origin, | 855 const GURL& storage_origin, |
856 net::URLRequestContextGetter* request_context_getter, | 856 net::URLRequestContextGetter* request_context_getter, |
857 const base::Closure& callback) { | 857 const base::Closure& callback) { |
858 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 858 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
859 ClearDataImpl(remove_mask, | 859 ClearDataImpl(remove_mask, |
860 quota_storage_remove_mask, | 860 quota_storage_remove_mask, |
861 storage_origin, | 861 storage_origin, |
862 OriginMatcherFunction(), | 862 OriginMatcherFunction(), |
863 request_context_getter, | 863 request_context_getter, |
864 base::Time(), | 864 base::Time(), |
865 base::Time::Max(), | 865 base::Time::Max(), |
866 callback); | 866 callback); |
867 } | 867 } |
868 | 868 |
869 void StoragePartitionImpl::ClearData( | 869 void StoragePartitionImpl::ClearData( |
870 uint32 remove_mask, | 870 uint32_t remove_mask, |
871 uint32 quota_storage_remove_mask, | 871 uint32_t quota_storage_remove_mask, |
872 const GURL& storage_origin, | 872 const GURL& storage_origin, |
873 const OriginMatcherFunction& origin_matcher, | 873 const OriginMatcherFunction& origin_matcher, |
874 const base::Time begin, | 874 const base::Time begin, |
875 const base::Time end, | 875 const base::Time end, |
876 const base::Closure& callback) { | 876 const base::Closure& callback) { |
877 ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin, | 877 ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin, |
878 origin_matcher, GetURLRequestContext(), begin, end, callback); | 878 origin_matcher, GetURLRequestContext(), begin, end, callback); |
879 } | 879 } |
880 | 880 |
881 void StoragePartitionImpl::Flush() { | 881 void StoragePartitionImpl::Flush() { |
(...skipping 24 matching lines...) Expand all Loading... |
906 net::URLRequestContextGetter* url_request_context) { | 906 net::URLRequestContextGetter* url_request_context) { |
907 url_request_context_ = url_request_context; | 907 url_request_context_ = url_request_context; |
908 } | 908 } |
909 | 909 |
910 void StoragePartitionImpl::SetMediaURLRequestContext( | 910 void StoragePartitionImpl::SetMediaURLRequestContext( |
911 net::URLRequestContextGetter* media_url_request_context) { | 911 net::URLRequestContextGetter* media_url_request_context) { |
912 media_url_request_context_ = media_url_request_context; | 912 media_url_request_context_ = media_url_request_context; |
913 } | 913 } |
914 | 914 |
915 } // namespace content | 915 } // namespace content |
OLD | NEW |