Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(524)

Side by Side Diff: content/browser/storage_partition_impl.cc

Issue 852463002: Keep track of ServiceWorkerContext's BrowserContext and expose it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nullptr
Patch Set: remove include Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/storage_partition_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 new GeofencingManager(service_worker_context); 486 new GeofencingManager(service_worker_context);
485 geofencing_manager->Init(); 487 geofencing_manager->Init();
486 488
487 scoped_refptr<HostZoomLevelContext> host_zoom_level_context( 489 scoped_refptr<HostZoomLevelContext> host_zoom_level_context(
488 new HostZoomLevelContext( 490 new HostZoomLevelContext(
489 context->CreateZoomLevelDelegate(partition_path))); 491 context->CreateZoomLevelDelegate(partition_path)));
490 492
491 scoped_refptr<NavigatorConnectContext> navigator_connect_context = 493 scoped_refptr<NavigatorConnectContext> navigator_connect_context =
492 new NavigatorConnectContext(service_worker_context); 494 new NavigatorConnectContext(service_worker_context);
493 495
494 return new StoragePartitionImpl( 496 StoragePartitionImpl* storage_partition = new StoragePartitionImpl(
495 partition_path, quota_manager.get(), appcache_service.get(), 497 context, partition_path, quota_manager.get(), appcache_service.get(),
496 filesystem_context.get(), database_tracker.get(), 498 filesystem_context.get(), database_tracker.get(),
497 dom_storage_context.get(), indexed_db_context.get(), 499 dom_storage_context.get(), indexed_db_context.get(),
498 service_worker_context.get(), webrtc_identity_store.get(), 500 service_worker_context.get(), webrtc_identity_store.get(),
499 special_storage_policy.get(), geofencing_manager.get(), 501 special_storage_policy.get(), geofencing_manager.get(),
500 host_zoom_level_context.get(), navigator_connect_context.get()); 502 host_zoom_level_context.get(), navigator_connect_context.get());
503
504 service_worker_context->set_storage_partition(storage_partition);
505
506 return storage_partition;
501 } 507 }
502 508
503 base::FilePath StoragePartitionImpl::GetPath() { 509 base::FilePath StoragePartitionImpl::GetPath() {
504 return partition_path_; 510 return partition_path_;
505 } 511 }
506 512
507 net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() { 513 net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() {
508 return url_request_context_.get(); 514 return url_request_context_.get();
509 } 515 }
510 516
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 const base::Time end, 852 const base::Time end,
847 const base::Closure& callback) { 853 const base::Closure& callback) {
848 ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin, 854 ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin,
849 origin_matcher, GetURLRequestContext(), begin, end, callback); 855 origin_matcher, GetURLRequestContext(), begin, end, callback);
850 } 856 }
851 857
852 WebRTCIdentityStore* StoragePartitionImpl::GetWebRTCIdentityStore() { 858 WebRTCIdentityStore* StoragePartitionImpl::GetWebRTCIdentityStore() {
853 return webrtc_identity_store_.get(); 859 return webrtc_identity_store_.get();
854 } 860 }
855 861
862 BrowserContext* StoragePartitionImpl::browser_context() const {
863 return browser_context_;
864 }
865
856 void StoragePartitionImpl::OverrideQuotaManagerForTesting( 866 void StoragePartitionImpl::OverrideQuotaManagerForTesting(
857 storage::QuotaManager* quota_manager) { 867 storage::QuotaManager* quota_manager) {
858 quota_manager_ = quota_manager; 868 quota_manager_ = quota_manager;
859 } 869 }
860 870
861 void StoragePartitionImpl::OverrideSpecialStoragePolicyForTesting( 871 void StoragePartitionImpl::OverrideSpecialStoragePolicyForTesting(
862 storage::SpecialStoragePolicy* special_storage_policy) { 872 storage::SpecialStoragePolicy* special_storage_policy) {
863 special_storage_policy_ = special_storage_policy; 873 special_storage_policy_ = special_storage_policy;
864 } 874 }
865 875
866 void StoragePartitionImpl::SetURLRequestContext( 876 void StoragePartitionImpl::SetURLRequestContext(
867 net::URLRequestContextGetter* url_request_context) { 877 net::URLRequestContextGetter* url_request_context) {
868 url_request_context_ = url_request_context; 878 url_request_context_ = url_request_context;
869 } 879 }
870 880
871 void StoragePartitionImpl::SetMediaURLRequestContext( 881 void StoragePartitionImpl::SetMediaURLRequestContext(
872 net::URLRequestContextGetter* media_url_request_context) { 882 net::URLRequestContextGetter* media_url_request_context) {
873 media_url_request_context_ = media_url_request_context; 883 media_url_request_context_ = media_url_request_context;
874 } 884 }
875 885
876 } // namespace content 886 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/storage_partition_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698