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

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

Issue 10885044: Remove storage context accessors from ResourceContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged to ToT Created 8 years, 3 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 | Annotate | Revision Log
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 "content/browser/fileapi/browser_file_system_helper.h" 7 #include "content/browser/fileapi/browser_file_system_helper.h"
8 #include "content/public/browser/browser_context.h" 8 #include "content/public/browser/browser_context.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "webkit/database/database_tracker.h" 10 #include "webkit/database/database_tracker.h"
11 #include "webkit/quota/quota_manager.h" 11 #include "webkit/quota/quota_manager.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 StoragePartitionImpl::StoragePartitionImpl( 15 StoragePartitionImpl::StoragePartitionImpl(
16 const std::string& partition_id,
16 const FilePath& partition_path, 17 const FilePath& partition_path,
17 quota::QuotaManager* quota_manager, 18 quota::QuotaManager* quota_manager,
18 ChromeAppCacheService* appcache_service, 19 ChromeAppCacheService* appcache_service,
19 fileapi::FileSystemContext* filesystem_context, 20 fileapi::FileSystemContext* filesystem_context,
20 webkit_database::DatabaseTracker* database_tracker, 21 webkit_database::DatabaseTracker* database_tracker,
21 DOMStorageContextImpl* dom_storage_context, 22 DOMStorageContextImpl* dom_storage_context,
22 IndexedDBContextImpl* indexed_db_context) 23 IndexedDBContextImpl* indexed_db_context)
23 : partition_path_(partition_path), 24 : partition_id_(partition_id),
25 partition_path_(partition_path),
24 quota_manager_(quota_manager), 26 quota_manager_(quota_manager),
25 appcache_service_(appcache_service), 27 appcache_service_(appcache_service),
26 filesystem_context_(filesystem_context), 28 filesystem_context_(filesystem_context),
27 database_tracker_(database_tracker), 29 database_tracker_(database_tracker),
28 dom_storage_context_(dom_storage_context), 30 dom_storage_context_(dom_storage_context),
29 indexed_db_context_(indexed_db_context) { 31 indexed_db_context_(indexed_db_context) {
30 } 32 }
31 33
32 StoragePartitionImpl::~StoragePartitionImpl() { 34 StoragePartitionImpl::~StoragePartitionImpl() {
33 // These message loop checks are just to avoid leaks in unittests. 35 // These message loop checks are just to avoid leaks in unittests.
34 if (GetDatabaseTracker() && 36 if (GetDatabaseTracker() &&
35 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { 37 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) {
36 BrowserThread::PostTask( 38 BrowserThread::PostTask(
37 BrowserThread::FILE, FROM_HERE, 39 BrowserThread::FILE, FROM_HERE,
38 base::Bind(&webkit_database::DatabaseTracker::Shutdown, 40 base::Bind(&webkit_database::DatabaseTracker::Shutdown,
39 GetDatabaseTracker())); 41 GetDatabaseTracker()));
40 } 42 }
41 43
42 if (GetDOMStorageContext()) 44 if (GetDOMStorageContext())
43 GetDOMStorageContext()->Shutdown(); 45 GetDOMStorageContext()->Shutdown();
44 } 46 }
45 47
46 // TODO(ajwong): Break the direct dependency on |context|. We only 48 // TODO(ajwong): Break the direct dependency on |context|. We only
47 // need 3 pieces of info from it. 49 // need 3 pieces of info from it.
48 StoragePartitionImpl* StoragePartitionImpl::Create( 50 StoragePartitionImpl* StoragePartitionImpl::Create(
49 BrowserContext* context, 51 BrowserContext* context,
52 const std::string& partition_id,
50 const FilePath& partition_path) { 53 const FilePath& partition_path) {
51 // Ensure that these methods are called on the UI thread, except for 54 // Ensure that these methods are called on the UI thread, except for
52 // unittests where a UI thread might not have been created. 55 // unittests where a UI thread might not have been created.
53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
54 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); 57 !BrowserThread::IsMessageLoopValid(BrowserThread::UI));
55 58
56 // All of the clients have to be created and registered with the 59 // All of the clients have to be created and registered with the
57 // QuotaManager prior to the QuotaManger being used. We do them 60 // QuotaManager prior to the QuotaManger being used. We do them
58 // all together here prior to handing out a reference to anything 61 // all together here prior to handing out a reference to anything
59 // that utilizes the QuotaManager. 62 // that utilizes the QuotaManager.
(...skipping 23 matching lines...) Expand all
83 86
84 scoped_refptr<IndexedDBContextImpl> indexed_db_context = 87 scoped_refptr<IndexedDBContextImpl> indexed_db_context =
85 new IndexedDBContextImpl(path, context->GetSpecialStoragePolicy(), 88 new IndexedDBContextImpl(path, context->GetSpecialStoragePolicy(),
86 quota_manager->proxy(), 89 quota_manager->proxy(),
87 BrowserThread::GetMessageLoopProxyForThread( 90 BrowserThread::GetMessageLoopProxyForThread(
88 BrowserThread::WEBKIT_DEPRECATED)); 91 BrowserThread::WEBKIT_DEPRECATED));
89 92
90 scoped_refptr<ChromeAppCacheService> appcache_service = 93 scoped_refptr<ChromeAppCacheService> appcache_service =
91 new ChromeAppCacheService(quota_manager->proxy()); 94 new ChromeAppCacheService(quota_manager->proxy());
92 95
93 return new StoragePartitionImpl(partition_path, 96 return new StoragePartitionImpl(partition_id,
97 partition_path,
94 quota_manager, 98 quota_manager,
95 appcache_service, 99 appcache_service,
96 filesystem_context, 100 filesystem_context,
97 database_tracker, 101 database_tracker,
98 dom_storage_context, 102 dom_storage_context,
99 indexed_db_context); 103 indexed_db_context);
100 } 104 }
101 105
106 const std::string& StoragePartitionImpl::GetId() {
107 return partition_id_;
108 }
109
102 quota::QuotaManager* StoragePartitionImpl::GetQuotaManager() { 110 quota::QuotaManager* StoragePartitionImpl::GetQuotaManager() {
103 return quota_manager_; 111 return quota_manager_;
104 } 112 }
105 113
106 ChromeAppCacheService* StoragePartitionImpl::GetAppCacheService() { 114 ChromeAppCacheService* StoragePartitionImpl::GetAppCacheService() {
107 return appcache_service_; 115 return appcache_service_;
108 } 116 }
109 117
110 fileapi::FileSystemContext* StoragePartitionImpl::GetFileSystemContext() { 118 fileapi::FileSystemContext* StoragePartitionImpl::GetFileSystemContext() {
111 return filesystem_context_; 119 return filesystem_context_;
112 } 120 }
113 121
114 webkit_database::DatabaseTracker* StoragePartitionImpl::GetDatabaseTracker() { 122 webkit_database::DatabaseTracker* StoragePartitionImpl::GetDatabaseTracker() {
115 return database_tracker_; 123 return database_tracker_;
116 } 124 }
117 125
118 DOMStorageContextImpl* StoragePartitionImpl::GetDOMStorageContext() { 126 DOMStorageContextImpl* StoragePartitionImpl::GetDOMStorageContext() {
119 return dom_storage_context_; 127 return dom_storage_context_;
120 } 128 }
121 129
122 IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() { 130 IndexedDBContextImpl* StoragePartitionImpl::GetIndexedDBContext() {
123 return indexed_db_context_; 131 return indexed_db_context_;
124 } 132 }
125 133
126 } // namespace content 134 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698