Chromium Code Reviews| 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 #include "content/browser/appcache/chrome_appcache_service.h" | 7 #include "content/browser/appcache/chrome_appcache_service.h" |
| 8 #include "webkit/database/database_tracker.h" | 8 #include "webkit/database/database_tracker.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_file_manager.h" | 10 #include "content/browser/download/download_file_manager.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 kDownloadManagerKeyName, | 96 kDownloadManagerKeyName, |
| 97 new UserDataAdapter<DownloadManager>(download_manager)); | 97 new UserDataAdapter<DownloadManager>(download_manager)); |
| 98 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); | 98 download_manager->SetDelegate(context->GetDownloadManagerDelegate()); |
| 99 download_manager->Init(context); | 99 download_manager->Init(context); |
| 100 } | 100 } |
| 101 | 101 |
| 102 return UserDataAdapter<DownloadManager>::Get( | 102 return UserDataAdapter<DownloadManager>::Get( |
| 103 context, kDownloadManagerKeyName); | 103 context, kDownloadManagerKeyName); |
| 104 } | 104 } |
| 105 | 105 |
| 106 IndexedDBContext* BrowserContext::GetIndexedDBContext( | |
| 107 BrowserContext* browser_context) { | |
| 108 // TODO(ajwong): Change this API to require a SiteInstance instead of | |
| 109 // using GetDefaultStoragePartition(). | |
| 110 return GetDefaultStoragePartition(browser_context)->GetIndexedDBContext(); | |
| 111 } | |
| 112 | |
| 113 appcache::AppCacheService* BrowserContext::GetAppCacheService( | 106 appcache::AppCacheService* BrowserContext::GetAppCacheService( |
| 114 BrowserContext* browser_context) { | 107 BrowserContext* browser_context) { |
| 115 // TODO(ajwong): Change this API to require a SiteInstance instead of | 108 // TODO(ajwong): Change this API to require a SiteInstance instead of |
| 116 // using GetDefaultStoragePartition(). | 109 // using GetDefaultStoragePartition(). |
| 117 return GetDefaultStoragePartition(browser_context)->GetAppCacheService(); | 110 return GetDefaultStoragePartition(browser_context)->GetAppCacheService(); |
| 118 } | 111 } |
| 119 | 112 |
| 120 fileapi::FileSystemContext* BrowserContext::GetFileSystemContext( | 113 fileapi::FileSystemContext* BrowserContext::GetFileSystemContext( |
| 121 BrowserContext* browser_context) { | 114 BrowserContext* browser_context) { |
| 122 // TODO(ajwong): Change this API to require a SiteInstance instead of | 115 // TODO(ajwong): Change this API to require a SiteInstance instead of |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 // and when that call returns it'll end rewriting its UserData map. It will | 166 // and when that call returns it'll end rewriting its UserData map. It will |
| 174 // end up rewriting the same value but this still causes a race condition. | 167 // end up rewriting the same value but this still causes a race condition. |
| 175 // | 168 // |
| 176 // See http://crbug.com/115678. | 169 // See http://crbug.com/115678. |
| 177 GetDefaultStoragePartition(context); | 170 GetDefaultStoragePartition(context); |
| 178 } | 171 } |
| 179 | 172 |
| 180 void BrowserContext::SaveSessionState(BrowserContext* browser_context) { | 173 void BrowserContext::SaveSessionState(BrowserContext* browser_context) { |
| 181 GetDefaultStoragePartition(browser_context)->GetDatabaseTracker()-> | 174 GetDefaultStoragePartition(browser_context)->GetDatabaseTracker()-> |
| 182 SetForceKeepSessionState(); | 175 SetForceKeepSessionState(); |
| 176 StoragePartition* storage_partition = | |
| 177 BrowserContext::GetDefaultStoragePartition(browser_context); | |
|
Charlie Reis
2012/09/15 00:55:58
nit: wrong indent
awong
2012/09/15 01:19:37
Done.
| |
| 183 | 178 |
| 184 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { | 179 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { |
| 185 BrowserThread::PostTask( | 180 BrowserThread::PostTask( |
| 186 BrowserThread::IO, FROM_HERE, | 181 BrowserThread::IO, FROM_HERE, |
| 187 base::Bind( | 182 base::Bind( |
| 188 &SaveSessionStateOnIOThread, | 183 &SaveSessionStateOnIOThread, |
| 189 make_scoped_refptr(browser_context->GetRequestContext()), | 184 make_scoped_refptr(browser_context->GetRequestContext()), |
| 190 BrowserContext::GetDefaultStoragePartition(browser_context)-> | 185 storage_partition->GetAppCacheService())); |
| 191 GetAppCacheService())); | |
| 192 } | 186 } |
| 193 | 187 |
| 194 DOMStorageContextImpl* dom_storage_context_impl = | 188 DOMStorageContextImpl* dom_storage_context_impl = |
| 195 static_cast<DOMStorageContextImpl*>( | 189 static_cast<DOMStorageContextImpl*>( |
| 196 GetDefaultStoragePartition(browser_context)->GetDOMStorageContext()); | 190 storage_partition->GetDOMStorageContext()); |
| 197 dom_storage_context_impl->SetForceKeepSessionState(); | 191 dom_storage_context_impl->SetForceKeepSessionState(); |
| 198 | 192 |
| 199 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { | 193 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { |
| 200 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>( | 194 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>( |
| 201 GetIndexedDBContext(browser_context)); | 195 storage_partition->GetIndexedDBContext()); |
| 202 BrowserThread::PostTask( | 196 BrowserThread::PostTask( |
| 203 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, | 197 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, |
| 204 base::Bind(&SaveSessionStateOnWebkitThread, | 198 base::Bind(&SaveSessionStateOnWebkitThread, |
| 205 make_scoped_refptr(indexed_db))); | 199 make_scoped_refptr(indexed_db))); |
| 206 } | 200 } |
| 207 } | 201 } |
| 208 | 202 |
| 209 void BrowserContext::PurgeMemory(BrowserContext* browser_context) { | 203 void BrowserContext::PurgeMemory(BrowserContext* browser_context) { |
| 210 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { | 204 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { |
| 211 BrowserThread::PostTask( | 205 BrowserThread::PostTask( |
| 212 BrowserThread::IO, FROM_HERE, | 206 BrowserThread::IO, FROM_HERE, |
| 213 base::Bind( | 207 base::Bind( |
| 214 &PurgeMemoryOnIOThread, | 208 &PurgeMemoryOnIOThread, |
| 215 BrowserContext::GetDefaultStoragePartition(browser_context)-> | 209 BrowserContext::GetDefaultStoragePartition(browser_context)-> |
| 216 GetAppCacheService())); | 210 GetAppCacheService())); |
| 217 } | 211 } |
| 218 | 212 |
| 219 ForEachStoragePartition(browser_context, | 213 ForEachStoragePartition(browser_context, |
| 220 base::Bind(&PurgeDOMStorageContextInPartition)); | 214 base::Bind(&PurgeDOMStorageContextInPartition)); |
| 221 } | 215 } |
| 222 | 216 |
| 223 BrowserContext::~BrowserContext() { | 217 BrowserContext::~BrowserContext() { |
| 224 if (GetUserData(kDownloadManagerKeyName)) | 218 if (GetUserData(kDownloadManagerKeyName)) |
| 225 GetDownloadManager(this)->Shutdown(); | 219 GetDownloadManager(this)->Shutdown(); |
| 226 } | 220 } |
| 227 | 221 |
| 228 } // namespace content | 222 } // namespace content |
| OLD | NEW |