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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 311 |
312 void ClearDataOnUIThread( | 312 void ClearDataOnUIThread( |
313 const GURL& storage_origin, | 313 const GURL& storage_origin, |
314 const OriginMatcherFunction& origin_matcher, | 314 const OriginMatcherFunction& origin_matcher, |
315 const CookieMatcherFunction& cookie_matcher, | 315 const CookieMatcherFunction& cookie_matcher, |
316 const base::FilePath& path, | 316 const base::FilePath& path, |
317 net::URLRequestContextGetter* rq_context, | 317 net::URLRequestContextGetter* rq_context, |
318 DOMStorageContextWrapper* dom_storage_context, | 318 DOMStorageContextWrapper* dom_storage_context, |
319 storage::QuotaManager* quota_manager, | 319 storage::QuotaManager* quota_manager, |
320 storage::SpecialStoragePolicy* special_storage_policy, | 320 storage::SpecialStoragePolicy* special_storage_policy, |
321 WebRTCIdentityStore* webrtc_identity_store, | |
322 storage::FileSystemContext* filesystem_context, | 321 storage::FileSystemContext* filesystem_context, |
323 const base::Time begin, | 322 const base::Time begin, |
324 const base::Time end); | 323 const base::Time end); |
325 | 324 |
326 void ClearQuotaManagedDataOnIOThread( | 325 void ClearQuotaManagedDataOnIOThread( |
327 const scoped_refptr<storage::QuotaManager>& quota_manager, | 326 const scoped_refptr<storage::QuotaManager>& quota_manager, |
328 const base::Time begin, | 327 const base::Time begin, |
329 const GURL& storage_origin, | 328 const GURL& storage_origin, |
330 const scoped_refptr<storage::SpecialStoragePolicy>& | 329 const scoped_refptr<storage::SpecialStoragePolicy>& |
331 special_storage_policy, | 330 special_storage_policy, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 BrowserContext* browser_context, | 363 BrowserContext* browser_context, |
365 const base::FilePath& partition_path, | 364 const base::FilePath& partition_path, |
366 storage::QuotaManager* quota_manager, | 365 storage::QuotaManager* quota_manager, |
367 ChromeAppCacheService* appcache_service, | 366 ChromeAppCacheService* appcache_service, |
368 storage::FileSystemContext* filesystem_context, | 367 storage::FileSystemContext* filesystem_context, |
369 storage::DatabaseTracker* database_tracker, | 368 storage::DatabaseTracker* database_tracker, |
370 DOMStorageContextWrapper* dom_storage_context, | 369 DOMStorageContextWrapper* dom_storage_context, |
371 IndexedDBContextImpl* indexed_db_context, | 370 IndexedDBContextImpl* indexed_db_context, |
372 CacheStorageContextImpl* cache_storage_context, | 371 CacheStorageContextImpl* cache_storage_context, |
373 ServiceWorkerContextWrapper* service_worker_context, | 372 ServiceWorkerContextWrapper* service_worker_context, |
374 WebRTCIdentityStore* webrtc_identity_store, | |
375 storage::SpecialStoragePolicy* special_storage_policy, | 373 storage::SpecialStoragePolicy* special_storage_policy, |
376 HostZoomLevelContext* host_zoom_level_context, | 374 HostZoomLevelContext* host_zoom_level_context, |
377 PlatformNotificationContextImpl* platform_notification_context, | 375 PlatformNotificationContextImpl* platform_notification_context, |
378 BackgroundSyncContext* background_sync_context) | 376 BackgroundSyncContext* background_sync_context) |
379 : partition_path_(partition_path), | 377 : partition_path_(partition_path), |
380 quota_manager_(quota_manager), | 378 quota_manager_(quota_manager), |
381 appcache_service_(appcache_service), | 379 appcache_service_(appcache_service), |
382 filesystem_context_(filesystem_context), | 380 filesystem_context_(filesystem_context), |
383 database_tracker_(database_tracker), | 381 database_tracker_(database_tracker), |
384 dom_storage_context_(dom_storage_context), | 382 dom_storage_context_(dom_storage_context), |
385 indexed_db_context_(indexed_db_context), | 383 indexed_db_context_(indexed_db_context), |
386 cache_storage_context_(cache_storage_context), | 384 cache_storage_context_(cache_storage_context), |
387 service_worker_context_(service_worker_context), | 385 service_worker_context_(service_worker_context), |
388 webrtc_identity_store_(webrtc_identity_store), | |
389 special_storage_policy_(special_storage_policy), | 386 special_storage_policy_(special_storage_policy), |
390 host_zoom_level_context_(host_zoom_level_context), | 387 host_zoom_level_context_(host_zoom_level_context), |
391 platform_notification_context_(platform_notification_context), | 388 platform_notification_context_(platform_notification_context), |
392 background_sync_context_(background_sync_context), | 389 background_sync_context_(background_sync_context), |
393 browser_context_(browser_context) { | 390 browser_context_(browser_context) { |
394 } | 391 } |
395 | 392 |
396 StoragePartitionImpl::~StoragePartitionImpl() { | 393 StoragePartitionImpl::~StoragePartitionImpl() { |
397 browser_context_ = nullptr; | 394 browser_context_ = nullptr; |
398 | 395 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 cache_storage_context->Init(path, make_scoped_refptr(quota_manager->proxy())); | 488 cache_storage_context->Init(path, make_scoped_refptr(quota_manager->proxy())); |
492 | 489 |
493 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context = | 490 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context = |
494 new ServiceWorkerContextWrapper(context); | 491 new ServiceWorkerContextWrapper(context); |
495 service_worker_context->Init(path, quota_manager->proxy(), | 492 service_worker_context->Init(path, quota_manager->proxy(), |
496 context->GetSpecialStoragePolicy()); | 493 context->GetSpecialStoragePolicy()); |
497 | 494 |
498 scoped_refptr<ChromeAppCacheService> appcache_service = | 495 scoped_refptr<ChromeAppCacheService> appcache_service = |
499 new ChromeAppCacheService(quota_manager->proxy()); | 496 new ChromeAppCacheService(quota_manager->proxy()); |
500 | 497 |
501 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store( | |
502 new WebRTCIdentityStore(path, context->GetSpecialStoragePolicy())); | |
503 | |
504 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy( | 498 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy( |
505 context->GetSpecialStoragePolicy()); | 499 context->GetSpecialStoragePolicy()); |
506 | 500 |
507 scoped_refptr<HostZoomLevelContext> host_zoom_level_context( | 501 scoped_refptr<HostZoomLevelContext> host_zoom_level_context( |
508 new HostZoomLevelContext( | 502 new HostZoomLevelContext( |
509 context->CreateZoomLevelDelegate(partition_path))); | 503 context->CreateZoomLevelDelegate(partition_path))); |
510 | 504 |
511 scoped_refptr<PlatformNotificationContextImpl> platform_notification_context = | 505 scoped_refptr<PlatformNotificationContextImpl> platform_notification_context = |
512 new PlatformNotificationContextImpl(path, context, | 506 new PlatformNotificationContextImpl(path, context, |
513 service_worker_context); | 507 service_worker_context); |
514 platform_notification_context->Initialize(); | 508 platform_notification_context->Initialize(); |
515 | 509 |
516 scoped_refptr<BackgroundSyncContext> background_sync_context = | 510 scoped_refptr<BackgroundSyncContext> background_sync_context = |
517 new BackgroundSyncContext(); | 511 new BackgroundSyncContext(); |
518 background_sync_context->Init(service_worker_context); | 512 background_sync_context->Init(service_worker_context); |
519 | 513 |
520 StoragePartitionImpl* storage_partition = new StoragePartitionImpl( | 514 StoragePartitionImpl* storage_partition = new StoragePartitionImpl( |
521 context, partition_path, quota_manager.get(), appcache_service.get(), | 515 context, partition_path, quota_manager.get(), appcache_service.get(), |
522 filesystem_context.get(), database_tracker.get(), | 516 filesystem_context.get(), database_tracker.get(), |
523 dom_storage_context.get(), indexed_db_context.get(), | 517 dom_storage_context.get(), indexed_db_context.get(), |
524 cache_storage_context.get(), service_worker_context.get(), | 518 cache_storage_context.get(), service_worker_context.get(), |
525 webrtc_identity_store.get(), special_storage_policy.get(), | 519 special_storage_policy.get(), host_zoom_level_context.get(), |
526 host_zoom_level_context.get(), platform_notification_context.get(), | 520 platform_notification_context.get(), background_sync_context.get()); |
527 background_sync_context.get()); | |
528 | 521 |
529 service_worker_context->set_storage_partition(storage_partition); | 522 service_worker_context->set_storage_partition(storage_partition); |
530 | 523 |
531 return storage_partition; | 524 return storage_partition; |
532 } | 525 } |
533 | 526 |
534 base::FilePath StoragePartitionImpl::GetPath() { | 527 base::FilePath StoragePartitionImpl::GetPath() { |
535 return partition_path_; | 528 return partition_path_; |
536 } | 529 } |
537 | 530 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 const base::Closure& callback) { | 612 const base::Closure& callback) { |
620 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 613 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
621 DataDeletionHelper* helper = new DataDeletionHelper(remove_mask, | 614 DataDeletionHelper* helper = new DataDeletionHelper(remove_mask, |
622 quota_storage_remove_mask, | 615 quota_storage_remove_mask, |
623 callback); | 616 callback); |
624 // |helper| deletes itself when done in | 617 // |helper| deletes itself when done in |
625 // DataDeletionHelper::DecrementTaskCountOnUI(). | 618 // DataDeletionHelper::DecrementTaskCountOnUI(). |
626 helper->ClearDataOnUIThread( | 619 helper->ClearDataOnUIThread( |
627 storage_origin, origin_matcher, cookie_matcher, GetPath(), rq_context, | 620 storage_origin, origin_matcher, cookie_matcher, GetPath(), rq_context, |
628 dom_storage_context_.get(), quota_manager_.get(), | 621 dom_storage_context_.get(), quota_manager_.get(), |
629 special_storage_policy_.get(), webrtc_identity_store_.get(), | 622 special_storage_policy_.get(), filesystem_context_.get(), begin, end); |
630 filesystem_context_.get(), begin, end); | |
631 } | 623 } |
632 | 624 |
633 void StoragePartitionImpl:: | 625 void StoragePartitionImpl:: |
634 QuotaManagedDataDeletionHelper::IncrementTaskCountOnIO() { | 626 QuotaManagedDataDeletionHelper::IncrementTaskCountOnIO() { |
635 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 627 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
636 ++task_count; | 628 ++task_count; |
637 } | 629 } |
638 | 630 |
639 void StoragePartitionImpl:: | 631 void StoragePartitionImpl:: |
640 QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO() { | 632 QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO() { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 | 751 |
760 void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread( | 752 void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread( |
761 const GURL& storage_origin, | 753 const GURL& storage_origin, |
762 const OriginMatcherFunction& origin_matcher, | 754 const OriginMatcherFunction& origin_matcher, |
763 const CookieMatcherFunction& cookie_matcher, | 755 const CookieMatcherFunction& cookie_matcher, |
764 const base::FilePath& path, | 756 const base::FilePath& path, |
765 net::URLRequestContextGetter* rq_context, | 757 net::URLRequestContextGetter* rq_context, |
766 DOMStorageContextWrapper* dom_storage_context, | 758 DOMStorageContextWrapper* dom_storage_context, |
767 storage::QuotaManager* quota_manager, | 759 storage::QuotaManager* quota_manager, |
768 storage::SpecialStoragePolicy* special_storage_policy, | 760 storage::SpecialStoragePolicy* special_storage_policy, |
769 WebRTCIdentityStore* webrtc_identity_store, | |
770 storage::FileSystemContext* filesystem_context, | 761 storage::FileSystemContext* filesystem_context, |
771 const base::Time begin, | 762 const base::Time begin, |
772 const base::Time end) { | 763 const base::Time end) { |
773 DCHECK_NE(remove_mask, 0u); | 764 DCHECK_NE(remove_mask, 0u); |
774 DCHECK(!callback.is_null()); | 765 DCHECK(!callback.is_null()); |
775 | 766 |
776 IncrementTaskCountOnUI(); | 767 IncrementTaskCountOnUI(); |
777 base::Closure decrement_callback = base::Bind( | 768 base::Closure decrement_callback = base::Bind( |
778 &DataDeletionHelper::DecrementTaskCountOnUI, base::Unretained(this)); | 769 &DataDeletionHelper::DecrementTaskCountOnUI, base::Unretained(this)); |
779 | 770 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 } | 820 } |
830 | 821 |
831 if (remove_mask & REMOVE_DATA_MASK_SHADER_CACHE) { | 822 if (remove_mask & REMOVE_DATA_MASK_SHADER_CACHE) { |
832 IncrementTaskCountOnUI(); | 823 IncrementTaskCountOnUI(); |
833 BrowserThread::PostTask( | 824 BrowserThread::PostTask( |
834 BrowserThread::IO, FROM_HERE, | 825 BrowserThread::IO, FROM_HERE, |
835 base::Bind(&ClearShaderCacheOnIOThread, | 826 base::Bind(&ClearShaderCacheOnIOThread, |
836 path, begin, end, decrement_callback)); | 827 path, begin, end, decrement_callback)); |
837 } | 828 } |
838 | 829 |
839 if (remove_mask & REMOVE_DATA_MASK_WEBRTC_IDENTITY) { | |
840 IncrementTaskCountOnUI(); | |
841 BrowserThread::PostTask( | |
842 BrowserThread::IO, | |
843 FROM_HERE, | |
844 base::Bind(&WebRTCIdentityStore::DeleteBetween, | |
845 webrtc_identity_store, | |
846 begin, | |
847 end, | |
848 decrement_callback)); | |
849 } | |
850 | |
851 #if defined(ENABLE_PLUGINS) | 830 #if defined(ENABLE_PLUGINS) |
852 if (remove_mask & REMOVE_DATA_MASK_PLUGIN_PRIVATE_DATA) { | 831 if (remove_mask & REMOVE_DATA_MASK_PLUGIN_PRIVATE_DATA) { |
853 IncrementTaskCountOnUI(); | 832 IncrementTaskCountOnUI(); |
854 filesystem_context->default_file_task_runner()->PostTask( | 833 filesystem_context->default_file_task_runner()->PostTask( |
855 FROM_HERE, base::Bind(&ClearPluginPrivateDataOnFileTaskRunner, | 834 FROM_HERE, base::Bind(&ClearPluginPrivateDataOnFileTaskRunner, |
856 make_scoped_refptr(filesystem_context), | 835 make_scoped_refptr(filesystem_context), |
857 storage_origin, begin, end, decrement_callback)); | 836 storage_origin, begin, end, decrement_callback)); |
858 } | 837 } |
859 #endif // defined(ENABLE_PLUGINS) | 838 #endif // defined(ENABLE_PLUGINS) |
860 | 839 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(), origin_matcher, | 877 ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(), origin_matcher, |
899 cookie_matcher, GetURLRequestContext(), begin, end, callback); | 878 cookie_matcher, GetURLRequestContext(), begin, end, callback); |
900 } | 879 } |
901 | 880 |
902 void StoragePartitionImpl::Flush() { | 881 void StoragePartitionImpl::Flush() { |
903 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 882 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
904 if (GetDOMStorageContext()) | 883 if (GetDOMStorageContext()) |
905 GetDOMStorageContext()->Flush(); | 884 GetDOMStorageContext()->Flush(); |
906 } | 885 } |
907 | 886 |
908 WebRTCIdentityStore* StoragePartitionImpl::GetWebRTCIdentityStore() { | |
909 return webrtc_identity_store_.get(); | |
910 } | |
911 | |
912 BrowserContext* StoragePartitionImpl::browser_context() const { | 887 BrowserContext* StoragePartitionImpl::browser_context() const { |
913 return browser_context_; | 888 return browser_context_; |
914 } | 889 } |
915 | 890 |
916 void StoragePartitionImpl::Bind( | 891 void StoragePartitionImpl::Bind( |
917 mojo::InterfaceRequest<mojom::StoragePartitionService> request) { | 892 mojo::InterfaceRequest<mojom::StoragePartitionService> request) { |
918 bindings_.AddBinding(this, std::move(request)); | 893 bindings_.AddBinding(this, std::move(request)); |
919 } | 894 } |
920 | 895 |
921 void StoragePartitionImpl::OverrideQuotaManagerForTesting( | 896 void StoragePartitionImpl::OverrideQuotaManagerForTesting( |
(...skipping 10 matching lines...) Expand all Loading... |
932 net::URLRequestContextGetter* url_request_context) { | 907 net::URLRequestContextGetter* url_request_context) { |
933 url_request_context_ = url_request_context; | 908 url_request_context_ = url_request_context; |
934 } | 909 } |
935 | 910 |
936 void StoragePartitionImpl::SetMediaURLRequestContext( | 911 void StoragePartitionImpl::SetMediaURLRequestContext( |
937 net::URLRequestContextGetter* media_url_request_context) { | 912 net::URLRequestContextGetter* media_url_request_context) { |
938 media_url_request_context_ = media_url_request_context; | 913 media_url_request_context_ = media_url_request_context; |
939 } | 914 } |
940 | 915 |
941 } // namespace content | 916 } // namespace content |
OLD | NEW |