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

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

Issue 645763003: Refactor GeofencingManager to have one instance per StoragePartition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: have reference to service worker context in geofencing manager Created 6 years, 2 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
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"
11 #include "content/browser/geofencing/geofencing_manager.h"
11 #include "content/browser/gpu/shader_disk_cache.h" 12 #include "content/browser/gpu/shader_disk_cache.h"
12 #include "content/common/dom_storage/dom_storage_types.h" 13 #include "content/common/dom_storage/dom_storage_types.h"
13 #include "content/public/browser/browser_context.h" 14 #include "content/public/browser/browser_context.h"
14 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/dom_storage_context.h" 16 #include "content/public/browser/dom_storage_context.h"
16 #include "content/public/browser/indexed_db_context.h" 17 #include "content/public/browser/indexed_db_context.h"
17 #include "content/public/browser/local_storage_usage_info.h" 18 #include "content/public/browser/local_storage_usage_info.h"
18 #include "content/public/browser/session_storage_usage_info.h" 19 #include "content/public/browser/session_storage_usage_info.h"
19 #include "net/base/completion_callback.h" 20 #include "net/base/completion_callback.h"
20 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 StoragePartitionImpl::StoragePartitionImpl( 356 StoragePartitionImpl::StoragePartitionImpl(
356 const base::FilePath& partition_path, 357 const base::FilePath& partition_path,
357 storage::QuotaManager* quota_manager, 358 storage::QuotaManager* quota_manager,
358 ChromeAppCacheService* appcache_service, 359 ChromeAppCacheService* appcache_service,
359 storage::FileSystemContext* filesystem_context, 360 storage::FileSystemContext* filesystem_context,
360 storage::DatabaseTracker* database_tracker, 361 storage::DatabaseTracker* database_tracker,
361 DOMStorageContextWrapper* dom_storage_context, 362 DOMStorageContextWrapper* dom_storage_context,
362 IndexedDBContextImpl* indexed_db_context, 363 IndexedDBContextImpl* indexed_db_context,
363 ServiceWorkerContextWrapper* service_worker_context, 364 ServiceWorkerContextWrapper* service_worker_context,
364 WebRTCIdentityStore* webrtc_identity_store, 365 WebRTCIdentityStore* webrtc_identity_store,
365 storage::SpecialStoragePolicy* special_storage_policy) 366 storage::SpecialStoragePolicy* special_storage_policy,
367 GeofencingManager* geofencing_manager)
366 : partition_path_(partition_path), 368 : partition_path_(partition_path),
367 quota_manager_(quota_manager), 369 quota_manager_(quota_manager),
368 appcache_service_(appcache_service), 370 appcache_service_(appcache_service),
369 filesystem_context_(filesystem_context), 371 filesystem_context_(filesystem_context),
370 database_tracker_(database_tracker), 372 database_tracker_(database_tracker),
371 dom_storage_context_(dom_storage_context), 373 dom_storage_context_(dom_storage_context),
372 indexed_db_context_(indexed_db_context), 374 indexed_db_context_(indexed_db_context),
373 service_worker_context_(service_worker_context), 375 service_worker_context_(service_worker_context),
374 webrtc_identity_store_(webrtc_identity_store), 376 webrtc_identity_store_(webrtc_identity_store),
375 special_storage_policy_(special_storage_policy) { 377 special_storage_policy_(special_storage_policy),
378 geofencing_manager_(geofencing_manager) {
376 } 379 }
377 380
378 StoragePartitionImpl::~StoragePartitionImpl() { 381 StoragePartitionImpl::~StoragePartitionImpl() {
379 // These message loop checks are just to avoid leaks in unittests. 382 // These message loop checks are just to avoid leaks in unittests.
380 if (GetDatabaseTracker() && 383 if (GetDatabaseTracker() &&
381 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { 384 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) {
382 BrowserThread::PostTask( 385 BrowserThread::PostTask(
383 BrowserThread::FILE, 386 BrowserThread::FILE,
384 FROM_HERE, 387 FROM_HERE,
385 base::Bind(&storage::DatabaseTracker::Shutdown, GetDatabaseTracker())); 388 base::Bind(&storage::DatabaseTracker::Shutdown, GetDatabaseTracker()));
386 } 389 }
387 390
388 if (GetFileSystemContext()) 391 if (GetFileSystemContext())
389 GetFileSystemContext()->Shutdown(); 392 GetFileSystemContext()->Shutdown();
390 393
391 if (GetDOMStorageContext()) 394 if (GetDOMStorageContext())
392 GetDOMStorageContext()->Shutdown(); 395 GetDOMStorageContext()->Shutdown();
393 396
394 if (GetServiceWorkerContext()) 397 if (GetServiceWorkerContext())
395 GetServiceWorkerContext()->Shutdown(); 398 GetServiceWorkerContext()->Shutdown();
399
400 if (GetGeofencingManager())
401 GetGeofencingManager()->Shutdown();
396 } 402 }
397 403
398 // TODO(ajwong): Break the direct dependency on |context|. We only 404 // TODO(ajwong): Break the direct dependency on |context|. We only
399 // need 3 pieces of info from it. 405 // need 3 pieces of info from it.
400 StoragePartitionImpl* StoragePartitionImpl::Create( 406 StoragePartitionImpl* StoragePartitionImpl::Create(
401 BrowserContext* context, 407 BrowserContext* context,
402 bool in_memory, 408 bool in_memory,
403 const base::FilePath& partition_path) { 409 const base::FilePath& partition_path) {
404 // Ensure that these methods are called on the UI thread, except for 410 // Ensure that these methods are called on the UI thread, except for
405 // unittests where a UI thread might not have been created. 411 // unittests where a UI thread might not have been created.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 462
457 scoped_refptr<ChromeAppCacheService> appcache_service = 463 scoped_refptr<ChromeAppCacheService> appcache_service =
458 new ChromeAppCacheService(quota_manager->proxy()); 464 new ChromeAppCacheService(quota_manager->proxy());
459 465
460 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store( 466 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store(
461 new WebRTCIdentityStore(path, context->GetSpecialStoragePolicy())); 467 new WebRTCIdentityStore(path, context->GetSpecialStoragePolicy()));
462 468
463 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy( 469 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy(
464 context->GetSpecialStoragePolicy()); 470 context->GetSpecialStoragePolicy());
465 471
472 scoped_refptr<GeofencingManager> geofencing_manager =
473 new GeofencingManager(service_worker_context);
474 geofencing_manager->Init();
475
466 return new StoragePartitionImpl(partition_path, 476 return new StoragePartitionImpl(partition_path,
467 quota_manager.get(), 477 quota_manager.get(),
468 appcache_service.get(), 478 appcache_service.get(),
469 filesystem_context.get(), 479 filesystem_context.get(),
470 database_tracker.get(), 480 database_tracker.get(),
471 dom_storage_context.get(), 481 dom_storage_context.get(),
472 indexed_db_context.get(), 482 indexed_db_context.get(),
473 service_worker_context.get(), 483 service_worker_context.get(),
474 webrtc_identity_store.get(), 484 webrtc_identity_store.get(),
475 special_storage_policy.get()); 485 special_storage_policy.get(),
486 geofencing_manager.get());
476 } 487 }
477 488
478 base::FilePath StoragePartitionImpl::GetPath() { 489 base::FilePath StoragePartitionImpl::GetPath() {
479 return partition_path_; 490 return partition_path_;
480 } 491 }
481 492
482 net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() { 493 net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() {
483 return url_request_context_.get(); 494 return url_request_context_.get();
484 } 495 }
485 496
(...skipping 23 matching lines...) Expand all
509 } 520 }
510 521
511 IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() { 522 IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() {
512 return indexed_db_context_.get(); 523 return indexed_db_context_.get();
513 } 524 }
514 525
515 ServiceWorkerContextWrapper* StoragePartitionImpl::GetServiceWorkerContext() { 526 ServiceWorkerContextWrapper* StoragePartitionImpl::GetServiceWorkerContext() {
516 return service_worker_context_.get(); 527 return service_worker_context_.get();
517 } 528 }
518 529
530 GeofencingManager* StoragePartitionImpl::GetGeofencingManager() {
531 return geofencing_manager_.get();
532 }
533
519 void StoragePartitionImpl::ClearDataImpl( 534 void StoragePartitionImpl::ClearDataImpl(
520 uint32 remove_mask, 535 uint32 remove_mask,
521 uint32 quota_storage_remove_mask, 536 uint32 quota_storage_remove_mask,
522 const GURL& storage_origin, 537 const GURL& storage_origin,
523 const OriginMatcherFunction& origin_matcher, 538 const OriginMatcherFunction& origin_matcher,
524 net::URLRequestContextGetter* rq_context, 539 net::URLRequestContextGetter* rq_context,
525 const base::Time begin, 540 const base::Time begin,
526 const base::Time end, 541 const base::Time end,
527 const base::Closure& callback) { 542 const base::Closure& callback) {
528 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 543 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 net::URLRequestContextGetter* url_request_context) { 835 net::URLRequestContextGetter* url_request_context) {
821 url_request_context_ = url_request_context; 836 url_request_context_ = url_request_context;
822 } 837 }
823 838
824 void StoragePartitionImpl::SetMediaURLRequestContext( 839 void StoragePartitionImpl::SetMediaURLRequestContext(
825 net::URLRequestContextGetter* media_url_request_context) { 840 net::URLRequestContextGetter* media_url_request_context) {
826 media_url_request_context_ = media_url_request_context; 841 media_url_request_context_ = media_url_request_context;
827 } 842 }
828 843
829 } // namespace content 844 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698