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/gpu/shader_disk_cache.h" | 11 #include "content/browser/gpu/shader_disk_cache.h" |
12 #include "content/common/dom_storage/dom_storage_types.h" | 12 #include "content/common/dom_storage/dom_storage_types.h" |
13 #include "content/public/browser/browser_context.h" | 13 #include "content/public/browser/browser_context.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/dom_storage_context.h" | 15 #include "content/public/browser/dom_storage_context.h" |
16 #include "content/public/browser/indexed_db_context.h" | 16 #include "content/public/browser/indexed_db_context.h" |
17 #include "content/public/browser/local_storage_usage_info.h" | 17 #include "content/public/browser/local_storage_usage_info.h" |
18 #include "content/public/browser/session_storage_usage_info.h" | 18 #include "content/public/browser/session_storage_usage_info.h" |
19 #include "net/base/completion_callback.h" | 19 #include "net/base/completion_callback.h" |
20 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
21 #include "net/cookies/cookie_monster.h" | 21 #include "net/cookies/cookie_monster.h" |
22 #include "net/url_request/url_request_context.h" | 22 #include "net/url_request/url_request_context.h" |
23 #include "net/url_request/url_request_context_getter.h" | 23 #include "net/url_request/url_request_context_getter.h" |
24 #include "webkit/browser/database/database_tracker.h" | 24 #include "storage/browser/database/database_tracker.h" |
25 #include "webkit/browser/quota/quota_manager.h" | 25 #include "storage/browser/quota/quota_manager.h" |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 void OnClearedCookies(const base::Closure& callback, int num_deleted) { | 31 void OnClearedCookies(const base::Closure& callback, int num_deleted) { |
32 // The final callback needs to happen from UI thread. | 32 // The final callback needs to happen from UI thread. |
33 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 33 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
34 BrowserThread::PostTask( | 34 BrowserThread::PostTask( |
35 BrowserThread::UI, FROM_HERE, | 35 BrowserThread::UI, FROM_HERE, |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 storage_origin, | 345 storage_origin, |
346 callback); | 346 callback); |
347 helper->ClearDataOnIOThread(quota_manager, begin, special_storage_policy, | 347 helper->ClearDataOnIOThread(quota_manager, begin, special_storage_policy, |
348 origin_matcher); | 348 origin_matcher); |
349 } | 349 } |
350 | 350 |
351 StoragePartitionImpl::StoragePartitionImpl( | 351 StoragePartitionImpl::StoragePartitionImpl( |
352 const base::FilePath& partition_path, | 352 const base::FilePath& partition_path, |
353 quota::QuotaManager* quota_manager, | 353 quota::QuotaManager* quota_manager, |
354 ChromeAppCacheService* appcache_service, | 354 ChromeAppCacheService* appcache_service, |
355 fileapi::FileSystemContext* filesystem_context, | 355 storage::FileSystemContext* filesystem_context, |
356 webkit_database::DatabaseTracker* database_tracker, | 356 webkit_database::DatabaseTracker* database_tracker, |
357 DOMStorageContextWrapper* dom_storage_context, | 357 DOMStorageContextWrapper* dom_storage_context, |
358 IndexedDBContextImpl* indexed_db_context, | 358 IndexedDBContextImpl* indexed_db_context, |
359 ServiceWorkerContextWrapper* service_worker_context, | 359 ServiceWorkerContextWrapper* service_worker_context, |
360 WebRTCIdentityStore* webrtc_identity_store, | 360 WebRTCIdentityStore* webrtc_identity_store, |
361 quota::SpecialStoragePolicy* special_storage_policy) | 361 quota::SpecialStoragePolicy* special_storage_policy) |
362 : partition_path_(partition_path), | 362 : partition_path_(partition_path), |
363 quota_manager_(quota_manager), | 363 quota_manager_(quota_manager), |
364 appcache_service_(appcache_service), | 364 appcache_service_(appcache_service), |
365 filesystem_context_(filesystem_context), | 365 filesystem_context_(filesystem_context), |
366 database_tracker_(database_tracker), | 366 database_tracker_(database_tracker), |
367 dom_storage_context_(dom_storage_context), | 367 dom_storage_context_(dom_storage_context), |
368 indexed_db_context_(indexed_db_context), | 368 indexed_db_context_(indexed_db_context), |
369 service_worker_context_(service_worker_context), | 369 service_worker_context_(service_worker_context), |
370 webrtc_identity_store_(webrtc_identity_store), | 370 webrtc_identity_store_(webrtc_identity_store), |
371 special_storage_policy_(special_storage_policy) {} | 371 special_storage_policy_(special_storage_policy) { |
| 372 } |
372 | 373 |
373 StoragePartitionImpl::~StoragePartitionImpl() { | 374 StoragePartitionImpl::~StoragePartitionImpl() { |
374 // These message loop checks are just to avoid leaks in unittests. | 375 // These message loop checks are just to avoid leaks in unittests. |
375 if (GetDatabaseTracker() && | 376 if (GetDatabaseTracker() && |
376 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { | 377 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { |
377 BrowserThread::PostTask( | 378 BrowserThread::PostTask( |
378 BrowserThread::FILE, FROM_HERE, | 379 BrowserThread::FILE, FROM_HERE, |
379 base::Bind(&webkit_database::DatabaseTracker::Shutdown, | 380 base::Bind(&webkit_database::DatabaseTracker::Shutdown, |
380 GetDatabaseTracker())); | 381 GetDatabaseTracker())); |
381 } | 382 } |
(...skipping 25 matching lines...) Expand all Loading... |
407 // that utilizes the QuotaManager. | 408 // that utilizes the QuotaManager. |
408 scoped_refptr<quota::QuotaManager> quota_manager = new quota::QuotaManager( | 409 scoped_refptr<quota::QuotaManager> quota_manager = new quota::QuotaManager( |
409 in_memory, | 410 in_memory, |
410 partition_path, | 411 partition_path, |
411 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get(), | 412 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get(), |
412 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB).get(), | 413 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB).get(), |
413 context->GetSpecialStoragePolicy()); | 414 context->GetSpecialStoragePolicy()); |
414 | 415 |
415 // Each consumer is responsible for registering its QuotaClient during | 416 // Each consumer is responsible for registering its QuotaClient during |
416 // its construction. | 417 // its construction. |
417 scoped_refptr<fileapi::FileSystemContext> filesystem_context = | 418 scoped_refptr<storage::FileSystemContext> filesystem_context = |
418 CreateFileSystemContext(context, | 419 CreateFileSystemContext( |
419 partition_path, in_memory, | 420 context, partition_path, in_memory, quota_manager->proxy()); |
420 quota_manager->proxy()); | |
421 | 421 |
422 scoped_refptr<webkit_database::DatabaseTracker> database_tracker = | 422 scoped_refptr<webkit_database::DatabaseTracker> database_tracker = |
423 new webkit_database::DatabaseTracker( | 423 new webkit_database::DatabaseTracker( |
424 partition_path, | 424 partition_path, |
425 in_memory, | 425 in_memory, |
426 context->GetSpecialStoragePolicy(), | 426 context->GetSpecialStoragePolicy(), |
427 quota_manager->proxy(), | 427 quota_manager->proxy(), |
428 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) | 428 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) |
429 .get()); | 429 .get()); |
430 | 430 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 } | 485 } |
486 | 486 |
487 quota::QuotaManager* StoragePartitionImpl::GetQuotaManager() { | 487 quota::QuotaManager* StoragePartitionImpl::GetQuotaManager() { |
488 return quota_manager_.get(); | 488 return quota_manager_.get(); |
489 } | 489 } |
490 | 490 |
491 ChromeAppCacheService* StoragePartitionImpl::GetAppCacheService() { | 491 ChromeAppCacheService* StoragePartitionImpl::GetAppCacheService() { |
492 return appcache_service_.get(); | 492 return appcache_service_.get(); |
493 } | 493 } |
494 | 494 |
495 fileapi::FileSystemContext* StoragePartitionImpl::GetFileSystemContext() { | 495 storage::FileSystemContext* StoragePartitionImpl::GetFileSystemContext() { |
496 return filesystem_context_.get(); | 496 return filesystem_context_.get(); |
497 } | 497 } |
498 | 498 |
499 webkit_database::DatabaseTracker* StoragePartitionImpl::GetDatabaseTracker() { | 499 webkit_database::DatabaseTracker* StoragePartitionImpl::GetDatabaseTracker() { |
500 return database_tracker_.get(); | 500 return database_tracker_.get(); |
501 } | 501 } |
502 | 502 |
503 DOMStorageContextWrapper* StoragePartitionImpl::GetDOMStorageContext() { | 503 DOMStorageContextWrapper* StoragePartitionImpl::GetDOMStorageContext() { |
504 return dom_storage_context_.get(); | 504 return dom_storage_context_.get(); |
505 } | 505 } |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 net::URLRequestContextGetter* url_request_context) { | 808 net::URLRequestContextGetter* url_request_context) { |
809 url_request_context_ = url_request_context; | 809 url_request_context_ = url_request_context; |
810 } | 810 } |
811 | 811 |
812 void StoragePartitionImpl::SetMediaURLRequestContext( | 812 void StoragePartitionImpl::SetMediaURLRequestContext( |
813 net::URLRequestContextGetter* media_url_request_context) { | 813 net::URLRequestContextGetter* media_url_request_context) { |
814 media_url_request_context_ = media_url_request_context; | 814 media_url_request_context_ = media_url_request_context; |
815 } | 815 } |
816 | 816 |
817 } // namespace content | 817 } // namespace content |
OLD | NEW |