| 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 } | 277 } |
| 278 | 278 |
| 279 StoragePartitionImpl::StoragePartitionImpl( | 279 StoragePartitionImpl::StoragePartitionImpl( |
| 280 const base::FilePath& partition_path, | 280 const base::FilePath& partition_path, |
| 281 quota::QuotaManager* quota_manager, | 281 quota::QuotaManager* quota_manager, |
| 282 ChromeAppCacheService* appcache_service, | 282 ChromeAppCacheService* appcache_service, |
| 283 fileapi::FileSystemContext* filesystem_context, | 283 fileapi::FileSystemContext* filesystem_context, |
| 284 webkit_database::DatabaseTracker* database_tracker, | 284 webkit_database::DatabaseTracker* database_tracker, |
| 285 DOMStorageContextWrapper* dom_storage_context, | 285 DOMStorageContextWrapper* dom_storage_context, |
| 286 IndexedDBContextImpl* indexed_db_context, | 286 IndexedDBContextImpl* indexed_db_context, |
| 287 ServiceWorkerContext* service_worker_context, | 287 ServiceWorkerContextWrapper* service_worker_context, |
| 288 WebRTCIdentityStore* webrtc_identity_store) | 288 WebRTCIdentityStore* webrtc_identity_store) |
| 289 : partition_path_(partition_path), | 289 : partition_path_(partition_path), |
| 290 quota_manager_(quota_manager), | 290 quota_manager_(quota_manager), |
| 291 appcache_service_(appcache_service), | 291 appcache_service_(appcache_service), |
| 292 filesystem_context_(filesystem_context), | 292 filesystem_context_(filesystem_context), |
| 293 database_tracker_(database_tracker), | 293 database_tracker_(database_tracker), |
| 294 dom_storage_context_(dom_storage_context), | 294 dom_storage_context_(dom_storage_context), |
| 295 indexed_db_context_(indexed_db_context), | 295 indexed_db_context_(indexed_db_context), |
| 296 service_worker_context_(service_worker_context), | 296 service_worker_context_(service_worker_context), |
| 297 webrtc_identity_store_(webrtc_identity_store) {} | 297 webrtc_identity_store_(webrtc_identity_store) {} |
| 298 | 298 |
| 299 StoragePartitionImpl::~StoragePartitionImpl() { | 299 StoragePartitionImpl::~StoragePartitionImpl() { |
| 300 // These message loop checks are just to avoid leaks in unittests. | 300 // These message loop checks are just to avoid leaks in unittests. |
| 301 if (GetDatabaseTracker() && | 301 if (GetDatabaseTracker() && |
| 302 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { | 302 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { |
| 303 BrowserThread::PostTask( | 303 BrowserThread::PostTask( |
| 304 BrowserThread::FILE, FROM_HERE, | 304 BrowserThread::FILE, FROM_HERE, |
| 305 base::Bind(&webkit_database::DatabaseTracker::Shutdown, | 305 base::Bind(&webkit_database::DatabaseTracker::Shutdown, |
| 306 GetDatabaseTracker())); | 306 GetDatabaseTracker())); |
| 307 } | 307 } |
| 308 | 308 |
| 309 if (GetFileSystemContext()) | 309 if (GetFileSystemContext()) |
| 310 GetFileSystemContext()->Shutdown(); | 310 GetFileSystemContext()->Shutdown(); |
| 311 | 311 |
| 312 if (GetDOMStorageContext()) | 312 if (GetDOMStorageContext()) |
| 313 GetDOMStorageContext()->Shutdown(); | 313 GetDOMStorageContext()->Shutdown(); |
| 314 |
| 315 if (GetServiceWorkerContext()) |
| 316 GetServiceWorkerContext()->Shutdown(); |
| 314 } | 317 } |
| 315 | 318 |
| 316 // TODO(ajwong): Break the direct dependency on |context|. We only | 319 // TODO(ajwong): Break the direct dependency on |context|. We only |
| 317 // need 3 pieces of info from it. | 320 // need 3 pieces of info from it. |
| 318 StoragePartitionImpl* StoragePartitionImpl::Create( | 321 StoragePartitionImpl* StoragePartitionImpl::Create( |
| 319 BrowserContext* context, | 322 BrowserContext* context, |
| 320 bool in_memory, | 323 bool in_memory, |
| 321 const base::FilePath& partition_path) { | 324 const base::FilePath& partition_path) { |
| 322 // Ensure that these methods are called on the UI thread, except for | 325 // Ensure that these methods are called on the UI thread, except for |
| 323 // unittests where a UI thread might not have been created. | 326 // unittests where a UI thread might not have been created. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 BrowserMainLoop::GetInstance() | 365 BrowserMainLoop::GetInstance() |
| 363 ? BrowserMainLoop::GetInstance()->indexed_db_thread() | 366 ? BrowserMainLoop::GetInstance()->indexed_db_thread() |
| 364 ->message_loop_proxy().get() | 367 ->message_loop_proxy().get() |
| 365 : NULL; | 368 : NULL; |
| 366 scoped_refptr<IndexedDBContextImpl> indexed_db_context = | 369 scoped_refptr<IndexedDBContextImpl> indexed_db_context = |
| 367 new IndexedDBContextImpl(path, | 370 new IndexedDBContextImpl(path, |
| 368 context->GetSpecialStoragePolicy(), | 371 context->GetSpecialStoragePolicy(), |
| 369 quota_manager->proxy(), | 372 quota_manager->proxy(), |
| 370 idb_task_runner); | 373 idb_task_runner); |
| 371 | 374 |
| 372 scoped_refptr<ServiceWorkerContext> service_worker_context = | 375 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_wrapper = |
| 373 new ServiceWorkerContext(path, quota_manager->proxy()); | 376 new ServiceWorkerContextWrapper(path, quota_manager->proxy()); |
| 374 | 377 |
| 375 scoped_refptr<ChromeAppCacheService> appcache_service = | 378 scoped_refptr<ChromeAppCacheService> appcache_service = |
| 376 new ChromeAppCacheService(quota_manager->proxy()); | 379 new ChromeAppCacheService(quota_manager->proxy()); |
| 377 | 380 |
| 378 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store( | 381 scoped_refptr<WebRTCIdentityStore> webrtc_identity_store( |
| 379 new WebRTCIdentityStore(path, context->GetSpecialStoragePolicy())); | 382 new WebRTCIdentityStore(path, context->GetSpecialStoragePolicy())); |
| 380 | 383 |
| 381 return new StoragePartitionImpl(partition_path, | 384 return new StoragePartitionImpl(partition_path, |
| 382 quota_manager.get(), | 385 quota_manager.get(), |
| 383 appcache_service.get(), | 386 appcache_service.get(), |
| 384 filesystem_context.get(), | 387 filesystem_context.get(), |
| 385 database_tracker.get(), | 388 database_tracker.get(), |
| 386 dom_storage_context.get(), | 389 dom_storage_context.get(), |
| 387 indexed_db_context.get(), | 390 indexed_db_context.get(), |
| 388 service_worker_context.get(), | 391 service_worker_context_wrapper.get(), |
| 389 webrtc_identity_store.get()); | 392 webrtc_identity_store.get()); |
| 390 } | 393 } |
| 391 | 394 |
| 392 base::FilePath StoragePartitionImpl::GetPath() { | 395 base::FilePath StoragePartitionImpl::GetPath() { |
| 393 return partition_path_; | 396 return partition_path_; |
| 394 } | 397 } |
| 395 | 398 |
| 396 net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() { | 399 net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() { |
| 397 return url_request_context_.get(); | 400 return url_request_context_.get(); |
| 398 } | 401 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 419 } | 422 } |
| 420 | 423 |
| 421 DOMStorageContextWrapper* StoragePartitionImpl::GetDOMStorageContext() { | 424 DOMStorageContextWrapper* StoragePartitionImpl::GetDOMStorageContext() { |
| 422 return dom_storage_context_.get(); | 425 return dom_storage_context_.get(); |
| 423 } | 426 } |
| 424 | 427 |
| 425 IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() { | 428 IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() { |
| 426 return indexed_db_context_.get(); | 429 return indexed_db_context_.get(); |
| 427 } | 430 } |
| 428 | 431 |
| 429 ServiceWorkerContext* StoragePartitionImpl::GetServiceWorkerContext() { | 432 ServiceWorkerContextWrapper* StoragePartitionImpl::GetServiceWorkerContext() { |
| 430 return service_worker_context_.get(); | 433 return service_worker_context_.get(); |
| 431 } | 434 } |
| 432 | 435 |
| 433 void StoragePartitionImpl::ClearDataImpl( | 436 void StoragePartitionImpl::ClearDataImpl( |
| 434 uint32 remove_mask, | 437 uint32 remove_mask, |
| 435 uint32 quota_storage_remove_mask, | 438 uint32 quota_storage_remove_mask, |
| 436 const GURL& remove_origin, | 439 const GURL& remove_origin, |
| 437 net::URLRequestContextGetter* rq_context, | 440 net::URLRequestContextGetter* rq_context, |
| 438 const base::Time begin, | 441 const base::Time begin, |
| 439 const base::Time end, | 442 const base::Time end, |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 net::URLRequestContextGetter* url_request_context) { | 672 net::URLRequestContextGetter* url_request_context) { |
| 670 url_request_context_ = url_request_context; | 673 url_request_context_ = url_request_context; |
| 671 } | 674 } |
| 672 | 675 |
| 673 void StoragePartitionImpl::SetMediaURLRequestContext( | 676 void StoragePartitionImpl::SetMediaURLRequestContext( |
| 674 net::URLRequestContextGetter* media_url_request_context) { | 677 net::URLRequestContextGetter* media_url_request_context) { |
| 675 media_url_request_context_ = media_url_request_context; | 678 media_url_request_context_ = media_url_request_context; |
| 676 } | 679 } |
| 677 | 680 |
| 678 } // namespace content | 681 } // namespace content |
| OLD | NEW |