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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 DOMStorageContextWrapper* dom_storage_context, | 371 DOMStorageContextWrapper* dom_storage_context, |
372 IndexedDBContextImpl* indexed_db_context, | 372 IndexedDBContextImpl* indexed_db_context, |
373 CacheStorageContextImpl* cache_storage_context, | 373 CacheStorageContextImpl* cache_storage_context, |
374 ServiceWorkerContextWrapper* service_worker_context, | 374 ServiceWorkerContextWrapper* service_worker_context, |
375 WebRTCIdentityStore* webrtc_identity_store, | 375 WebRTCIdentityStore* webrtc_identity_store, |
376 storage::SpecialStoragePolicy* special_storage_policy, | 376 storage::SpecialStoragePolicy* special_storage_policy, |
377 GeofencingManager* geofencing_manager, | 377 GeofencingManager* geofencing_manager, |
378 HostZoomLevelContext* host_zoom_level_context, | 378 HostZoomLevelContext* host_zoom_level_context, |
379 NavigatorConnectContextImpl* navigator_connect_context, | 379 NavigatorConnectContextImpl* navigator_connect_context, |
380 PlatformNotificationContextImpl* platform_notification_context, | 380 PlatformNotificationContextImpl* platform_notification_context, |
381 BackgroundSyncContextImpl* background_sync_context) | 381 BackgroundSyncContextImpl* background_sync_context, |
| 382 StashedPortManager* stashed_port_manager) |
382 : partition_path_(partition_path), | 383 : partition_path_(partition_path), |
383 quota_manager_(quota_manager), | 384 quota_manager_(quota_manager), |
384 appcache_service_(appcache_service), | 385 appcache_service_(appcache_service), |
385 filesystem_context_(filesystem_context), | 386 filesystem_context_(filesystem_context), |
386 database_tracker_(database_tracker), | 387 database_tracker_(database_tracker), |
387 dom_storage_context_(dom_storage_context), | 388 dom_storage_context_(dom_storage_context), |
388 indexed_db_context_(indexed_db_context), | 389 indexed_db_context_(indexed_db_context), |
389 cache_storage_context_(cache_storage_context), | 390 cache_storage_context_(cache_storage_context), |
390 service_worker_context_(service_worker_context), | 391 service_worker_context_(service_worker_context), |
391 webrtc_identity_store_(webrtc_identity_store), | 392 webrtc_identity_store_(webrtc_identity_store), |
392 special_storage_policy_(special_storage_policy), | 393 special_storage_policy_(special_storage_policy), |
393 geofencing_manager_(geofencing_manager), | 394 geofencing_manager_(geofencing_manager), |
394 host_zoom_level_context_(host_zoom_level_context), | 395 host_zoom_level_context_(host_zoom_level_context), |
395 navigator_connect_context_(navigator_connect_context), | 396 navigator_connect_context_(navigator_connect_context), |
396 platform_notification_context_(platform_notification_context), | 397 platform_notification_context_(platform_notification_context), |
397 background_sync_context_(background_sync_context), | 398 background_sync_context_(background_sync_context), |
| 399 stashed_port_manager_(stashed_port_manager), |
398 browser_context_(browser_context) { | 400 browser_context_(browser_context) { |
399 } | 401 } |
400 | 402 |
401 StoragePartitionImpl::~StoragePartitionImpl() { | 403 StoragePartitionImpl::~StoragePartitionImpl() { |
402 browser_context_ = nullptr; | 404 browser_context_ = nullptr; |
403 | 405 |
404 // These message loop checks are just to avoid leaks in unittests. | 406 // These message loop checks are just to avoid leaks in unittests. |
405 if (GetDatabaseTracker() && | 407 if (GetDatabaseTracker() && |
406 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { | 408 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { |
407 BrowserThread::PostTask( | 409 BrowserThread::PostTask( |
(...skipping 15 matching lines...) Expand all Loading... |
423 GetCacheStorageContext()->Shutdown(); | 425 GetCacheStorageContext()->Shutdown(); |
424 | 426 |
425 if (GetGeofencingManager()) | 427 if (GetGeofencingManager()) |
426 GetGeofencingManager()->Shutdown(); | 428 GetGeofencingManager()->Shutdown(); |
427 | 429 |
428 if (GetPlatformNotificationContext()) | 430 if (GetPlatformNotificationContext()) |
429 GetPlatformNotificationContext()->Shutdown(); | 431 GetPlatformNotificationContext()->Shutdown(); |
430 | 432 |
431 if (GetBackgroundSyncContext()) | 433 if (GetBackgroundSyncContext()) |
432 GetBackgroundSyncContext()->Shutdown(); | 434 GetBackgroundSyncContext()->Shutdown(); |
| 435 |
| 436 if (GetStashedPortManager()) |
| 437 GetStashedPortManager()->Shutdown(); |
433 } | 438 } |
434 | 439 |
435 StoragePartitionImpl* StoragePartitionImpl::Create( | 440 StoragePartitionImpl* StoragePartitionImpl::Create( |
436 BrowserContext* context, | 441 BrowserContext* context, |
437 bool in_memory, | 442 bool in_memory, |
438 const base::FilePath& partition_path) { | 443 const base::FilePath& partition_path) { |
439 // Ensure that these methods are called on the UI thread, except for | 444 // Ensure that these methods are called on the UI thread, except for |
440 // unittests where a UI thread might not have been created. | 445 // unittests where a UI thread might not have been created. |
441 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 446 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
442 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); | 447 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 new NavigatorConnectServiceWorkerServiceFactory(service_worker_context))); | 523 new NavigatorConnectServiceWorkerServiceFactory(service_worker_context))); |
519 | 524 |
520 scoped_refptr<PlatformNotificationContextImpl> platform_notification_context = | 525 scoped_refptr<PlatformNotificationContextImpl> platform_notification_context = |
521 new PlatformNotificationContextImpl(path, service_worker_context); | 526 new PlatformNotificationContextImpl(path, service_worker_context); |
522 platform_notification_context->Initialize(); | 527 platform_notification_context->Initialize(); |
523 | 528 |
524 scoped_refptr<BackgroundSyncContextImpl> background_sync_context = | 529 scoped_refptr<BackgroundSyncContextImpl> background_sync_context = |
525 new BackgroundSyncContextImpl(); | 530 new BackgroundSyncContextImpl(); |
526 background_sync_context->Init(service_worker_context); | 531 background_sync_context->Init(service_worker_context); |
527 | 532 |
| 533 scoped_refptr<StashedPortManager> stashed_port_manager = |
| 534 new StashedPortManager(service_worker_context); |
| 535 stashed_port_manager->Init(); |
| 536 |
528 StoragePartitionImpl* storage_partition = new StoragePartitionImpl( | 537 StoragePartitionImpl* storage_partition = new StoragePartitionImpl( |
529 context, partition_path, quota_manager.get(), appcache_service.get(), | 538 context, partition_path, quota_manager.get(), appcache_service.get(), |
530 filesystem_context.get(), database_tracker.get(), | 539 filesystem_context.get(), database_tracker.get(), |
531 dom_storage_context.get(), indexed_db_context.get(), | 540 dom_storage_context.get(), indexed_db_context.get(), |
532 cache_storage_context.get(), service_worker_context.get(), | 541 cache_storage_context.get(), service_worker_context.get(), |
533 webrtc_identity_store.get(), special_storage_policy.get(), | 542 webrtc_identity_store.get(), special_storage_policy.get(), |
534 geofencing_manager.get(), host_zoom_level_context.get(), | 543 geofencing_manager.get(), host_zoom_level_context.get(), |
535 navigator_connect_context.get(), platform_notification_context.get(), | 544 navigator_connect_context.get(), platform_notification_context.get(), |
536 background_sync_context.get()); | 545 background_sync_context.get(), stashed_port_manager.get()); |
537 | 546 |
538 service_worker_context->set_storage_partition(storage_partition); | 547 service_worker_context->set_storage_partition(storage_partition); |
539 | 548 |
540 return storage_partition; | 549 return storage_partition; |
541 } | 550 } |
542 | 551 |
543 base::FilePath StoragePartitionImpl::GetPath() { | 552 base::FilePath StoragePartitionImpl::GetPath() { |
544 return partition_path_; | 553 return partition_path_; |
545 } | 554 } |
546 | 555 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 | 619 |
611 PlatformNotificationContextImpl* | 620 PlatformNotificationContextImpl* |
612 StoragePartitionImpl::GetPlatformNotificationContext() { | 621 StoragePartitionImpl::GetPlatformNotificationContext() { |
613 return platform_notification_context_.get(); | 622 return platform_notification_context_.get(); |
614 } | 623 } |
615 | 624 |
616 BackgroundSyncContextImpl* StoragePartitionImpl::GetBackgroundSyncContext() { | 625 BackgroundSyncContextImpl* StoragePartitionImpl::GetBackgroundSyncContext() { |
617 return background_sync_context_.get(); | 626 return background_sync_context_.get(); |
618 } | 627 } |
619 | 628 |
| 629 StashedPortManager* StoragePartitionImpl::GetStashedPortManager() { |
| 630 return stashed_port_manager_.get(); |
| 631 } |
| 632 |
620 void StoragePartitionImpl::ClearDataImpl( | 633 void StoragePartitionImpl::ClearDataImpl( |
621 uint32 remove_mask, | 634 uint32 remove_mask, |
622 uint32 quota_storage_remove_mask, | 635 uint32 quota_storage_remove_mask, |
623 const GURL& storage_origin, | 636 const GURL& storage_origin, |
624 const OriginMatcherFunction& origin_matcher, | 637 const OriginMatcherFunction& origin_matcher, |
625 net::URLRequestContextGetter* rq_context, | 638 net::URLRequestContextGetter* rq_context, |
626 const base::Time begin, | 639 const base::Time begin, |
627 const base::Time end, | 640 const base::Time end, |
628 const base::Closure& callback) { | 641 const base::Closure& callback) { |
629 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 642 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 net::URLRequestContextGetter* url_request_context) { | 938 net::URLRequestContextGetter* url_request_context) { |
926 url_request_context_ = url_request_context; | 939 url_request_context_ = url_request_context; |
927 } | 940 } |
928 | 941 |
929 void StoragePartitionImpl::SetMediaURLRequestContext( | 942 void StoragePartitionImpl::SetMediaURLRequestContext( |
930 net::URLRequestContextGetter* media_url_request_context) { | 943 net::URLRequestContextGetter* media_url_request_context) { |
931 media_url_request_context_ = media_url_request_context; | 944 media_url_request_context_ = media_url_request_context; |
932 } | 945 } |
933 | 946 |
934 } // namespace content | 947 } // namespace content |
OLD | NEW |