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

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

Issue 9695013: DOMStorageContextImpl that's implemented in terms of the new dom_storage classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | content/browser/dom_storage/dom_storage_context_impl_new.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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/fileapi/browser_file_system_helper.h" 8 #include "content/browser/fileapi/browser_file_system_helper.h"
9 #include "content/browser/in_process_webkit/dom_storage_context_impl.h" 9 #include "content/browser/in_process_webkit/dom_storage_context_impl.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"
(...skipping 16 matching lines...) Expand all
27 // Key names on BrowserContext. 27 // Key names on BrowserContext.
28 static const char* kAppCacheServicKeyName = "content_appcache_service_tracker"; 28 static const char* kAppCacheServicKeyName = "content_appcache_service_tracker";
29 static const char* kDatabaseTrackerKeyName = "content_database_tracker"; 29 static const char* kDatabaseTrackerKeyName = "content_database_tracker";
30 static const char* kDOMStorageContextKeyName = "content_dom_storage_context"; 30 static const char* kDOMStorageContextKeyName = "content_dom_storage_context";
31 static const char* kFileSystemContextKeyName = "content_file_system_context"; 31 static const char* kFileSystemContextKeyName = "content_file_system_context";
32 static const char* kIndexedDBContextKeyName = "content_indexed_db_context"; 32 static const char* kIndexedDBContextKeyName = "content_indexed_db_context";
33 static const char* kQuotaManagerKeyName = "content_quota_manager"; 33 static const char* kQuotaManagerKeyName = "content_quota_manager";
34 34
35 namespace content { 35 namespace content {
36 36
37 namespace {
38
37 void CreateQuotaManagerAndClients(BrowserContext* context) { 39 void CreateQuotaManagerAndClients(BrowserContext* context) {
38 if (context->GetUserData(kQuotaManagerKeyName)) { 40 if (context->GetUserData(kQuotaManagerKeyName)) {
39 DCHECK(context->GetUserData(kDatabaseTrackerKeyName)); 41 DCHECK(context->GetUserData(kDatabaseTrackerKeyName));
40 DCHECK(context->GetUserData(kDOMStorageContextKeyName)); 42 DCHECK(context->GetUserData(kDOMStorageContextKeyName));
41 DCHECK(context->GetUserData(kFileSystemContextKeyName)); 43 DCHECK(context->GetUserData(kFileSystemContextKeyName));
42 DCHECK(context->GetUserData(kIndexedDBContextKeyName)); 44 DCHECK(context->GetUserData(kIndexedDBContextKeyName));
43 return; 45 return;
44 } 46 }
45 47
46 // All of the clients have to be created and registered with the 48 // All of the clients have to be created and registered with the
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 110 }
109 111
110 void SaveSessionStateOnIOThread(ResourceContext* resource_context) { 112 void SaveSessionStateOnIOThread(ResourceContext* resource_context) {
111 resource_context->GetRequestContext()->cookie_store()->GetCookieMonster()-> 113 resource_context->GetRequestContext()->cookie_store()->GetCookieMonster()->
112 SaveSessionCookies(); 114 SaveSessionCookies();
113 ResourceContext::GetAppCacheService(resource_context)->set_save_session_state( 115 ResourceContext::GetAppCacheService(resource_context)->set_save_session_state(
114 true); 116 true);
115 } 117 }
116 118
117 void SaveSessionStateOnWebkitThread( 119 void SaveSessionStateOnWebkitThread(
118 scoped_refptr<DOMStorageContextImpl> dom_storage_context,
119 scoped_refptr<IndexedDBContextImpl> indexed_db_context) { 120 scoped_refptr<IndexedDBContextImpl> indexed_db_context) {
120 dom_storage_context->SaveSessionState();
121 indexed_db_context->SaveSessionState(); 121 indexed_db_context->SaveSessionState();
122 } 122 }
123 123
124 void PurgeMemoryOnIOThread(ResourceContext* resource_context) { 124 void PurgeMemoryOnIOThread(ResourceContext* resource_context) {
125 ResourceContext::GetAppCacheService(resource_context)->PurgeMemory(); 125 ResourceContext::GetAppCacheService(resource_context)->PurgeMemory();
126 } 126 }
127 127
128 void PurgeMemoryOnWebkitThread( 128 DOMStorageContextImpl* GetDOMStorageContextImpl(BrowserContext* context) {
129 scoped_refptr<DOMStorageContextImpl> dom_storage_context) { 129 return static_cast<DOMStorageContextImpl*>(
130 dom_storage_context->PurgeMemory(); 130 BrowserContext::GetDOMStorageContext(context));
131 } 131 }
132 132
133 } // namespace
134
133 QuotaManager* BrowserContext::GetQuotaManager(BrowserContext* context) { 135 QuotaManager* BrowserContext::GetQuotaManager(BrowserContext* context) {
134 CreateQuotaManagerAndClients(context); 136 CreateQuotaManagerAndClients(context);
135 return UserDataAdapter<QuotaManager>::Get(context, kQuotaManagerKeyName); 137 return UserDataAdapter<QuotaManager>::Get(context, kQuotaManagerKeyName);
136 } 138 }
137 139
138 DOMStorageContext* BrowserContext::GetDOMStorageContext( 140 DOMStorageContext* BrowserContext::GetDOMStorageContext(
139 BrowserContext* context) { 141 BrowserContext* context) {
140 CreateQuotaManagerAndClients(context); 142 CreateQuotaManagerAndClients(context);
141 return UserDataAdapter<DOMStorageContextImpl>::Get( 143 return UserDataAdapter<DOMStorageContextImpl>::Get(
142 context, kDOMStorageContextKeyName); 144 context, kDOMStorageContextKeyName);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 void BrowserContext::SaveSessionState(BrowserContext* browser_context) { 183 void BrowserContext::SaveSessionState(BrowserContext* browser_context) {
182 GetDatabaseTracker(browser_context)->SaveSessionState(); 184 GetDatabaseTracker(browser_context)->SaveSessionState();
183 185
184 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { 186 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
185 BrowserThread::PostTask( 187 BrowserThread::PostTask(
186 BrowserThread::IO, FROM_HERE, 188 BrowserThread::IO, FROM_HERE,
187 base::Bind(&SaveSessionStateOnIOThread, 189 base::Bind(&SaveSessionStateOnIOThread,
188 browser_context->GetResourceContext())); 190 browser_context->GetResourceContext()));
189 } 191 }
190 192
193 GetDOMStorageContextImpl(browser_context)->SaveSessionState();
michaeln 2012/03/17 03:52:22 the gist of these changes is to remove the WEBKIT_
194
191 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { 195 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) {
192 DOMStorageContextImpl* dom_context = static_cast<DOMStorageContextImpl*>(
193 GetDOMStorageContext(browser_context));
194 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>( 196 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>(
195 GetIndexedDBContext(browser_context)); 197 GetIndexedDBContext(browser_context));
196 BrowserThread::PostTask( 198 BrowserThread::PostTask(
197 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, 199 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
198 base::Bind(&SaveSessionStateOnWebkitThread, 200 base::Bind(&SaveSessionStateOnWebkitThread,
199 make_scoped_refptr(dom_context),
200 make_scoped_refptr(indexed_db))); 201 make_scoped_refptr(indexed_db)));
201 } 202 }
202 } 203 }
203 204
204 void BrowserContext::ClearLocalOnDestruction(BrowserContext* browser_context) { 205 void BrowserContext::ClearLocalOnDestruction(BrowserContext* browser_context) {
205 DOMStorageContextImpl* dom_context = static_cast<DOMStorageContextImpl*>( 206 GetDOMStorageContextImpl(browser_context)->SetClearLocalState(true);
206 GetDOMStorageContext(browser_context));
207 dom_context->set_clear_local_state_on_exit(true);
208 207
209 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>( 208 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>(
210 GetIndexedDBContext(browser_context)); 209 GetIndexedDBContext(browser_context));
211 indexed_db->set_clear_local_state_on_exit(true); 210 indexed_db->set_clear_local_state_on_exit(true);
212 211
213 GetDatabaseTracker(browser_context)->SetClearLocalStateOnExit(true); 212 GetDatabaseTracker(browser_context)->SetClearLocalStateOnExit(true);
214 213
215 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { 214 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
216 BrowserThread::PostTask( 215 BrowserThread::PostTask(
217 BrowserThread::IO, FROM_HERE, 216 BrowserThread::IO, FROM_HERE,
218 base::Bind(&appcache::AppCacheService::set_clear_local_state_on_exit, 217 base::Bind(&appcache::AppCacheService::set_clear_local_state_on_exit,
219 base::Unretained(GetAppCacheService(browser_context)), true)); 218 base::Unretained(GetAppCacheService(browser_context)), true));
220 } 219 }
221 } 220 }
222 221
223 void BrowserContext::PurgeMemory(BrowserContext* browser_context) { 222 void BrowserContext::PurgeMemory(BrowserContext* browser_context) {
224 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { 223 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
225 BrowserThread::PostTask( 224 BrowserThread::PostTask(
226 BrowserThread::IO, FROM_HERE, 225 BrowserThread::IO, FROM_HERE,
227 base::Bind(&PurgeMemoryOnIOThread, 226 base::Bind(&PurgeMemoryOnIOThread,
228 browser_context->GetResourceContext())); 227 browser_context->GetResourceContext()));
229 } 228 }
230 229
231 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { 230 GetDOMStorageContextImpl(browser_context)->PurgeMemory();
232 DOMStorageContextImpl* dom_context = static_cast<DOMStorageContextImpl*>(
233 GetDOMStorageContext(browser_context));
234 BrowserThread::PostTask(
235 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
236 base::Bind(&PurgeMemoryOnWebkitThread,
237 make_scoped_refptr(dom_context)));
238 }
239 } 231 }
240 232
241 BrowserContext::~BrowserContext() { 233 BrowserContext::~BrowserContext() {
242 // These message loop checks are just to avoid leaks in unittests. 234 // These message loop checks are just to avoid leaks in unittests.
243 if (GetUserData(kDatabaseTrackerKeyName) && 235 if (GetUserData(kDatabaseTrackerKeyName) &&
244 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { 236 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) {
245 BrowserThread::PostTask( 237 BrowserThread::PostTask(
246 BrowserThread::FILE, FROM_HERE, 238 BrowserThread::FILE, FROM_HERE,
247 base::Bind(&webkit_database::DatabaseTracker::Shutdown, 239 base::Bind(&webkit_database::DatabaseTracker::Shutdown,
248 GetDatabaseTracker(this))); 240 GetDatabaseTracker(this)));
249 } 241 }
250 242
243 #ifdef ENABLE_NEW_DOM_STORAGE_BACKEND
244 if (GetUserData(kDOMStorageContextKeyName))
245 GetDOMStorageContextImpl(this)->Shutdown();
michaeln 2012/03/17 03:52:22 adding an explicit shutdown method since relying o
246 #else
251 if (GetUserData(kDOMStorageContextKeyName) && 247 if (GetUserData(kDOMStorageContextKeyName) &&
252 BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { 248 BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) {
253 DOMStorageContextImpl* dom_storage_context = 249 DOMStorageContextImpl* dom_storage_context =
254 (static_cast<UserDataAdapter<DOMStorageContextImpl>*>( 250 (static_cast<UserDataAdapter<DOMStorageContextImpl>*>(
255 GetUserData(kDOMStorageContextKeyName)))->release(); 251 GetUserData(kDOMStorageContextKeyName)))->release();
256 BrowserThread::ReleaseSoon( 252 BrowserThread::ReleaseSoon(
257 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, dom_storage_context); 253 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, dom_storage_context);
258 } 254 }
255 #endif
259 } 256 }
260 257
261 } // namespace content 258 } // namespace content
OLDNEW
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | content/browser/dom_storage/dom_storage_context_impl_new.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698