| 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 scoped_refptr<webmessaging::BroadcastChannelProvider> | 377 scoped_refptr<webmessaging::BroadcastChannelProvider> |
| 380 broadcast_channel_provider) | 378 broadcast_channel_provider) |
| 381 : partition_path_(partition_path), | 379 : partition_path_(partition_path), |
| 382 quota_manager_(quota_manager), | 380 quota_manager_(quota_manager), |
| 383 appcache_service_(appcache_service), | 381 appcache_service_(appcache_service), |
| 384 filesystem_context_(filesystem_context), | 382 filesystem_context_(filesystem_context), |
| 385 database_tracker_(database_tracker), | 383 database_tracker_(database_tracker), |
| 386 dom_storage_context_(dom_storage_context), | 384 dom_storage_context_(dom_storage_context), |
| 387 indexed_db_context_(indexed_db_context), | 385 indexed_db_context_(indexed_db_context), |
| 388 cache_storage_context_(cache_storage_context), | 386 cache_storage_context_(cache_storage_context), |
| 389 service_worker_context_(service_worker_context), | 387 service_worker_context_(service_worker_context), |
| 390 webrtc_identity_store_(webrtc_identity_store), | |
| 391 special_storage_policy_(special_storage_policy), | 388 special_storage_policy_(special_storage_policy), |
| 392 host_zoom_level_context_(host_zoom_level_context), | 389 host_zoom_level_context_(host_zoom_level_context), |
| 393 platform_notification_context_(platform_notification_context), | 390 platform_notification_context_(platform_notification_context), |
| 394 background_sync_context_(background_sync_context), | 391 background_sync_context_(background_sync_context), |
| 395 broadcast_channel_provider_(std::move(broadcast_channel_provider)), | 392 broadcast_channel_provider_(std::move(broadcast_channel_provider)), |
| 396 browser_context_(browser_context) {} | 393 browser_context_(browser_context) {} |
| 397 | 394 |
| 398 StoragePartitionImpl::~StoragePartitionImpl() { | 395 StoragePartitionImpl::~StoragePartitionImpl() { |
| 399 browser_context_ = nullptr; | 396 browser_context_ = nullptr; |
| 400 | 397 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 cache_storage_context->Init(path, make_scoped_refptr(quota_manager->proxy())); | 490 cache_storage_context->Init(path, make_scoped_refptr(quota_manager->proxy())); |
| 494 | 491 |
| 495 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context = | 492 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context = |
| 496 new ServiceWorkerContextWrapper(context); | 493 new ServiceWorkerContextWrapper(context); |
| 497 service_worker_context->Init(path, quota_manager->proxy(), | 494 service_worker_context->Init(path, quota_manager->proxy(), |
| 498 context->GetSpecialStoragePolicy()); | 495 context->GetSpecialStoragePolicy()); |
| 499 | 496 |
| 500 scoped_refptr<ChromeAppCacheService> appcache_service = | 497 scoped_refptr<ChromeAppCacheService> appcache_service = |
| 501 new ChromeAppCacheService(quota_manager->proxy()); | 498 new ChromeAppCacheService(quota_manager->proxy()); |
| 502 | 499 |
| 503 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store( | |
| 504 new WebRTCIdentityStore(path, context->GetSpecialStoragePolicy())); | |
| 505 | |
| 506 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy( | 500 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy( |
| 507 context->GetSpecialStoragePolicy()); | 501 context->GetSpecialStoragePolicy()); |
| 508 | 502 |
| 509 scoped_refptr<HostZoomLevelContext> host_zoom_level_context( | 503 scoped_refptr<HostZoomLevelContext> host_zoom_level_context( |
| 510 new HostZoomLevelContext( | 504 new HostZoomLevelContext( |
| 511 context->CreateZoomLevelDelegate(partition_path))); | 505 context->CreateZoomLevelDelegate(partition_path))); |
| 512 | 506 |
| 513 scoped_refptr<PlatformNotificationContextImpl> platform_notification_context = | 507 scoped_refptr<PlatformNotificationContextImpl> platform_notification_context = |
| 514 new PlatformNotificationContextImpl(path, context, | 508 new PlatformNotificationContextImpl(path, context, |
| 515 service_worker_context); | 509 service_worker_context); |
| 516 platform_notification_context->Initialize(); | 510 platform_notification_context->Initialize(); |
| 517 | 511 |
| 518 scoped_refptr<BackgroundSyncContext> background_sync_context = | 512 scoped_refptr<BackgroundSyncContext> background_sync_context = |
| 519 new BackgroundSyncContext(); | 513 new BackgroundSyncContext(); |
| 520 background_sync_context->Init(service_worker_context); | 514 background_sync_context->Init(service_worker_context); |
| 521 | 515 |
| 522 scoped_refptr<webmessaging::BroadcastChannelProvider> | 516 scoped_refptr<webmessaging::BroadcastChannelProvider> |
| 523 broadcast_channel_provider = new webmessaging::BroadcastChannelProvider(); | 517 broadcast_channel_provider = new webmessaging::BroadcastChannelProvider(); |
| 524 | 518 |
| 525 StoragePartitionImpl* storage_partition = new StoragePartitionImpl( | 519 StoragePartitionImpl* storage_partition = new StoragePartitionImpl( |
| 526 context, partition_path, quota_manager.get(), appcache_service.get(), | 520 context, partition_path, quota_manager.get(), appcache_service.get(), |
| 527 filesystem_context.get(), database_tracker.get(), | 521 filesystem_context.get(), database_tracker.get(), |
| 528 dom_storage_context.get(), indexed_db_context.get(), | 522 dom_storage_context.get(), indexed_db_context.get(), |
| 529 cache_storage_context.get(), service_worker_context.get(), | 523 cache_storage_context.get(), service_worker_context.get(), |
| 530 webrtc_identity_store.get(), special_storage_policy.get(), | 524 special_storage_policy.get(), host_zoom_level_context.get(), |
| 531 host_zoom_level_context.get(), platform_notification_context.get(), | 525 platform_notification_context.get(), background_sync_context.get(), |
| 532 background_sync_context.get(), std::move(broadcast_channel_provider)); | 526 std::move(broadcast_channel_provider)); |
| 533 | 527 |
| 534 service_worker_context->set_storage_partition(storage_partition); | 528 service_worker_context->set_storage_partition(storage_partition); |
| 535 | 529 |
| 536 return storage_partition; | 530 return storage_partition; |
| 537 } | 531 } |
| 538 | 532 |
| 539 base::FilePath StoragePartitionImpl::GetPath() { | 533 base::FilePath StoragePartitionImpl::GetPath() { |
| 540 return partition_path_; | 534 return partition_path_; |
| 541 } | 535 } |
| 542 | 536 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 const base::Closure& callback) { | 623 const base::Closure& callback) { |
| 630 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 624 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 631 DataDeletionHelper* helper = new DataDeletionHelper(remove_mask, | 625 DataDeletionHelper* helper = new DataDeletionHelper(remove_mask, |
| 632 quota_storage_remove_mask, | 626 quota_storage_remove_mask, |
| 633 callback); | 627 callback); |
| 634 // |helper| deletes itself when done in | 628 // |helper| deletes itself when done in |
| 635 // DataDeletionHelper::DecrementTaskCountOnUI(). | 629 // DataDeletionHelper::DecrementTaskCountOnUI(). |
| 636 helper->ClearDataOnUIThread( | 630 helper->ClearDataOnUIThread( |
| 637 storage_origin, origin_matcher, cookie_matcher, GetPath(), rq_context, | 631 storage_origin, origin_matcher, cookie_matcher, GetPath(), rq_context, |
| 638 dom_storage_context_.get(), quota_manager_.get(), | 632 dom_storage_context_.get(), quota_manager_.get(), |
| 639 special_storage_policy_.get(), webrtc_identity_store_.get(), | 633 special_storage_policy_.get(), filesystem_context_.get(), begin, end); |
| 640 filesystem_context_.get(), begin, end); | |
| 641 } | 634 } |
| 642 | 635 |
| 643 void StoragePartitionImpl:: | 636 void StoragePartitionImpl:: |
| 644 QuotaManagedDataDeletionHelper::IncrementTaskCountOnIO() { | 637 QuotaManagedDataDeletionHelper::IncrementTaskCountOnIO() { |
| 645 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 638 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 646 ++task_count; | 639 ++task_count; |
| 647 } | 640 } |
| 648 | 641 |
| 649 void StoragePartitionImpl:: | 642 void StoragePartitionImpl:: |
| 650 QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO() { | 643 QuotaManagedDataDeletionHelper::DecrementTaskCountOnIO() { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 | 762 |
| 770 void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread( | 763 void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread( |
| 771 const GURL& storage_origin, | 764 const GURL& storage_origin, |
| 772 const OriginMatcherFunction& origin_matcher, | 765 const OriginMatcherFunction& origin_matcher, |
| 773 const CookieMatcherFunction& cookie_matcher, | 766 const CookieMatcherFunction& cookie_matcher, |
| 774 const base::FilePath& path, | 767 const base::FilePath& path, |
| 775 net::URLRequestContextGetter* rq_context, | 768 net::URLRequestContextGetter* rq_context, |
| 776 DOMStorageContextWrapper* dom_storage_context, | 769 DOMStorageContextWrapper* dom_storage_context, |
| 777 storage::QuotaManager* quota_manager, | 770 storage::QuotaManager* quota_manager, |
| 778 storage::SpecialStoragePolicy* special_storage_policy, | 771 storage::SpecialStoragePolicy* special_storage_policy, |
| 779 WebRTCIdentityStore* webrtc_identity_store, | |
| 780 storage::FileSystemContext* filesystem_context, | 772 storage::FileSystemContext* filesystem_context, |
| 781 const base::Time begin, | 773 const base::Time begin, |
| 782 const base::Time end) { | 774 const base::Time end) { |
| 783 DCHECK_NE(remove_mask, 0u); | 775 DCHECK_NE(remove_mask, 0u); |
| 784 DCHECK(!callback.is_null()); | 776 DCHECK(!callback.is_null()); |
| 785 | 777 |
| 786 IncrementTaskCountOnUI(); | 778 IncrementTaskCountOnUI(); |
| 787 base::Closure decrement_callback = base::Bind( | 779 base::Closure decrement_callback = base::Bind( |
| 788 &DataDeletionHelper::DecrementTaskCountOnUI, base::Unretained(this)); | 780 &DataDeletionHelper::DecrementTaskCountOnUI, base::Unretained(this)); |
| 789 | 781 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 } | 831 } |
| 840 | 832 |
| 841 if (remove_mask & REMOVE_DATA_MASK_SHADER_CACHE) { | 833 if (remove_mask & REMOVE_DATA_MASK_SHADER_CACHE) { |
| 842 IncrementTaskCountOnUI(); | 834 IncrementTaskCountOnUI(); |
| 843 BrowserThread::PostTask( | 835 BrowserThread::PostTask( |
| 844 BrowserThread::IO, FROM_HERE, | 836 BrowserThread::IO, FROM_HERE, |
| 845 base::Bind(&ClearShaderCacheOnIOThread, | 837 base::Bind(&ClearShaderCacheOnIOThread, |
| 846 path, begin, end, decrement_callback)); | 838 path, begin, end, decrement_callback)); |
| 847 } | 839 } |
| 848 | 840 |
| 849 if (remove_mask & REMOVE_DATA_MASK_WEBRTC_IDENTITY) { | |
| 850 IncrementTaskCountOnUI(); | |
| 851 BrowserThread::PostTask( | |
| 852 BrowserThread::IO, | |
| 853 FROM_HERE, | |
| 854 base::Bind(&WebRTCIdentityStore::DeleteBetween, | |
| 855 webrtc_identity_store, | |
| 856 begin, | |
| 857 end, | |
| 858 decrement_callback)); | |
| 859 } | |
| 860 | |
| 861 #if defined(ENABLE_PLUGINS) | 841 #if defined(ENABLE_PLUGINS) |
| 862 if (remove_mask & REMOVE_DATA_MASK_PLUGIN_PRIVATE_DATA) { | 842 if (remove_mask & REMOVE_DATA_MASK_PLUGIN_PRIVATE_DATA) { |
| 863 IncrementTaskCountOnUI(); | 843 IncrementTaskCountOnUI(); |
| 864 filesystem_context->default_file_task_runner()->PostTask( | 844 filesystem_context->default_file_task_runner()->PostTask( |
| 865 FROM_HERE, base::Bind(&ClearPluginPrivateDataOnFileTaskRunner, | 845 FROM_HERE, base::Bind(&ClearPluginPrivateDataOnFileTaskRunner, |
| 866 make_scoped_refptr(filesystem_context), | 846 make_scoped_refptr(filesystem_context), |
| 867 storage_origin, begin, end, decrement_callback)); | 847 storage_origin, begin, end, decrement_callback)); |
| 868 } | 848 } |
| 869 #endif // defined(ENABLE_PLUGINS) | 849 #endif // defined(ENABLE_PLUGINS) |
| 870 | 850 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(), origin_matcher, | 888 ClearDataImpl(remove_mask, quota_storage_remove_mask, GURL(), origin_matcher, |
| 909 cookie_matcher, GetURLRequestContext(), begin, end, callback); | 889 cookie_matcher, GetURLRequestContext(), begin, end, callback); |
| 910 } | 890 } |
| 911 | 891 |
| 912 void StoragePartitionImpl::Flush() { | 892 void StoragePartitionImpl::Flush() { |
| 913 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 893 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 914 if (GetDOMStorageContext()) | 894 if (GetDOMStorageContext()) |
| 915 GetDOMStorageContext()->Flush(); | 895 GetDOMStorageContext()->Flush(); |
| 916 } | 896 } |
| 917 | 897 |
| 918 WebRTCIdentityStore* StoragePartitionImpl::GetWebRTCIdentityStore() { | |
| 919 return webrtc_identity_store_.get(); | |
| 920 } | |
| 921 | |
| 922 BrowserContext* StoragePartitionImpl::browser_context() const { | 898 BrowserContext* StoragePartitionImpl::browser_context() const { |
| 923 return browser_context_; | 899 return browser_context_; |
| 924 } | 900 } |
| 925 | 901 |
| 926 void StoragePartitionImpl::Bind( | 902 void StoragePartitionImpl::Bind( |
| 927 mojo::InterfaceRequest<mojom::StoragePartitionService> request) { | 903 mojo::InterfaceRequest<mojom::StoragePartitionService> request) { |
| 928 bindings_.AddBinding(this, std::move(request)); | 904 bindings_.AddBinding(this, std::move(request)); |
| 929 } | 905 } |
| 930 | 906 |
| 931 void StoragePartitionImpl::OverrideQuotaManagerForTesting( | 907 void StoragePartitionImpl::OverrideQuotaManagerForTesting( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 942 net::URLRequestContextGetter* url_request_context) { | 918 net::URLRequestContextGetter* url_request_context) { |
| 943 url_request_context_ = url_request_context; | 919 url_request_context_ = url_request_context; |
| 944 } | 920 } |
| 945 | 921 |
| 946 void StoragePartitionImpl::SetMediaURLRequestContext( | 922 void StoragePartitionImpl::SetMediaURLRequestContext( |
| 947 net::URLRequestContextGetter* media_url_request_context) { | 923 net::URLRequestContextGetter* media_url_request_context) { |
| 948 media_url_request_context_ = media_url_request_context; | 924 media_url_request_context_ = media_url_request_context; |
| 949 } | 925 } |
| 950 | 926 |
| 951 } // namespace content | 927 } // namespace content |
| OLD | NEW |