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

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

Issue 10919307: Move IndexedDBContext into the StoragePartition and ensure isolation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove useless include Created 8 years, 3 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
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 "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
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 fileapi::FileSystemContext* BrowserContext::GetFileSystemContext( 106 fileapi::FileSystemContext* BrowserContext::GetFileSystemContext(
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)->GetFileSystemContext(); 110 return GetDefaultStoragePartition(browser_context)->GetFileSystemContext();
118 } 111 }
119 112
120 StoragePartition* BrowserContext::GetStoragePartition( 113 StoragePartition* BrowserContext::GetStoragePartition(
121 BrowserContext* browser_context, 114 BrowserContext* browser_context,
122 SiteInstance* site_instance) { 115 SiteInstance* site_instance) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // and when that call returns it'll end rewriting its UserData map. It will 159 // and when that call returns it'll end rewriting its UserData map. It will
167 // end up rewriting the same value but this still causes a race condition. 160 // end up rewriting the same value but this still causes a race condition.
168 // 161 //
169 // See http://crbug.com/115678. 162 // See http://crbug.com/115678.
170 GetDefaultStoragePartition(context); 163 GetDefaultStoragePartition(context);
171 } 164 }
172 165
173 void BrowserContext::SaveSessionState(BrowserContext* browser_context) { 166 void BrowserContext::SaveSessionState(BrowserContext* browser_context) {
174 GetDefaultStoragePartition(browser_context)->GetDatabaseTracker()-> 167 GetDefaultStoragePartition(browser_context)->GetDatabaseTracker()->
175 SetForceKeepSessionState(); 168 SetForceKeepSessionState();
169 StoragePartition* storage_partition =
170 BrowserContext::GetDefaultStoragePartition(browser_context);
176 171
177 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { 172 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
178 BrowserThread::PostTask( 173 BrowserThread::PostTask(
179 BrowserThread::IO, FROM_HERE, 174 BrowserThread::IO, FROM_HERE,
180 base::Bind( 175 base::Bind(
181 &SaveSessionStateOnIOThread, 176 &SaveSessionStateOnIOThread,
182 make_scoped_refptr(browser_context->GetRequestContext()), 177 make_scoped_refptr(browser_context->GetRequestContext()),
183 BrowserContext::GetDefaultStoragePartition(browser_context)-> 178 storage_partition->GetAppCacheService()));
184 GetAppCacheService()));
185 } 179 }
186 180
187 DOMStorageContextImpl* dom_storage_context_impl = 181 DOMStorageContextImpl* dom_storage_context_impl =
188 static_cast<DOMStorageContextImpl*>( 182 static_cast<DOMStorageContextImpl*>(
189 GetDefaultStoragePartition(browser_context)->GetDOMStorageContext()); 183 storage_partition->GetDOMStorageContext());
190 dom_storage_context_impl->SetForceKeepSessionState(); 184 dom_storage_context_impl->SetForceKeepSessionState();
191 185
192 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) { 186 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT_DEPRECATED)) {
193 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>( 187 IndexedDBContextImpl* indexed_db = static_cast<IndexedDBContextImpl*>(
194 GetIndexedDBContext(browser_context)); 188 storage_partition->GetIndexedDBContext());
195 BrowserThread::PostTask( 189 BrowserThread::PostTask(
196 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE, 190 BrowserThread::WEBKIT_DEPRECATED, FROM_HERE,
197 base::Bind(&SaveSessionStateOnWebkitThread, 191 base::Bind(&SaveSessionStateOnWebkitThread,
198 make_scoped_refptr(indexed_db))); 192 make_scoped_refptr(indexed_db)));
199 } 193 }
200 } 194 }
201 195
202 void BrowserContext::PurgeMemory(BrowserContext* browser_context) { 196 void BrowserContext::PurgeMemory(BrowserContext* browser_context) {
203 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { 197 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
204 BrowserThread::PostTask( 198 BrowserThread::PostTask(
205 BrowserThread::IO, FROM_HERE, 199 BrowserThread::IO, FROM_HERE,
206 base::Bind( 200 base::Bind(
207 &PurgeMemoryOnIOThread, 201 &PurgeMemoryOnIOThread,
208 BrowserContext::GetDefaultStoragePartition(browser_context)-> 202 BrowserContext::GetDefaultStoragePartition(browser_context)->
209 GetAppCacheService())); 203 GetAppCacheService()));
210 } 204 }
211 205
212 ForEachStoragePartition(browser_context, 206 ForEachStoragePartition(browser_context,
213 base::Bind(&PurgeDOMStorageContextInPartition)); 207 base::Bind(&PurgeDOMStorageContextInPartition));
214 } 208 }
215 209
216 BrowserContext::~BrowserContext() { 210 BrowserContext::~BrowserContext() {
217 if (GetUserData(kDownloadManagerKeyName)) 211 if (GetUserData(kDownloadManagerKeyName))
218 GetDownloadManager(this)->Shutdown(); 212 GetDownloadManager(this)->Shutdown();
219 } 213 }
220 214
221 } // namespace content 215 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/cookies_view_handler.cc ('k') | content/browser/in_process_webkit/indexed_db_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698