| 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/public/browser/browser_context.h" | 5 #include "content/public/browser/browser_context.h" |
| 6 | 6 |
| 7 #if !defined(OS_IOS) | 7 #if !defined(OS_IOS) |
| 8 #include "content/browser/appcache/chrome_appcache_service.h" | 8 #include "content/browser/appcache/chrome_appcache_service.h" |
| 9 #include "content/browser/dom_storage/dom_storage_context_impl.h" | 9 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
| 10 #include "content/browser/download/download_manager_impl.h" | 10 #include "content/browser/download/download_manager_impl.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 const scoped_refptr<net::URLRequestContextGetter>& context_getter, | 75 const scoped_refptr<net::URLRequestContextGetter>& context_getter, |
| 76 appcache::AppCacheService* appcache_service) { | 76 appcache::AppCacheService* appcache_service) { |
| 77 net::URLRequestContext* context = context_getter->GetURLRequestContext(); | 77 net::URLRequestContext* context = context_getter->GetURLRequestContext(); |
| 78 context->cookie_store()->GetCookieMonster()-> | 78 context->cookie_store()->GetCookieMonster()-> |
| 79 SetForceKeepSessionState(); | 79 SetForceKeepSessionState(); |
| 80 context->server_bound_cert_service()->GetCertStore()-> | 80 context->server_bound_cert_service()->GetCertStore()-> |
| 81 SetForceKeepSessionState(); | 81 SetForceKeepSessionState(); |
| 82 appcache_service->set_force_keep_session_state(); | 82 appcache_service->set_force_keep_session_state(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void SaveSessionStateOnWebkitThread( | 85 void SaveSessionStateOnIndexedDBThread( |
| 86 scoped_refptr<IndexedDBContextImpl> indexed_db_context) { | 86 scoped_refptr<IndexedDBContextImpl> indexed_db_context) { |
| 87 indexed_db_context->SetForceKeepSessionState(); | 87 indexed_db_context->SetForceKeepSessionState(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void PurgeMemoryOnIOThread(appcache::AppCacheService* appcache_service) { | 90 void PurgeMemoryOnIOThread(appcache::AppCacheService* appcache_service) { |
| 91 appcache_service->PurgeMemory(); | 91 appcache_service->PurgeMemory(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace | 94 } // namespace |
| 95 | 95 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 &SaveSessionStateOnIOThread, | 231 &SaveSessionStateOnIOThread, |
| 232 make_scoped_refptr(browser_context->GetRequestContext()), | 232 make_scoped_refptr(browser_context->GetRequestContext()), |
| 233 storage_partition->GetAppCacheService())); | 233 storage_partition->GetAppCacheService())); |
| 234 } | 234 } |
| 235 | 235 |
| 236 DOMStorageContextImpl* dom_storage_context_impl = | 236 DOMStorageContextImpl* dom_storage_context_impl = |
| 237 static_cast<DOMStorageContextImpl*>( | 237 static_cast<DOMStorageContextImpl*>( |
| 238 storage_partition->GetDOMStorageContext()); | 238 storage_partition->GetDOMStorageContext()); |
| 239 dom_storage_context_impl->SetForceKeepSessionState(); | 239 dom_storage_context_impl->SetForceKeepSessionState(); |
| 240 | 240 |
| 241 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { | 241 IndexedDBContextImpl* indexed_db_context_impl = |
| 242 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>( | 242 static_cast<IndexedDBContextImpl*>( |
| 243 storage_partition->GetIndexedDBContext()); | 243 storage_partition->GetIndexedDBContext()); |
| 244 BrowserThread::PostTask( | 244 // No task runner in unit tests. |
| 245 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, | 245 if (indexed_db_context_impl->TaskRunner()) { |
| 246 base::Bind(&SaveSessionStateOnWebkitThread, | 246 indexed_db_context_impl->TaskRunner()->PostTask( |
| 247 make_scoped_refptr(indexed_db))); | 247 FROM_HERE, |
| 248 base::Bind(&SaveSessionStateOnIndexedDBThread, |
| 249 make_scoped_refptr(indexed_db_context_impl))); |
| 248 } | 250 } |
| 249 } | 251 } |
| 250 | 252 |
| 251 void BrowserContext::PurgeMemory(BrowserContext* browser_context) { | 253 void BrowserContext::PurgeMemory(BrowserContext* browser_context) { |
| 252 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { | 254 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { |
| 253 BrowserThread::PostTask( | 255 BrowserThread::PostTask( |
| 254 BrowserThread::IO, FROM_HERE, | 256 BrowserThread::IO, FROM_HERE, |
| 255 base::Bind( | 257 base::Bind( |
| 256 &PurgeMemoryOnIOThread, | 258 &PurgeMemoryOnIOThread, |
| 257 BrowserContext::GetDefaultStoragePartition(browser_context)-> | 259 BrowserContext::GetDefaultStoragePartition(browser_context)-> |
| 258 GetAppCacheService())); | 260 GetAppCacheService())); |
| 259 } | 261 } |
| 260 | 262 |
| 261 ForEachStoragePartition(browser_context, | 263 ForEachStoragePartition(browser_context, |
| 262 base::Bind(&PurgeDOMStorageContextInPartition)); | 264 base::Bind(&PurgeDOMStorageContextInPartition)); |
| 263 } | 265 } |
| 264 | 266 |
| 265 #endif // !OS_IOS | 267 #endif // !OS_IOS |
| 266 | 268 |
| 267 BrowserContext::~BrowserContext() { | 269 BrowserContext::~BrowserContext() { |
| 268 #if !defined(OS_IOS) | 270 #if !defined(OS_IOS) |
| 269 if (GetUserData(kDownloadManagerKeyName)) | 271 if (GetUserData(kDownloadManagerKeyName)) |
| 270 GetDownloadManager(this)->Shutdown(); | 272 GetDownloadManager(this)->Shutdown(); |
| 271 #endif | 273 #endif |
| 272 } | 274 } |
| 273 | 275 |
| 274 } // namespace content | 276 } // namespace content |
| OLD | NEW |