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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 | 307 |
308 void ClearDataOnUIThread( | 308 void ClearDataOnUIThread( |
309 const GURL& storage_origin, | 309 const GURL& storage_origin, |
310 const OriginMatcherFunction& origin_matcher, | 310 const OriginMatcherFunction& origin_matcher, |
311 const CookieMatcherFunction& cookie_matcher, | 311 const CookieMatcherFunction& cookie_matcher, |
312 const base::FilePath& path, | 312 const base::FilePath& path, |
313 net::URLRequestContextGetter* rq_context, | 313 net::URLRequestContextGetter* rq_context, |
314 DOMStorageContextWrapper* dom_storage_context, | 314 DOMStorageContextWrapper* dom_storage_context, |
315 storage::QuotaManager* quota_manager, | 315 storage::QuotaManager* quota_manager, |
316 storage::SpecialStoragePolicy* special_storage_policy, | 316 storage::SpecialStoragePolicy* special_storage_policy, |
317 WebRTCIdentityStore* webrtc_identity_store, | |
318 const base::Time begin, | 317 const base::Time begin, |
319 const base::Time end); | 318 const base::Time end); |
320 | 319 |
321 void ClearQuotaManagedDataOnIOThread( | 320 void ClearQuotaManagedDataOnIOThread( |
322 const scoped_refptr<storage::QuotaManager>& quota_manager, | 321 const scoped_refptr<storage::QuotaManager>& quota_manager, |
323 const base::Time begin, | 322 const base::Time begin, |
324 const GURL& storage_origin, | 323 const GURL& storage_origin, |
325 const scoped_refptr<storage::SpecialStoragePolicy>& | 324 const scoped_refptr<storage::SpecialStoragePolicy>& |
326 special_storage_policy, | 325 special_storage_policy, |
327 const StoragePartition::OriginMatcherFunction& origin_matcher, | 326 const StoragePartition::OriginMatcherFunction& origin_matcher, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 BrowserContext* browser_context, | 358 BrowserContext* browser_context, |
360 const base::FilePath& partition_path, | 359 const base::FilePath& partition_path, |
361 storage::QuotaManager* quota_manager, | 360 storage::QuotaManager* quota_manager, |
362 ChromeAppCacheService* appcache_service, | 361 ChromeAppCacheService* appcache_service, |
363 storage::FileSystemContext* filesystem_context, | 362 storage::FileSystemContext* filesystem_context, |
364 storage::DatabaseTracker* database_tracker, | 363 storage::DatabaseTracker* database_tracker, |
365 DOMStorageContextWrapper* dom_storage_context, | 364 DOMStorageContextWrapper* dom_storage_context, |
366 IndexedDBContextImpl* indexed_db_context, | 365 IndexedDBContextImpl* indexed_db_context, |
367 CacheStorageContextImpl* cache_storage_context, | 366 CacheStorageContextImpl* cache_storage_context, |
368 ServiceWorkerContextWrapper* service_worker_context, | 367 ServiceWorkerContextWrapper* service_worker_context, |
369 WebRTCIdentityStore* webrtc_identity_store, | |
370 storage::SpecialStoragePolicy* special_storage_policy, | 368 storage::SpecialStoragePolicy* special_storage_policy, |
371 HostZoomLevelContext* host_zoom_level_context, | 369 HostZoomLevelContext* host_zoom_level_context, |
372 PlatformNotificationContextImpl* platform_notification_context, | 370 PlatformNotificationContextImpl* platform_notification_context, |
373 BackgroundSyncContext* background_sync_context) | 371 BackgroundSyncContext* background_sync_context) |
374 : partition_path_(partition_path), | 372 : partition_path_(partition_path), |
375 quota_manager_(quota_manager), | 373 quota_manager_(quota_manager), |
376 appcache_service_(appcache_service), | 374 appcache_service_(appcache_service), |
377 filesystem_context_(filesystem_context), | 375 filesystem_context_(filesystem_context), |
378 database_tracker_(database_tracker), | 376 database_tracker_(database_tracker), |
379 dom_storage_context_(dom_storage_context), | 377 dom_storage_context_(dom_storage_context), |
380 indexed_db_context_(indexed_db_context), | 378 indexed_db_context_(indexed_db_context), |
381 cache_storage_context_(cache_storage_context), | 379 cache_storage_context_(cache_storage_context), |
382 service_worker_context_(service_worker_context), | 380 service_worker_context_(service_worker_context), |
383 webrtc_identity_store_(webrtc_identity_store), | |
384 special_storage_policy_(special_storage_policy), | 381 special_storage_policy_(special_storage_policy), |
385 host_zoom_level_context_(host_zoom_level_context), | 382 host_zoom_level_context_(host_zoom_level_context), |
386 platform_notification_context_(platform_notification_context), | 383 platform_notification_context_(platform_notification_context), |
387 background_sync_context_(background_sync_context), | 384 background_sync_context_(background_sync_context), |
388 browser_context_(browser_context) { | 385 browser_context_(browser_context) { |
389 } | 386 } |
390 | 387 |
391 StoragePartitionImpl::~StoragePartitionImpl() { | 388 StoragePartitionImpl::~StoragePartitionImpl() { |
392 browser_context_ = nullptr; | 389 browser_context_ = nullptr; |
393 | 390 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 cache_storage_context->Init(path, make_scoped_refptr(quota_manager->proxy())); | 483 cache_storage_context->Init(path, make_scoped_refptr(quota_manager->proxy())); |
487 | 484 |
488 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context = | 485 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context = |
489 new ServiceWorkerContextWrapper(context); | 486 new ServiceWorkerContextWrapper(context); |
490 service_worker_context->Init(path, quota_manager->proxy(), | 487 service_worker_context->Init(path, quota_manager->proxy(), |
491 context->GetSpecialStoragePolicy()); | 488 context->GetSpecialStoragePolicy()); |
492 | 489 |
493 scoped_refptr<ChromeAppCacheService> appcache_service = | 490 scoped_refptr<ChromeAppCacheService> appcache_service = |
494 new ChromeAppCacheService(quota_manager->proxy()); | 491 new ChromeAppCacheService(quota_manager->proxy()); |
495 | 492 |
496 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store( | |
497 new WebRTCIdentityStore(path, context->GetSpecialStoragePolicy())); | |
498 | |
499 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy( | 493 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy( |
500 context->GetSpecialStoragePolicy()); | 494 context->GetSpecialStoragePolicy()); |
501 | 495 |
502 scoped_refptr<HostZoomLevelContext> host_zoom_level_context( | 496 scoped_refptr<HostZoomLevelContext> host_zoom_level_context( |
503 new HostZoomLevelContext( | 497 new HostZoomLevelContext( |
504 context->CreateZoomLevelDelegate(partition_path))); | 498 context->CreateZoomLevelDelegate(partition_path))); |
505 | 499 |
506 scoped_refptr<PlatformNotificationContextImpl> platform_notification_context = | 500 scoped_refptr<PlatformNotificationContextImpl> platform_notification_context = |
507 new PlatformNotificationContextImpl(path, context, | 501 new PlatformNotificationContextImpl(path, context, |
508 service_worker_context); | 502 service_worker_context); |
509 platform_notification_context->Initialize(); | 503 platform_notification_context->Initialize(); |
510 | 504 |
511 scoped_refptr<BackgroundSyncContext> background_sync_context = | 505 scoped_refptr<BackgroundSyncContext> background_sync_context = |
512 new BackgroundSyncContext(); | 506 new BackgroundSyncContext(); |
513 background_sync_context->Init(service_worker_context); | 507 background_sync_context->Init(service_worker_context); |
514 | 508 |
515 StoragePartitionImpl* storage_partition = new StoragePartitionImpl( | 509 StoragePartitionImpl* storage_partition = new StoragePartitionImpl( |
516 context, partition_path, quota_manager.get(), appcache_service.get(), | 510 context, partition_path, quota_manager.get(), appcache_service.get(), |
517 filesystem_context.get(), database_tracker.get(), | 511 filesystem_context.get(), database_tracker.get(), |
518 dom_storage_context.get(), indexed_db_context.get(), | 512 dom_storage_context.get(), indexed_db_context.get(), |
519 cache_storage_context.get(), service_worker_context.get(), | 513 cache_storage_context.get(), service_worker_context.get(), |
520 webrtc_identity_store.get(), special_storage_policy.get(), | 514 special_storage_policy.get(), host_zoom_level_context.get(), |
521 host_zoom_level_context.get(), platform_notification_context.get(), | 515 platform_notification_context.get(), background_sync_context.get()); |
522 background_sync_context.get()); | |
523 | 516 |
524 service_worker_context->set_storage_partition(storage_partition); | 517 service_worker_context->set_storage_partition(storage_partition); |
525 | 518 |
526 return storage_partition; | 519 return storage_partition; |
527 } | 520 } |
528 | 521 |
529 base::FilePath StoragePartitionImpl::GetPath() { | 522 base::FilePath StoragePartitionImpl::GetPath() { |
530 return partition_path_; | 523 return partition_path_; |
531 } | 524 } |
532 | 525 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 const base::Closure& callback) { | 607 const base::Closure& callback) { |
615 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 608 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
616 DataDeletionHelper* helper = new DataDeletionHelper(remove_mask, | 609 DataDeletionHelper* helper = new DataDeletionHelper(remove_mask, |
617 quota_storage_remove_mask, | 610 quota_storage_remove_mask, |
618 callback); | 611 callback); |
619 // |helper| deletes itself when done in | 612 // |helper| deletes itself when done in |
620 // DataDeletionHelper::DecrementTaskCountOnUI(). | 613 // DataDeletionHelper::DecrementTaskCountOnUI(). |
621 helper->ClearDataOnUIThread( | 614 helper->ClearDataOnUIThread( |
622 storage_origin, origin_matcher, cookie_matcher, GetPath(), rq_context, | 615 storage_origin, origin_matcher, cookie_matcher, GetPath(), rq_context, |
623 dom_storage_context_.get(), quota_manager_.get(), | 616 dom_storage_context_.get(), quota_manager_.get(), |
624 special_storage_policy_.get(), webrtc_identity_store_.get(), begin, end); | 617 special_storage_policy_.get(), begin, end); |
625 } | 618 } |
626 | 619 |
627 void StoragePartitionImpl:: | 620 void StoragePartitionImpl:: |
628 QuotaManagedDataDeletionHelper::IncrementTaskCountOnIO() { | 621 QuotaManagedDataDeletionHelper::IncrementTaskCountOnIO() { |
629 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 622 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
630 ++task_count; | 623 ++task_count; |
631 } | 624 } |
632 | 625 |
633 void StoragePartitionImpl:: | 626 void StoragePartitionImpl:: |
634 QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO() { | 627 QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO() { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 | 746 |
754 void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread( | 747 void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread( |
755 const GURL& storage_origin, | 748 const GURL& storage_origin, |
756 const OriginMatcherFunction& origin_matcher, | 749 const OriginMatcherFunction& origin_matcher, |
757 const CookieMatcherFunction& cookie_matcher, | 750 const CookieMatcherFunction& cookie_matcher, |
758 const base::FilePath& path, | 751 const base::FilePath& path, |
759 net::URLRequestContextGetter* rq_context, | 752 net::URLRequestContextGetter* rq_context, |
760 DOMStorageContextWrapper* dom_storage_context, | 753 DOMStorageContextWrapper* dom_storage_context, |
761 storage::QuotaManager* quota_manager, | 754 storage::QuotaManager* quota_manager, |
762 storage::SpecialStoragePolicy* special_storage_policy, | 755 storage::SpecialStoragePolicy* special_storage_policy, |
763 WebRTCIdentityStore* webrtc_identity_store, | |
764 const base::Time begin, | 756 const base::Time begin, |
765 const base::Time end) { | 757 const base::Time end) { |
766 DCHECK_NE(remove_mask, 0u); | 758 DCHECK_NE(remove_mask, 0u); |
767 DCHECK(!callback.is_null()); | 759 DCHECK(!callback.is_null()); |
768 | 760 |
769 IncrementTaskCountOnUI(); | 761 IncrementTaskCountOnUI(); |
770 base::Closure decrement_callback = base::Bind( | 762 base::Closure decrement_callback = base::Bind( |
771 &DataDeletionHelper::DecrementTaskCountOnUI, base::Unretained(this)); | 763 &DataDeletionHelper::DecrementTaskCountOnUI, base::Unretained(this)); |
772 | 764 |
773 if (remove_mask & REMOVE_DATA_MASK_COOKIES) { | 765 if (remove_mask & REMOVE_DATA_MASK_COOKIES) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 } | 814 } |
823 | 815 |
824 if (remove_mask & REMOVE_DATA_MASK_SHADER_CACHE) { | 816 if (remove_mask & REMOVE_DATA_MASK_SHADER_CACHE) { |
825 IncrementTaskCountOnUI(); | 817 IncrementTaskCountOnUI(); |
826 BrowserThread::PostTask( | 818 BrowserThread::PostTask( |
827 BrowserThread::IO, FROM_HERE, | 819 BrowserThread::IO, FROM_HERE, |
828 base::Bind(&ClearShaderCacheOnIOThread, | 820 base::Bind(&ClearShaderCacheOnIOThread, |
829 path, begin, end, decrement_callback)); | 821 path, begin, end, decrement_callback)); |
830 } | 822 } |
831 | 823 |
832 if (remove_mask & REMOVE_DATA_MASK_WEBRTC_IDENTITY) { | |
833 IncrementTaskCountOnUI(); | |
834 BrowserThread::PostTask( | |
835 BrowserThread::IO, | |
836 FROM_HERE, | |
837 base::Bind(&WebRTCIdentityStore::DeleteBetween, | |
838 webrtc_identity_store, | |
839 begin, | |
840 end, | |
841 decrement_callback)); | |
842 } | |
843 | |
844 DecrementTaskCountOnUI(); | 824 DecrementTaskCountOnUI(); |
845 } | 825 } |
846 | 826 |
847 void StoragePartitionImpl::ClearDataForOrigin( | 827 void StoragePartitionImpl::ClearDataForOrigin( |
848 uint32_t remove_mask, | 828 uint32_t remove_mask, |
849 uint32_t quota_storage_remove_mask, | 829 uint32_t quota_storage_remove_mask, |
850 const GURL& storage_origin, | 830 const GURL& storage_origin, |
851 net::URLRequestContextGetter* request_context_getter, | 831 net::URLRequestContextGetter* request_context_getter, |
852 const base::Closure& callback) { | 832 const base::Closure& callback) { |
853 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 833 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
(...skipping 27 matching lines...) Expand all Loading... |
881 ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(), origin_matcher, | 861 ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(), origin_matcher, |
882 cookie_matcher, GetURLRequestContext(), begin, end, callback); | 862 cookie_matcher, GetURLRequestContext(), begin, end, callback); |
883 } | 863 } |
884 | 864 |
885 void StoragePartitionImpl::Flush() { | 865 void StoragePartitionImpl::Flush() { |
886 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 866 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
887 if (GetDOMStorageContext()) | 867 if (GetDOMStorageContext()) |
888 GetDOMStorageContext()->Flush(); | 868 GetDOMStorageContext()->Flush(); |
889 } | 869 } |
890 | 870 |
891 WebRTCIdentityStore* StoragePartitionImpl::GetWebRTCIdentityStore() { | |
892 return webrtc_identity_store_.get(); | |
893 } | |
894 | |
895 BrowserContext* StoragePartitionImpl::browser_context() const { | 871 BrowserContext* StoragePartitionImpl::browser_context() const { |
896 return browser_context_; | 872 return browser_context_; |
897 } | 873 } |
898 | 874 |
899 void StoragePartitionImpl::Bind( | 875 void StoragePartitionImpl::Bind( |
900 mojo::InterfaceRequest<mojom::StoragePartitionService> request) { | 876 mojo::InterfaceRequest<mojom::StoragePartitionService> request) { |
901 bindings_.AddBinding(this, std::move(request)); | 877 bindings_.AddBinding(this, std::move(request)); |
902 } | 878 } |
903 | 879 |
904 void StoragePartitionImpl::OverrideQuotaManagerForTesting( | 880 void StoragePartitionImpl::OverrideQuotaManagerForTesting( |
(...skipping 10 matching lines...) Expand all Loading... |
915 net::URLRequestContextGetter* url_request_context) { | 891 net::URLRequestContextGetter* url_request_context) { |
916 url_request_context_ = url_request_context; | 892 url_request_context_ = url_request_context; |
917 } | 893 } |
918 | 894 |
919 void StoragePartitionImpl::SetMediaURLRequestContext( | 895 void StoragePartitionImpl::SetMediaURLRequestContext( |
920 net::URLRequestContextGetter* media_url_request_context) { | 896 net::URLRequestContextGetter* media_url_request_context) { |
921 media_url_request_context_ = media_url_request_context; | 897 media_url_request_context_ = media_url_request_context; |
922 } | 898 } |
923 | 899 |
924 } // namespace content | 900 } // namespace content |
OLD | NEW |