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

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

Issue 9726022: Revert 127573 - DOMStorageContextImpl that's implemented in terms of the new dom_storage classes. A… (Closed) Base URL: svn://svn.chromium.org/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 | « no previous file | 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
39 void CreateQuotaManagerAndClients(BrowserContext* context) { 37 void CreateQuotaManagerAndClients(BrowserContext* context) {
40 if (context->GetUserData(kQuotaManagerKeyName)) { 38 if (context->GetUserData(kQuotaManagerKeyName)) {
41 DCHECK(context->GetUserData(kDatabaseTrackerKeyName)); 39 DCHECK(context->GetUserData(kDatabaseTrackerKeyName));
42 DCHECK(context->GetUserData(kDOMStorageContextKeyName)); 40 DCHECK(context->GetUserData(kDOMStorageContextKeyName));
43 DCHECK(context->GetUserData(kFileSystemContextKeyName)); 41 DCHECK(context->GetUserData(kFileSystemContextKeyName));
44 DCHECK(context->GetUserData(kIndexedDBContextKeyName)); 42 DCHECK(context->GetUserData(kIndexedDBContextKeyName));
45 return; 43 return;
46 } 44 }
47 45
48 // All of the clients have to be created and registered with the 46 // All of the clients have to be created and registered with the
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 108 }
111 109
112 void SaveSessionStateOnIOThread(ResourceContext* resource_context) { 110 void SaveSessionStateOnIOThread(ResourceContext* resource_context) {
113 resource_context->GetRequestContext()->cookie_store()->GetCookieMonster()-> 111 resource_context->GetRequestContext()->cookie_store()->GetCookieMonster()->
114 SaveSessionCookies(); 112 SaveSessionCookies();
115 ResourceContext::GetAppCacheService(resource_context)->set_save_session_state( 113 ResourceContext::GetAppCacheService(resource_context)->set_save_session_state(
116 true); 114 true);
117 } 115 }
118 116
119 void SaveSessionStateOnWebkitThread( 117 void SaveSessionStateOnWebkitThread(
118 scoped_refptr<DOMStorageContextImpl> dom_storage_context,
120 scoped_refptr<IndexedDBContextImpl> indexed_db_context) { 119 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 DOMStorageContextImpl* GetDOMStorageContextImpl(BrowserContext* context) { 128 void PurgeMemoryOnWebkitThread(
129 return static_cast<DOMStorageContextImpl*>( 129 scoped_refptr<DOMStorageContextImpl> dom_storage_context) {
130 BrowserContext::GetDOMStorageContext(context)); 130 dom_storage_context->PurgeMemory();
131 } 131 }
132 132
133 } // namespace
134
135 QuotaManager* BrowserContext::GetQuotaManager(BrowserContext* context) { 133 QuotaManager* BrowserContext::GetQuotaManager(BrowserContext* context) {
136 CreateQuotaManagerAndClients(context); 134 CreateQuotaManagerAndClients(context);
137 return UserDataAdapter<QuotaManager>::Get(context, kQuotaManagerKeyName); 135 return UserDataAdapter<QuotaManager>::Get(context, kQuotaManagerKeyName);
138 } 136 }
139 137
140 DOMStorageContext* BrowserContext::GetDOMStorageContext( 138 DOMStorageContext* BrowserContext::GetDOMStorageContext(
141 BrowserContext* context) { 139 BrowserContext* context) {
142 CreateQuotaManagerAndClients(context); 140 CreateQuotaManagerAndClients(context);
143 return UserDataAdapter<DOMStorageContextImpl>::Get( 141 return UserDataAdapter<DOMStorageContextImpl>::Get(
144 context, kDOMStorageContextKeyName); 142 context, kDOMStorageContextKeyName);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 void BrowserContext::SaveSessionState(BrowserContext* browser_context) { 181 void BrowserContext::SaveSessionState(BrowserContext* browser_context) {
184 GetDatabaseTracker(browser_context)->SaveSessionState(); 182 GetDatabaseTracker(browser_context)->SaveSessionState();
185 183
186 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { 184 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
187 BrowserThread::PostTask( 185 BrowserThread::PostTask(
188 BrowserThread::IO, FROM_HERE, 186 BrowserThread::IO, FROM_HERE,
189 base::Bind(&SaveSessionStateOnIOThread, 187 base::Bind(&SaveSessionStateOnIOThread,
190 browser_context->GetResourceContext())); 188 browser_context->GetResourceContext()));
191 } 189 }
192 190
193 GetDOMStorageContextImpl(browser_context)->SaveSessionState();
194
195 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { 191 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) {
192 DOMStorageContextImpl* dom_context = static_cast<DOMStorageContextImpl*>(
193 GetDOMStorageContext(browser_context));
196 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>( 194 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>(
197 GetIndexedDBContext(browser_context)); 195 GetIndexedDBContext(browser_context));
198 BrowserThread::PostTask( 196 BrowserThread::PostTask(
199 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, 197 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
200 base::Bind(&SaveSessionStateOnWebkitThread, 198 base::Bind(&SaveSessionStateOnWebkitThread,
199 make_scoped_refptr(dom_context),
201 make_scoped_refptr(indexed_db))); 200 make_scoped_refptr(indexed_db)));
202 } 201 }
203 } 202 }
204 203
205 void BrowserContext::ClearLocalOnDestruction(BrowserContext* browser_context) { 204 void BrowserContext::ClearLocalOnDestruction(BrowserContext* browser_context) {
206 GetDOMStorageContextImpl(browser_context)->SetClearLocalState(true); 205 DOMStorageContextImpl* dom_context = static_cast<DOMStorageContextImpl*>(
206 GetDOMStorageContext(browser_context));
207 dom_context->set_clear_local_state_on_exit(true);
207 208
208 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>( 209 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>(
209 GetIndexedDBContext(browser_context)); 210 GetIndexedDBContext(browser_context));
210 indexed_db->set_clear_local_state_on_exit(true); 211 indexed_db->set_clear_local_state_on_exit(true);
211 212
212 GetDatabaseTracker(browser_context)->SetClearLocalStateOnExit(true); 213 GetDatabaseTracker(browser_context)->SetClearLocalStateOnExit(true);
213 214
214 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { 215 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
215 BrowserThread::PostTask( 216 BrowserThread::PostTask(
216 BrowserThread::IO, FROM_HERE, 217 BrowserThread::IO, FROM_HERE,
217 base::Bind(&appcache::AppCacheService::set_clear_local_state_on_exit, 218 base::Bind(&appcache::AppCacheService::set_clear_local_state_on_exit,
218 base::Unretained(GetAppCacheService(browser_context)), true)); 219 base::Unretained(GetAppCacheService(browser_context)), true));
219 } 220 }
220 } 221 }
221 222
222 void BrowserContext::PurgeMemory(BrowserContext* browser_context) { 223 void BrowserContext::PurgeMemory(BrowserContext* browser_context) {
223 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { 224 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
224 BrowserThread::PostTask( 225 BrowserThread::PostTask(
225 BrowserThread::IO, FROM_HERE, 226 BrowserThread::IO, FROM_HERE,
226 base::Bind(&PurgeMemoryOnIOThread, 227 base::Bind(&PurgeMemoryOnIOThread,
227 browser_context->GetResourceContext())); 228 browser_context->GetResourceContext()));
228 } 229 }
229 230
230 GetDOMStorageContextImpl(browser_context)->PurgeMemory(); 231 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) {
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 }
231 } 239 }
232 240
233 BrowserContext::~BrowserContext() { 241 BrowserContext::~BrowserContext() {
234 // These message loop checks are just to avoid leaks in unittests. 242 // These message loop checks are just to avoid leaks in unittests.
235 if (GetUserData(kDatabaseTrackerKeyName) && 243 if (GetUserData(kDatabaseTrackerKeyName) &&
236 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { 244 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) {
237 BrowserThread::PostTask( 245 BrowserThread::PostTask(
238 BrowserThread::FILE, FROM_HERE, 246 BrowserThread::FILE, FROM_HERE,
239 base::Bind(&webkit_database::DatabaseTracker::Shutdown, 247 base::Bind(&webkit_database::DatabaseTracker::Shutdown,
240 GetDatabaseTracker(this))); 248 GetDatabaseTracker(this)));
241 } 249 }
242 250
243 #ifdef ENABLE_NEW_DOM_STORAGE_BACKEND
244 if (GetUserData(kDOMStorageContextKeyName))
245 GetDOMStorageContextImpl(this)->Shutdown();
246 #else
247 if (GetUserData(kDOMStorageContextKeyName) && 251 if (GetUserData(kDOMStorageContextKeyName) &&
248 BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { 252 BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) {
249 DOMStorageContextImpl* dom_storage_context = 253 DOMStorageContextImpl* dom_storage_context =
250 (static_cast<UserDataAdapter<DOMStorageContextImpl>*>( 254 (static_cast<UserDataAdapter<DOMStorageContextImpl>*>(
251 GetUserData(kDOMStorageContextKeyName)))->release(); 255 GetUserData(kDOMStorageContextKeyName)))->release();
252 BrowserThread::ReleaseSoon( 256 BrowserThread::ReleaseSoon(
253 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, dom_storage_context); 257 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, dom_storage_context);
254 } 258 }
255 #endif
256 } 259 }
257 260
258 } // namespace content 261 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | 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