| 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" |
| 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 StoragePartitionImpl::StoragePartitionImpl( | 357 StoragePartitionImpl::StoragePartitionImpl( |
| 357 const base::FilePath& partition_path, | 358 const base::FilePath& partition_path, |
| 358 storage::QuotaManager* quota_manager, | 359 storage::QuotaManager* quota_manager, |
| 359 ChromeAppCacheService* appcache_service, | 360 ChromeAppCacheService* appcache_service, |
| 360 storage::FileSystemContext* filesystem_context, | 361 storage::FileSystemContext* filesystem_context, |
| 361 storage::DatabaseTracker* database_tracker, | 362 storage::DatabaseTracker* database_tracker, |
| 362 DOMStorageContextWrapper* dom_storage_context, | 363 DOMStorageContextWrapper* dom_storage_context, |
| 363 IndexedDBContextImpl* indexed_db_context, | 364 IndexedDBContextImpl* indexed_db_context, |
| 364 ServiceWorkerContextWrapper* service_worker_context, | 365 ServiceWorkerContextWrapper* service_worker_context, |
| 365 WebRTCIdentityStore* webrtc_identity_store, | 366 WebRTCIdentityStore* webrtc_identity_store, |
| 366 storage::SpecialStoragePolicy* special_storage_policy) | 367 storage::SpecialStoragePolicy* special_storage_policy, |
| 368 GeofencingManager* geofencing_manager) |
| 367 : partition_path_(partition_path), | 369 : partition_path_(partition_path), |
| 368 quota_manager_(quota_manager), | 370 quota_manager_(quota_manager), |
| 369 appcache_service_(appcache_service), | 371 appcache_service_(appcache_service), |
| 370 filesystem_context_(filesystem_context), | 372 filesystem_context_(filesystem_context), |
| 371 database_tracker_(database_tracker), | 373 database_tracker_(database_tracker), |
| 372 dom_storage_context_(dom_storage_context), | 374 dom_storage_context_(dom_storage_context), |
| 373 indexed_db_context_(indexed_db_context), | 375 indexed_db_context_(indexed_db_context), |
| 374 service_worker_context_(service_worker_context), | 376 service_worker_context_(service_worker_context), |
| 375 webrtc_identity_store_(webrtc_identity_store), | 377 webrtc_identity_store_(webrtc_identity_store), |
| 376 special_storage_policy_(special_storage_policy) { | 378 special_storage_policy_(special_storage_policy), |
| 379 geofencing_manager_(geofencing_manager) { |
| 377 } | 380 } |
| 378 | 381 |
| 379 StoragePartitionImpl::~StoragePartitionImpl() { | 382 StoragePartitionImpl::~StoragePartitionImpl() { |
| 380 // These message loop checks are just to avoid leaks in unittests. | 383 // These message loop checks are just to avoid leaks in unittests. |
| 381 if (GetDatabaseTracker() && | 384 if (GetDatabaseTracker() && |
| 382 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { | 385 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { |
| 383 BrowserThread::PostTask( | 386 BrowserThread::PostTask( |
| 384 BrowserThread::FILE, | 387 BrowserThread::FILE, |
| 385 FROM_HERE, | 388 FROM_HERE, |
| 386 base::Bind(&storage::DatabaseTracker::Shutdown, GetDatabaseTracker())); | 389 base::Bind(&storage::DatabaseTracker::Shutdown, GetDatabaseTracker())); |
| 387 } | 390 } |
| 388 | 391 |
| 389 if (GetFileSystemContext()) | 392 if (GetFileSystemContext()) |
| 390 GetFileSystemContext()->Shutdown(); | 393 GetFileSystemContext()->Shutdown(); |
| 391 | 394 |
| 392 if (GetDOMStorageContext()) | 395 if (GetDOMStorageContext()) |
| 393 GetDOMStorageContext()->Shutdown(); | 396 GetDOMStorageContext()->Shutdown(); |
| 394 | 397 |
| 395 if (GetServiceWorkerContext()) | 398 if (GetServiceWorkerContext()) |
| 396 GetServiceWorkerContext()->Shutdown(); | 399 GetServiceWorkerContext()->Shutdown(); |
| 400 |
| 401 if (GetGeofencingManager()) |
| 402 GetGeofencingManager()->Shutdown(); |
| 397 } | 403 } |
| 398 | 404 |
| 399 // TODO(ajwong): Break the direct dependency on |context|. We only | 405 // TODO(ajwong): Break the direct dependency on |context|. We only |
| 400 // need 3 pieces of info from it. | 406 // need 3 pieces of info from it. |
| 401 StoragePartitionImpl* StoragePartitionImpl::Create( | 407 StoragePartitionImpl* StoragePartitionImpl::Create( |
| 402 BrowserContext* context, | 408 BrowserContext* context, |
| 403 bool in_memory, | 409 bool in_memory, |
| 404 const base::FilePath& partition_path) { | 410 const base::FilePath& partition_path) { |
| 405 // Ensure that these methods are called on the UI thread, except for | 411 // Ensure that these methods are called on the UI thread, except for |
| 406 // unittests where a UI thread might not have been created. | 412 // unittests where a UI thread might not have been created. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 | 464 |
| 459 scoped_refptr<ChromeAppCacheService> appcache_service = | 465 scoped_refptr<ChromeAppCacheService> appcache_service = |
| 460 new ChromeAppCacheService(quota_manager->proxy()); | 466 new ChromeAppCacheService(quota_manager->proxy()); |
| 461 | 467 |
| 462 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store( | 468 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store( |
| 463 new WebRTCIdentityStore(path, context->GetSpecialStoragePolicy())); | 469 new WebRTCIdentityStore(path, context->GetSpecialStoragePolicy())); |
| 464 | 470 |
| 465 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy( | 471 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy( |
| 466 context->GetSpecialStoragePolicy()); | 472 context->GetSpecialStoragePolicy()); |
| 467 | 473 |
| 474 scoped_refptr<GeofencingManager> geofencing_manager = |
| 475 new GeofencingManager(service_worker_context); |
| 476 geofencing_manager->Init(); |
| 477 |
| 468 return new StoragePartitionImpl(partition_path, | 478 return new StoragePartitionImpl(partition_path, |
| 469 quota_manager.get(), | 479 quota_manager.get(), |
| 470 appcache_service.get(), | 480 appcache_service.get(), |
| 471 filesystem_context.get(), | 481 filesystem_context.get(), |
| 472 database_tracker.get(), | 482 database_tracker.get(), |
| 473 dom_storage_context.get(), | 483 dom_storage_context.get(), |
| 474 indexed_db_context.get(), | 484 indexed_db_context.get(), |
| 475 service_worker_context.get(), | 485 service_worker_context.get(), |
| 476 webrtc_identity_store.get(), | 486 webrtc_identity_store.get(), |
| 477 special_storage_policy.get()); | 487 special_storage_policy.get(), |
| 488 geofencing_manager.get()); |
| 478 } | 489 } |
| 479 | 490 |
| 480 base::FilePath StoragePartitionImpl::GetPath() { | 491 base::FilePath StoragePartitionImpl::GetPath() { |
| 481 return partition_path_; | 492 return partition_path_; |
| 482 } | 493 } |
| 483 | 494 |
| 484 net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() { | 495 net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() { |
| 485 return url_request_context_.get(); | 496 return url_request_context_.get(); |
| 486 } | 497 } |
| 487 | 498 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 511 } | 522 } |
| 512 | 523 |
| 513 IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() { | 524 IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() { |
| 514 return indexed_db_context_.get(); | 525 return indexed_db_context_.get(); |
| 515 } | 526 } |
| 516 | 527 |
| 517 ServiceWorkerContextWrapper* StoragePartitionImpl::GetServiceWorkerContext() { | 528 ServiceWorkerContextWrapper* StoragePartitionImpl::GetServiceWorkerContext() { |
| 518 return service_worker_context_.get(); | 529 return service_worker_context_.get(); |
| 519 } | 530 } |
| 520 | 531 |
| 532 GeofencingManager* StoragePartitionImpl::GetGeofencingManager() { |
| 533 return geofencing_manager_.get(); |
| 534 } |
| 535 |
| 521 void StoragePartitionImpl::ClearDataImpl( | 536 void StoragePartitionImpl::ClearDataImpl( |
| 522 uint32 remove_mask, | 537 uint32 remove_mask, |
| 523 uint32 quota_storage_remove_mask, | 538 uint32 quota_storage_remove_mask, |
| 524 const GURL& storage_origin, | 539 const GURL& storage_origin, |
| 525 const OriginMatcherFunction& origin_matcher, | 540 const OriginMatcherFunction& origin_matcher, |
| 526 net::URLRequestContextGetter* rq_context, | 541 net::URLRequestContextGetter* rq_context, |
| 527 const base::Time begin, | 542 const base::Time begin, |
| 528 const base::Time end, | 543 const base::Time end, |
| 529 const base::Closure& callback) { | 544 const base::Closure& callback) { |
| 530 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 net::URLRequestContextGetter* url_request_context) { | 837 net::URLRequestContextGetter* url_request_context) { |
| 823 url_request_context_ = url_request_context; | 838 url_request_context_ = url_request_context; |
| 824 } | 839 } |
| 825 | 840 |
| 826 void StoragePartitionImpl::SetMediaURLRequestContext( | 841 void StoragePartitionImpl::SetMediaURLRequestContext( |
| 827 net::URLRequestContextGetter* media_url_request_context) { | 842 net::URLRequestContextGetter* media_url_request_context) { |
| 828 media_url_request_context_ = media_url_request_context; | 843 media_url_request_context_ = media_url_request_context; |
| 829 } | 844 } |
| 830 | 845 |
| 831 } // namespace content | 846 } // namespace content |
| OLD | NEW |