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 "content/browser/dom_storage/dom_storage_context_impl.h" | 8 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
9 #include "content/browser/fileapi/browser_file_system_helper.h" | 9 #include "content/browser/fileapi/browser_file_system_helper.h" |
10 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" | 10 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" |
11 #include "content/browser/resource_context_impl.h" | 11 #include "content/browser/resource_context_impl.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/common/content_constants.h" | 13 #include "content/public/common/content_constants.h" |
14 #include "net/base/server_bound_cert_service.h" | |
15 #include "net/base/server_bound_cert_store.h" | |
14 #include "net/cookies/cookie_monster.h" | 16 #include "net/cookies/cookie_monster.h" |
15 #include "net/cookies/cookie_store.h" | 17 #include "net/cookies/cookie_store.h" |
16 #include "net/url_request/url_request_context.h" | 18 #include "net/url_request/url_request_context.h" |
17 #include "webkit/database/database_tracker.h" | 19 #include "webkit/database/database_tracker.h" |
18 #include "webkit/quota/quota_manager.h" | 20 #include "webkit/quota/quota_manager.h" |
19 | 21 |
20 using appcache::AppCacheService; | 22 using appcache::AppCacheService; |
21 using base::UserDataAdapter; | 23 using base::UserDataAdapter; |
22 using content::BrowserThread; | 24 using content::BrowserThread; |
23 using fileapi::FileSystemContext; | 25 using fileapi::FileSystemContext; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 context->IsOffTheRecord() ? FilePath() : | 107 context->IsOffTheRecord() ? FilePath() : |
106 context->GetPath().Append(content::kAppCacheDirname), | 108 context->GetPath().Append(content::kAppCacheDirname), |
107 context->GetResourceContext(), | 109 context->GetResourceContext(), |
108 make_scoped_refptr(context->GetSpecialStoragePolicy()))); | 110 make_scoped_refptr(context->GetSpecialStoragePolicy()))); |
109 } | 111 } |
110 } | 112 } |
111 | 113 |
112 void SaveSessionStateOnIOThread(ResourceContext* resource_context) { | 114 void SaveSessionStateOnIOThread(ResourceContext* resource_context) { |
113 resource_context->GetRequestContext()->cookie_store()->GetCookieMonster()-> | 115 resource_context->GetRequestContext()->cookie_store()->GetCookieMonster()-> |
114 SaveSessionCookies(); | 116 SaveSessionCookies(); |
117 resource_context->GetRequestContext()->server_bound_cert_service()-> | |
118 GetCertStore()->SaveSessionState(); | |
115 ResourceContext::GetAppCacheService(resource_context)->set_save_session_state( | 119 ResourceContext::GetAppCacheService(resource_context)->set_save_session_state( |
116 true); | 120 true); |
117 } | 121 } |
118 | 122 |
119 void SaveSessionStateOnWebkitThread( | 123 void SaveSessionStateOnWebkitThread( |
120 scoped_refptr<IndexedDBContextImpl> indexed_db_context) { | 124 scoped_refptr<IndexedDBContextImpl> indexed_db_context) { |
121 indexed_db_context->SaveSessionState(); | 125 indexed_db_context->SaveSessionState(); |
122 } | 126 } |
123 | 127 |
124 void PurgeMemoryOnIOThread(ResourceContext* resource_context) { | 128 void PurgeMemoryOnIOThread(ResourceContext* resource_context) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { | 199 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { |
196 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>( | 200 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>( |
197 GetIndexedDBContext(browser_context)); | 201 GetIndexedDBContext(browser_context)); |
198 BrowserThread::PostTask( | 202 BrowserThread::PostTask( |
199 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, | 203 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, |
200 base::Bind(&SaveSessionStateOnWebkitThread, | 204 base::Bind(&SaveSessionStateOnWebkitThread, |
201 make_scoped_refptr(indexed_db))); | 205 make_scoped_refptr(indexed_db))); |
202 } | 206 } |
203 } | 207 } |
204 | 208 |
205 void BrowserContext::ClearLocalOnDestruction(BrowserContext* browser_context) { | |
206 GetDOMStorageContextImpl(browser_context)->SetClearLocalState(true); | |
207 | |
208 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>( | |
209 GetIndexedDBContext(browser_context)); | |
210 indexed_db->set_clear_local_state_on_exit(true); | |
211 | |
212 GetDatabaseTracker(browser_context)->SetClearLocalStateOnExit(true); | |
213 | |
214 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { | |
215 BrowserThread::PostTask( | |
216 BrowserThread::IO, FROM_HERE, | |
217 base::Bind(&appcache::AppCacheService::set_clear_local_state_on_exit, | |
michaeln
2012/06/01 02:06:17
Can this method and associated stuff also be remov
jochen (gone - plz use gerrit)
2012/06/01 12:15:19
Done.
| |
218 base::Unretained(GetAppCacheService(browser_context)), true)); | |
219 } | |
220 } | |
221 | |
222 void BrowserContext::PurgeMemory(BrowserContext* browser_context) { | 209 void BrowserContext::PurgeMemory(BrowserContext* browser_context) { |
223 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { | 210 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { |
224 BrowserThread::PostTask( | 211 BrowserThread::PostTask( |
225 BrowserThread::IO, FROM_HERE, | 212 BrowserThread::IO, FROM_HERE, |
226 base::Bind(&PurgeMemoryOnIOThread, | 213 base::Bind(&PurgeMemoryOnIOThread, |
227 browser_context->GetResourceContext())); | 214 browser_context->GetResourceContext())); |
228 } | 215 } |
229 | 216 |
230 GetDOMStorageContextImpl(browser_context)->PurgeMemory(); | 217 GetDOMStorageContextImpl(browser_context)->PurgeMemory(); |
231 } | 218 } |
232 | 219 |
233 BrowserContext::~BrowserContext() { | 220 BrowserContext::~BrowserContext() { |
234 // These message loop checks are just to avoid leaks in unittests. | 221 // These message loop checks are just to avoid leaks in unittests. |
235 if (GetUserData(kDatabaseTrackerKeyName) && | 222 if (GetUserData(kDatabaseTrackerKeyName) && |
236 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { | 223 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { |
237 BrowserThread::PostTask( | 224 BrowserThread::PostTask( |
238 BrowserThread::FILE, FROM_HERE, | 225 BrowserThread::FILE, FROM_HERE, |
239 base::Bind(&webkit_database::DatabaseTracker::Shutdown, | 226 base::Bind(&webkit_database::DatabaseTracker::Shutdown, |
240 GetDatabaseTracker(this))); | 227 GetDatabaseTracker(this))); |
241 } | 228 } |
242 | 229 |
243 if (GetUserData(kDOMStorageContextKeyName)) | 230 if (GetUserData(kDOMStorageContextKeyName)) |
244 GetDOMStorageContextImpl(this)->Shutdown(); | 231 GetDOMStorageContextImpl(this)->Shutdown(); |
245 } | 232 } |
246 | 233 |
247 } // namespace content | 234 } // namespace content |
OLD | NEW |