Chromium Code Reviews| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 new StoragePartitionImpl::QuotaManagedDataDeletionHelper( | 353 new StoragePartitionImpl::QuotaManagedDataDeletionHelper( |
| 354 remove_mask, | 354 remove_mask, |
| 355 quota_storage_remove_mask, | 355 quota_storage_remove_mask, |
| 356 storage_origin, | 356 storage_origin, |
| 357 callback); | 357 callback); |
| 358 helper->ClearDataOnIOThread(quota_manager, begin, special_storage_policy, | 358 helper->ClearDataOnIOThread(quota_manager, begin, special_storage_policy, |
| 359 origin_matcher); | 359 origin_matcher); |
| 360 } | 360 } |
| 361 | 361 |
| 362 StoragePartitionImpl::StoragePartitionImpl( | 362 StoragePartitionImpl::StoragePartitionImpl( |
| 363 BrowserContext* browser_context, | |
| 363 const base::FilePath& partition_path, | 364 const base::FilePath& partition_path, |
| 364 storage::QuotaManager* quota_manager, | 365 storage::QuotaManager* quota_manager, |
| 365 ChromeAppCacheService* appcache_service, | 366 ChromeAppCacheService* appcache_service, |
| 366 storage::FileSystemContext* filesystem_context, | 367 storage::FileSystemContext* filesystem_context, |
| 367 storage::DatabaseTracker* database_tracker, | 368 storage::DatabaseTracker* database_tracker, |
| 368 DOMStorageContextWrapper* dom_storage_context, | 369 DOMStorageContextWrapper* dom_storage_context, |
| 369 IndexedDBContextImpl* indexed_db_context, | 370 IndexedDBContextImpl* indexed_db_context, |
| 370 ServiceWorkerContextWrapper* service_worker_context, | 371 ServiceWorkerContextWrapper* service_worker_context, |
| 371 WebRTCIdentityStore* webrtc_identity_store, | 372 WebRTCIdentityStore* webrtc_identity_store, |
| 372 storage::SpecialStoragePolicy* special_storage_policy, | 373 storage::SpecialStoragePolicy* special_storage_policy, |
| 373 GeofencingManager* geofencing_manager, | 374 GeofencingManager* geofencing_manager, |
| 374 HostZoomLevelContext* host_zoom_level_context, | 375 HostZoomLevelContext* host_zoom_level_context, |
| 375 NavigatorConnectContext* navigator_connect_context) | 376 NavigatorConnectContext* navigator_connect_context) |
| 376 : partition_path_(partition_path), | 377 : partition_path_(partition_path), |
| 377 quota_manager_(quota_manager), | 378 quota_manager_(quota_manager), |
| 378 appcache_service_(appcache_service), | 379 appcache_service_(appcache_service), |
| 379 filesystem_context_(filesystem_context), | 380 filesystem_context_(filesystem_context), |
| 380 database_tracker_(database_tracker), | 381 database_tracker_(database_tracker), |
| 381 dom_storage_context_(dom_storage_context), | 382 dom_storage_context_(dom_storage_context), |
| 382 indexed_db_context_(indexed_db_context), | 383 indexed_db_context_(indexed_db_context), |
| 383 service_worker_context_(service_worker_context), | 384 service_worker_context_(service_worker_context), |
| 384 webrtc_identity_store_(webrtc_identity_store), | 385 webrtc_identity_store_(webrtc_identity_store), |
| 385 special_storage_policy_(special_storage_policy), | 386 special_storage_policy_(special_storage_policy), |
| 386 geofencing_manager_(geofencing_manager), | 387 geofencing_manager_(geofencing_manager), |
| 387 host_zoom_level_context_(host_zoom_level_context), | 388 host_zoom_level_context_(host_zoom_level_context), |
| 388 navigator_connect_context_(navigator_connect_context) { | 389 navigator_connect_context_(navigator_connect_context), |
| 390 browser_context_(browser_context) { | |
| 389 } | 391 } |
| 390 | 392 |
| 391 StoragePartitionImpl::~StoragePartitionImpl() { | 393 StoragePartitionImpl::~StoragePartitionImpl() { |
| 394 browser_context_ = nullptr; | |
| 395 | |
| 392 // These message loop checks are just to avoid leaks in unittests. | 396 // These message loop checks are just to avoid leaks in unittests. |
| 393 if (GetDatabaseTracker() && | 397 if (GetDatabaseTracker() && |
| 394 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { | 398 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { |
| 395 BrowserThread::PostTask( | 399 BrowserThread::PostTask( |
| 396 BrowserThread::FILE, | 400 BrowserThread::FILE, |
| 397 FROM_HERE, | 401 FROM_HERE, |
| 398 base::Bind(&storage::DatabaseTracker::Shutdown, GetDatabaseTracker())); | 402 base::Bind(&storage::DatabaseTracker::Shutdown, GetDatabaseTracker())); |
| 399 } | 403 } |
| 400 | 404 |
| 401 if (GetFileSystemContext()) | 405 if (GetFileSystemContext()) |
| 402 GetFileSystemContext()->Shutdown(); | 406 GetFileSystemContext()->Shutdown(); |
| 403 | 407 |
| 404 if (GetDOMStorageContext()) | 408 if (GetDOMStorageContext()) |
| 405 GetDOMStorageContext()->Shutdown(); | 409 GetDOMStorageContext()->Shutdown(); |
| 406 | 410 |
| 407 if (GetServiceWorkerContext()) | 411 if (GetServiceWorkerContext()) |
| 408 GetServiceWorkerContext()->Shutdown(); | 412 GetServiceWorkerContext()->Shutdown(); |
| 409 | 413 |
| 410 if (GetGeofencingManager()) | 414 if (GetGeofencingManager()) |
| 411 GetGeofencingManager()->Shutdown(); | 415 GetGeofencingManager()->Shutdown(); |
| 412 } | 416 } |
| 413 | 417 |
| 414 // TODO(ajwong): Break the direct dependency on |context|. We only | |
| 415 // need 3 pieces of info from it. | |
| 416 StoragePartitionImpl* StoragePartitionImpl::Create( | 418 StoragePartitionImpl* StoragePartitionImpl::Create( |
| 417 BrowserContext* context, | 419 BrowserContext* context, |
| 418 bool in_memory, | 420 bool in_memory, |
| 419 const base::FilePath& partition_path) { | 421 const base::FilePath& partition_path) { |
| 420 // Ensure that these methods are called on the UI thread, except for | 422 // Ensure that these methods are called on the UI thread, except for |
| 421 // unittests where a UI thread might not have been created. | 423 // unittests where a UI thread might not have been created. |
| 422 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 424 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
| 423 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); | 425 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); |
| 424 | 426 |
| 425 // All of the clients have to be created and registered with the | 427 // All of the clients have to be created and registered with the |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 ->message_loop_proxy().get() | 463 ->message_loop_proxy().get() |
| 462 : NULL; | 464 : NULL; |
| 463 scoped_refptr<IndexedDBContextImpl> indexed_db_context = | 465 scoped_refptr<IndexedDBContextImpl> indexed_db_context = |
| 464 new IndexedDBContextImpl(path, | 466 new IndexedDBContextImpl(path, |
| 465 context->GetSpecialStoragePolicy(), | 467 context->GetSpecialStoragePolicy(), |
| 466 quota_manager->proxy(), | 468 quota_manager->proxy(), |
| 467 idb_task_runner); | 469 idb_task_runner); |
| 468 | 470 |
| 469 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context = | 471 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context = |
| 470 new ServiceWorkerContextWrapper(context); | 472 new ServiceWorkerContextWrapper(context); |
| 471 service_worker_context->Init( | 473 // Init() requires |storage_partition| so is done after the object is created. |
|
michaeln
2015/01/13 21:27:32
To avoid having to alter construction ordering, it
mlamouri (slow - plz ping)
2015/01/14 15:46:24
Ok. I guess we will never know if there are some s
| |
| 472 path, quota_manager->proxy(), context->GetSpecialStoragePolicy()); | |
| 473 | 474 |
| 474 scoped_refptr<ChromeAppCacheService> appcache_service = | 475 scoped_refptr<ChromeAppCacheService> appcache_service = |
| 475 new ChromeAppCacheService(quota_manager->proxy()); | 476 new ChromeAppCacheService(quota_manager->proxy()); |
| 476 | 477 |
| 477 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store( | 478 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store( |
| 478 new WebRTCIdentityStore(path, context->GetSpecialStoragePolicy())); | 479 new WebRTCIdentityStore(path, context->GetSpecialStoragePolicy())); |
| 479 | 480 |
| 480 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy( | 481 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy( |
| 481 context->GetSpecialStoragePolicy()); | 482 context->GetSpecialStoragePolicy()); |
| 482 | 483 |
| 483 scoped_refptr<GeofencingManager> geofencing_manager = | 484 scoped_refptr<GeofencingManager> geofencing_manager = |
| 484 new GeofencingManager(service_worker_context); | 485 new GeofencingManager(service_worker_context); |
| 485 geofencing_manager->Init(); | 486 geofencing_manager->Init(); |
| 486 | 487 |
| 487 scoped_refptr<HostZoomLevelContext> host_zoom_level_context( | 488 scoped_refptr<HostZoomLevelContext> host_zoom_level_context( |
| 488 new HostZoomLevelContext( | 489 new HostZoomLevelContext( |
| 489 context->CreateZoomLevelDelegate(partition_path))); | 490 context->CreateZoomLevelDelegate(partition_path))); |
| 490 | 491 |
| 491 scoped_refptr<NavigatorConnectContext> navigator_connect_context = | 492 scoped_refptr<NavigatorConnectContext> navigator_connect_context = |
| 492 new NavigatorConnectContext(service_worker_context); | 493 new NavigatorConnectContext(service_worker_context); |
| 493 | 494 |
| 494 return new StoragePartitionImpl( | 495 StoragePartitionImpl* storage_partition = new StoragePartitionImpl( |
| 495 partition_path, quota_manager.get(), appcache_service.get(), | 496 context, partition_path, quota_manager.get(), appcache_service.get(), |
| 496 filesystem_context.get(), database_tracker.get(), | 497 filesystem_context.get(), database_tracker.get(), |
| 497 dom_storage_context.get(), indexed_db_context.get(), | 498 dom_storage_context.get(), indexed_db_context.get(), |
| 498 service_worker_context.get(), webrtc_identity_store.get(), | 499 service_worker_context.get(), webrtc_identity_store.get(), |
| 499 special_storage_policy.get(), geofencing_manager.get(), | 500 special_storage_policy.get(), geofencing_manager.get(), |
| 500 host_zoom_level_context.get(), navigator_connect_context.get()); | 501 host_zoom_level_context.get(), navigator_connect_context.get()); |
| 502 | |
| 503 service_worker_context->Init(storage_partition, | |
| 504 path, | |
| 505 quota_manager->proxy(), | |
| 506 context->GetSpecialStoragePolicy()); | |
| 507 | |
| 508 return storage_partition; | |
| 501 } | 509 } |
| 502 | 510 |
| 503 base::FilePath StoragePartitionImpl::GetPath() { | 511 base::FilePath StoragePartitionImpl::GetPath() { |
| 504 return partition_path_; | 512 return partition_path_; |
| 505 } | 513 } |
| 506 | 514 |
| 507 net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() { | 515 net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() { |
| 508 return url_request_context_.get(); | 516 return url_request_context_.get(); |
| 509 } | 517 } |
| 510 | 518 |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 846 const base::Time end, | 854 const base::Time end, |
| 847 const base::Closure& callback) { | 855 const base::Closure& callback) { |
| 848 ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin, | 856 ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin, |
| 849 origin_matcher, GetURLRequestContext(), begin, end, callback); | 857 origin_matcher, GetURLRequestContext(), begin, end, callback); |
| 850 } | 858 } |
| 851 | 859 |
| 852 WebRTCIdentityStore* StoragePartitionImpl::GetWebRTCIdentityStore() { | 860 WebRTCIdentityStore* StoragePartitionImpl::GetWebRTCIdentityStore() { |
| 853 return webrtc_identity_store_.get(); | 861 return webrtc_identity_store_.get(); |
| 854 } | 862 } |
| 855 | 863 |
| 864 BrowserContext* StoragePartitionImpl::browser_context() const { | |
| 865 return browser_context_; | |
| 866 } | |
| 867 | |
| 856 void StoragePartitionImpl::OverrideQuotaManagerForTesting( | 868 void StoragePartitionImpl::OverrideQuotaManagerForTesting( |
| 857 storage::QuotaManager* quota_manager) { | 869 storage::QuotaManager* quota_manager) { |
| 858 quota_manager_ = quota_manager; | 870 quota_manager_ = quota_manager; |
| 859 } | 871 } |
| 860 | 872 |
| 861 void StoragePartitionImpl::OverrideSpecialStoragePolicyForTesting( | 873 void StoragePartitionImpl::OverrideSpecialStoragePolicyForTesting( |
| 862 storage::SpecialStoragePolicy* special_storage_policy) { | 874 storage::SpecialStoragePolicy* special_storage_policy) { |
| 863 special_storage_policy_ = special_storage_policy; | 875 special_storage_policy_ = special_storage_policy; |
| 864 } | 876 } |
| 865 | 877 |
| 866 void StoragePartitionImpl::SetURLRequestContext( | 878 void StoragePartitionImpl::SetURLRequestContext( |
| 867 net::URLRequestContextGetter* url_request_context) { | 879 net::URLRequestContextGetter* url_request_context) { |
| 868 url_request_context_ = url_request_context; | 880 url_request_context_ = url_request_context; |
| 869 } | 881 } |
| 870 | 882 |
| 871 void StoragePartitionImpl::SetMediaURLRequestContext( | 883 void StoragePartitionImpl::SetMediaURLRequestContext( |
| 872 net::URLRequestContextGetter* media_url_request_context) { | 884 net::URLRequestContextGetter* media_url_request_context) { |
| 873 media_url_request_context_ = media_url_request_context; | 885 media_url_request_context_ = media_url_request_context; |
| 874 } | 886 } |
| 875 | 887 |
| 876 } // namespace content | 888 } // namespace content |
| OLD | NEW |