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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "content/browser/fileapi/browser_file_system_helper.h" | 8 #include "content/browser/fileapi/browser_file_system_helper.h" |
9 #include "content/browser/gpu/shader_disk_cache.h" | |
9 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
11 #include "content/public/browser/dom_storage_context.h" | 12 #include "content/public/browser/dom_storage_context.h" |
12 #include "content/public/browser/indexed_db_context.h" | 13 #include "content/public/browser/indexed_db_context.h" |
13 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
15 #include "net/cookies/cookie_monster.h" | 16 #include "net/cookies/cookie_monster.h" |
16 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
17 #include "net/url_request/url_request_context.h" | 18 #include "net/url_request/url_request_context.h" |
18 #include "webkit/database/database_tracker.h" | 19 #include "webkit/database/database_tracker.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 quota::kStorageTypeTemporary, base::Time(), | 98 quota::kStorageTypeTemporary, base::Time(), |
98 base::Bind(&ClearQuotaManagedOriginsOnIOThread, quota_manager)); | 99 base::Bind(&ClearQuotaManagedOriginsOnIOThread, quota_manager)); |
99 } | 100 } |
100 if (storage_mask & StoragePartition::kQuotaManagedPersistentStorage) { | 101 if (storage_mask & StoragePartition::kQuotaManagedPersistentStorage) { |
101 quota_manager->GetOriginsModifiedSince( | 102 quota_manager->GetOriginsModifiedSince( |
102 quota::kStorageTypePersistent, base::Time(), | 103 quota::kStorageTypePersistent, base::Time(), |
103 base::Bind(&ClearQuotaManagedOriginsOnIOThread, quota_manager)); | 104 base::Bind(&ClearQuotaManagedOriginsOnIOThread, quota_manager)); |
104 } | 105 } |
105 } | 106 } |
106 | 107 |
108 void ClearedShaderCacheOnIOThread(base::Closure callback) { | |
109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
110 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | |
111 } | |
112 | |
113 void ClearShaderCacheOnIOThread(base::FilePath context_path, | |
114 base::Time begin, base::Time end, base::Closure callback) { | |
115 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
116 ShaderCacheFactory::GetInstance()->ClearByPath( | |
117 context_path, begin, end, | |
118 base::Bind(&ClearedShaderCacheOnIOThread, callback)); | |
119 } | |
120 | |
107 void OnLocalStorageUsageInfo( | 121 void OnLocalStorageUsageInfo( |
108 const scoped_refptr<DOMStorageContextImpl>& dom_storage_context, | 122 const scoped_refptr<DOMStorageContextImpl>& dom_storage_context, |
109 const std::vector<dom_storage::LocalStorageUsageInfo>& infos) { | 123 const std::vector<dom_storage::LocalStorageUsageInfo>& infos) { |
110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
111 | 125 |
112 for (size_t i = 0; i < infos.size(); ++i) { | 126 for (size_t i = 0; i < infos.size(); ++i) { |
113 dom_storage_context->DeleteLocalStorage(infos[i].origin); | 127 dom_storage_context->DeleteLocalStorage(infos[i].origin); |
114 } | 128 } |
115 } | 129 } |
116 | 130 |
117 void OnSessionStorageUsageInfo( | 131 void OnSessionStorageUsageInfo( |
118 const scoped_refptr<DOMStorageContextImpl>& dom_storage_context, | 132 const scoped_refptr<DOMStorageContextImpl>& dom_storage_context, |
119 const std::vector<dom_storage::SessionStorageUsageInfo>& infos) { | 133 const std::vector<dom_storage::SessionStorageUsageInfo>& infos) { |
120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
121 | 135 |
122 for (size_t i = 0; i < infos.size(); ++i) { | 136 for (size_t i = 0; i < infos.size(); ++i) { |
123 dom_storage_context->DeleteSessionStorage(infos[i]); | 137 dom_storage_context->DeleteSessionStorage(infos[i]); |
124 } | 138 } |
125 } | 139 } |
126 | 140 |
127 } // namespace | 141 } // namespace |
128 | 142 |
129 StoragePartitionImpl::StoragePartitionImpl( | 143 StoragePartitionImpl::StoragePartitionImpl( |
144 const base::FilePath& context_path, | |
jam
2013/03/26 17:04:16
this makes me wonder, should the shader cache be p
| |
130 const base::FilePath& partition_path, | 145 const base::FilePath& partition_path, |
131 quota::QuotaManager* quota_manager, | 146 quota::QuotaManager* quota_manager, |
132 ChromeAppCacheService* appcache_service, | 147 ChromeAppCacheService* appcache_service, |
133 fileapi::FileSystemContext* filesystem_context, | 148 fileapi::FileSystemContext* filesystem_context, |
134 webkit_database::DatabaseTracker* database_tracker, | 149 webkit_database::DatabaseTracker* database_tracker, |
135 DOMStorageContextImpl* dom_storage_context, | 150 DOMStorageContextImpl* dom_storage_context, |
136 IndexedDBContextImpl* indexed_db_context) | 151 IndexedDBContextImpl* indexed_db_context) |
137 : partition_path_(partition_path), | 152 : context_path_(context_path), |
153 partition_path_(partition_path), | |
138 quota_manager_(quota_manager), | 154 quota_manager_(quota_manager), |
139 appcache_service_(appcache_service), | 155 appcache_service_(appcache_service), |
140 filesystem_context_(filesystem_context), | 156 filesystem_context_(filesystem_context), |
141 database_tracker_(database_tracker), | 157 database_tracker_(database_tracker), |
142 dom_storage_context_(dom_storage_context), | 158 dom_storage_context_(dom_storage_context), |
143 indexed_db_context_(indexed_db_context) { | 159 indexed_db_context_(indexed_db_context) { |
144 } | 160 } |
145 | 161 |
146 StoragePartitionImpl::~StoragePartitionImpl() { | 162 StoragePartitionImpl::~StoragePartitionImpl() { |
147 // These message loop checks are just to avoid leaks in unittests. | 163 // These message loop checks are just to avoid leaks in unittests. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 | 215 |
200 scoped_refptr<IndexedDBContextImpl> indexed_db_context = | 216 scoped_refptr<IndexedDBContextImpl> indexed_db_context = |
201 new IndexedDBContextImpl(path, context->GetSpecialStoragePolicy(), | 217 new IndexedDBContextImpl(path, context->GetSpecialStoragePolicy(), |
202 quota_manager->proxy(), | 218 quota_manager->proxy(), |
203 BrowserThread::GetMessageLoopProxyForThread( | 219 BrowserThread::GetMessageLoopProxyForThread( |
204 BrowserThread::WEBKIT_DEPRECATED)); | 220 BrowserThread::WEBKIT_DEPRECATED)); |
205 | 221 |
206 scoped_refptr<ChromeAppCacheService> appcache_service = | 222 scoped_refptr<ChromeAppCacheService> appcache_service = |
207 new ChromeAppCacheService(quota_manager->proxy()); | 223 new ChromeAppCacheService(quota_manager->proxy()); |
208 | 224 |
209 return new StoragePartitionImpl(partition_path, | 225 return new StoragePartitionImpl(context->GetPath(), |
226 partition_path, | |
210 quota_manager, | 227 quota_manager, |
211 appcache_service, | 228 appcache_service, |
212 filesystem_context, | 229 filesystem_context, |
213 database_tracker, | 230 database_tracker, |
214 dom_storage_context, | 231 dom_storage_context, |
215 indexed_db_context); | 232 indexed_db_context); |
216 } | 233 } |
217 | 234 |
218 base::FilePath StoragePartitionImpl::GetPath() { | 235 base::FilePath StoragePartitionImpl::GetPath() { |
219 return partition_path_; | 236 return partition_path_; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 dom_storage_context_->GetLocalStorageUsage( | 303 dom_storage_context_->GetLocalStorageUsage( |
287 base::Bind(&OnLocalStorageUsageInfo, dom_storage_context_)); | 304 base::Bind(&OnLocalStorageUsageInfo, dom_storage_context_)); |
288 } | 305 } |
289 | 306 |
290 if (storage_mask & kSessionDomStorage) { | 307 if (storage_mask & kSessionDomStorage) { |
291 dom_storage_context_->GetSessionStorageUsage( | 308 dom_storage_context_->GetSessionStorageUsage( |
292 base::Bind(&OnSessionStorageUsageInfo, dom_storage_context_)); | 309 base::Bind(&OnSessionStorageUsageInfo, dom_storage_context_)); |
293 } | 310 } |
294 } | 311 } |
295 | 312 |
313 void StoragePartitionImpl::AsyncClearDataBetween(uint32 storage_mask, | |
314 const base::Time& begin, const base::Time& end, | |
315 const base::Closure& callback) { | |
316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
317 DCHECK(storage_mask == kShaderStorage); | |
318 | |
319 if (storage_mask & kShaderStorage) { | |
320 BrowserThread::PostTask( | |
321 BrowserThread::IO, FROM_HERE, | |
322 base::Bind(&ClearShaderCacheOnIOThread, context_path_, begin, end, | |
323 callback)); | |
324 } | |
325 } | |
326 | |
296 void StoragePartitionImpl::SetURLRequestContext( | 327 void StoragePartitionImpl::SetURLRequestContext( |
297 net::URLRequestContextGetter* url_request_context) { | 328 net::URLRequestContextGetter* url_request_context) { |
298 url_request_context_ = url_request_context; | 329 url_request_context_ = url_request_context; |
299 } | 330 } |
300 | 331 |
301 void StoragePartitionImpl::SetMediaURLRequestContext( | 332 void StoragePartitionImpl::SetMediaURLRequestContext( |
302 net::URLRequestContextGetter* media_url_request_context) { | 333 net::URLRequestContextGetter* media_url_request_context) { |
303 media_url_request_context_ = media_url_request_context; | 334 media_url_request_context_ = media_url_request_context; |
304 } | 335 } |
305 | 336 |
306 } // namespace content | 337 } // namespace content |
OLD | NEW |