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