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

Side by Side Diff: content/browser/in_process_webkit/indexed_db_dispatcher_host.cc

Issue 9567030: Fix and re-enable IndexedDBBrowserTestWithLowQuota.QuotaTest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove more double IDB directories 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
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/browser/in_process_webkit/indexed_db_dispatcher_host.h" 5 #include "content/browser/in_process_webkit/indexed_db_dispatcher_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" 10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h"
(...skipping 11 matching lines...) Expand all
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h"
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h " 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h "
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h" 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBFactory.h"
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBIndex.h" 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBIndex.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" 31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
32 #include "webkit/database/database_util.h"
32 #include "webkit/glue/webkit_glue.h" 33 #include "webkit/glue/webkit_glue.h"
33 34
34 using content::BrowserMessageFilter; 35 using content::BrowserMessageFilter;
35 using content::BrowserThread; 36 using content::BrowserThread;
36 using content::UserMetricsAction; 37 using content::UserMetricsAction;
38 using webkit_database::DatabaseUtil;
37 using WebKit::WebDOMStringList; 39 using WebKit::WebDOMStringList;
38 using WebKit::WebExceptionCode; 40 using WebKit::WebExceptionCode;
39 using WebKit::WebIDBCallbacks; 41 using WebKit::WebIDBCallbacks;
40 using WebKit::WebIDBCursor; 42 using WebKit::WebIDBCursor;
41 using WebKit::WebIDBDatabase; 43 using WebKit::WebIDBDatabase;
42 using WebKit::WebIDBDatabaseError; 44 using WebKit::WebIDBDatabaseError;
43 using WebKit::WebIDBIndex; 45 using WebKit::WebIDBIndex;
44 using WebKit::WebIDBKey; 46 using WebKit::WebIDBKey;
45 using WebKit::WebIDBKeyRange; 47 using WebKit::WebIDBKeyRange;
46 using WebKit::WebIDBObjectStore; 48 using WebKit::WebIDBObjectStore;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 201 }
200 202
201 WebIDBCursor* IndexedDBDispatcherHost::GetCursorFromId(int32 cursor_id) { 203 WebIDBCursor* IndexedDBDispatcherHost::GetCursorFromId(int32 cursor_id) {
202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
203 return cursor_dispatcher_host_->map_.Lookup(cursor_id); 205 return cursor_dispatcher_host_->map_.Lookup(cursor_id);
204 } 206 }
205 207
206 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames( 208 void IndexedDBDispatcherHost::OnIDBFactoryGetDatabaseNames(
207 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) { 209 const IndexedDBHostMsg_FactoryGetDatabaseNames_Params& params) {
208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 210 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
209 FilePath base_path = indexed_db_context_->data_path(); 211 FilePath indexed_db_path = indexed_db_context_->data_path();
210 FilePath indexed_db_path;
211 if (!base_path.empty()) {
212 indexed_db_path = base_path.Append(
213 IndexedDBContextImpl::kIndexedDBDirectory);
214 }
215 212
216 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need
217 // to add some toString method to WebSecurityOrigin that doesn't
218 // return null for them. Look at
219 // DatabaseUtil::GetOriginFromIdentifier.
220 WebSecurityOrigin origin( 213 WebSecurityOrigin origin(
221 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); 214 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin));
222 GURL origin_url(origin.toString());
223
224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
225 215
226 Context()->GetIDBFactory()->getDatabaseNames( 216 Context()->GetIDBFactory()->getDatabaseNames(
227 new IndexedDBCallbacks<WebDOMStringList>(this, params.thread_id, 217 new IndexedDBCallbacks<WebDOMStringList>(this, params.thread_id,
228 params.response_id), origin, NULL, 218 params.response_id), origin, NULL,
229 webkit_glue::FilePathToWebString(indexed_db_path)); 219 webkit_glue::FilePathToWebString(indexed_db_path));
230 } 220 }
231 221
232 void IndexedDBDispatcherHost::OnIDBFactoryOpen( 222 void IndexedDBDispatcherHost::OnIDBFactoryOpen(
233 const IndexedDBHostMsg_FactoryOpen_Params& params) { 223 const IndexedDBHostMsg_FactoryOpen_Params& params) {
234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
235 FilePath base_path = indexed_db_context_->data_path(); 225 FilePath indexed_db_path = indexed_db_context_->data_path();
236 FilePath indexed_db_path;
237 if (!base_path.empty()) {
238 indexed_db_path = base_path.Append(
239 IndexedDBContextImpl::kIndexedDBDirectory);
240 }
241 226
242 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need 227 GURL origin_url = DatabaseUtil::GetOriginFromIdentifier(params.origin);
jsbell 2012/03/02 00:51:31 Maybe file a crbug to move this from database_util
dgrogan 2012/03/02 01:23:54 Done.
243 // to add some toString method to WebSecurityOrigin that doesn't
244 // return null for them. Look at
245 // DatabaseUtil::GetOriginFromIdentifier.
246 WebSecurityOrigin origin( 228 WebSecurityOrigin origin(
247 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); 229 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin));
248 GURL origin_url(origin.toString());
249 230
250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
251 232
252 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore 233 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore
253 // created) if this origin is already over quota. 234 // created) if this origin is already over quota.
254 Context()->GetIDBFactory()->open( 235 Context()->GetIDBFactory()->open(
255 params.name, 236 params.name,
256 new IndexedDBCallbacks<WebIDBDatabase>(this, params.thread_id, 237 new IndexedDBCallbacks<WebIDBDatabase>(this, params.thread_id,
257 params.response_id, origin_url), 238 params.response_id, origin_url),
258 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path)); 239 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path));
259 } 240 }
260 241
261 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( 242 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase(
262 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { 243 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) {
263 FilePath base_path = indexed_db_context_->data_path(); 244 FilePath indexed_db_path = indexed_db_context_->data_path();
264 FilePath indexed_db_path;
265 if (!base_path.empty()) {
266 indexed_db_path = base_path.Append(
267 IndexedDBContextImpl::kIndexedDBDirectory);
268 }
269 245
270 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
271 Context()->GetIDBFactory()->deleteDatabase( 247 Context()->GetIDBFactory()->deleteDatabase(
272 params.name, 248 params.name,
273 new IndexedDBCallbacks<WebSerializedScriptValue>(this, 249 new IndexedDBCallbacks<WebSerializedScriptValue>(this,
274 params.thread_id, 250 params.thread_id,
275 params.response_id), 251 params.response_id),
276 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin), NULL, 252 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin), NULL,
277 webkit_glue::FilePathToWebString(indexed_db_path)); 253 webkit_glue::FilePathToWebString(indexed_db_path));
278 } 254 }
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 1177
1202 void IndexedDBDispatcherHost:: 1178 void IndexedDBDispatcherHost::
1203 TransactionDispatcherHost::OnDidCompleteTaskEvents(int transaction_id) { 1179 TransactionDispatcherHost::OnDidCompleteTaskEvents(int transaction_id) {
1204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); 1180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
1205 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 1181 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
1206 &map_, transaction_id); 1182 &map_, transaction_id);
1207 if (!idb_transaction) 1183 if (!idb_transaction)
1208 return; 1184 return;
1209 1185
1210 // TODO(dgrogan): Tell the page the transaction aborted because of quota. 1186 // TODO(dgrogan): Tell the page the transaction aborted because of quota.
1187 // http://crbug.com/113118
1211 if (parent_->Context()->WouldBeOverQuota( 1188 if (parent_->Context()->WouldBeOverQuota(
1212 transaction_url_map_[transaction_id], 1189 transaction_url_map_[transaction_id],
1213 transaction_size_map_[transaction_id])) { 1190 transaction_size_map_[transaction_id])) {
1214 idb_transaction->abort(); 1191 idb_transaction->abort();
1215 return; 1192 return;
1216 } 1193 }
1217 idb_transaction->didCompleteTaskEvents(); 1194 idb_transaction->didCompleteTaskEvents();
1218 } 1195 }
1219 1196
1220 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( 1197 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed(
1221 int32 object_id) { 1198 int32 object_id) {
1222 transaction_size_map_.erase(object_id); 1199 transaction_size_map_.erase(object_id);
1223 transaction_url_map_.erase(object_id); 1200 transaction_url_map_.erase(object_id);
1224 parent_->DestroyObject(&map_, object_id); 1201 parent_->DestroyObject(&map_, object_id);
1225 } 1202 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698