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

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

Issue 7470008: Improve IndexedDB's quota support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: finally responded to everything Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "content/browser/browser_thread.h" 9 #include "content/browser/browser_thread.h"
10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h" 10 #include "content/browser/in_process_webkit/indexed_db_callbacks.h"
(...skipping 10 matching lines...) Expand all
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabase.h"
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h " 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBDatabaseError.h "
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h" 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKeyRange.h"
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBIndex.h" 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBIndex.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/WebIDBObjectStore.h" 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBObjectStore.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBTransaction.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
30 #include "webkit/glue/webkit_glue.h" 30 #include "webkit/glue/webkit_glue.h"
31 #include "webkit/quota/quota_manager.h"
32 31
33 using WebKit::WebDOMStringList; 32 using WebKit::WebDOMStringList;
34 using WebKit::WebExceptionCode; 33 using WebKit::WebExceptionCode;
35 using WebKit::WebIDBCallbacks; 34 using WebKit::WebIDBCallbacks;
36 using WebKit::WebIDBCursor; 35 using WebKit::WebIDBCursor;
37 using WebKit::WebIDBDatabase; 36 using WebKit::WebIDBDatabase;
38 using WebKit::WebIDBDatabaseError; 37 using WebKit::WebIDBDatabaseError;
39 using WebKit::WebIDBIndex; 38 using WebKit::WebIDBIndex;
40 using WebKit::WebIDBKey; 39 using WebKit::WebIDBKey;
41 using WebKit::WebIDBKeyRange; 40 using WebKit::WebIDBKeyRange;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 return cursor_dispatcher_host_->map_.Add(idb_cursor); 147 return cursor_dispatcher_host_->map_.Add(idb_cursor);
149 } 148 }
150 149
151 int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database, 150 int32 IndexedDBDispatcherHost::Add(WebIDBDatabase* idb_database,
152 const GURL& origin_url) { 151 const GURL& origin_url) {
153 if (!database_dispatcher_host_.get()) { 152 if (!database_dispatcher_host_.get()) {
154 delete idb_database; 153 delete idb_database;
155 return 0; 154 return 0;
156 } 155 }
157 int32 idb_database_id = database_dispatcher_host_->map_.Add(idb_database); 156 int32 idb_database_id = database_dispatcher_host_->map_.Add(idb_database);
158 database_dispatcher_host_->url_map_[idb_database_id] = origin_url; 157 Context()->ConnectionOpened(origin_url);
158 database_dispatcher_host_->database_url_map_[idb_database_id] = origin_url;
159 return idb_database_id; 159 return idb_database_id;
160 } 160 }
161 161
162 int32 IndexedDBDispatcherHost::Add(WebIDBIndex* idb_index) { 162 int32 IndexedDBDispatcherHost::Add(WebIDBIndex* idb_index) {
163 if (!index_dispatcher_host_.get()) { 163 if (!index_dispatcher_host_.get()) {
164 delete idb_index; 164 delete idb_index;
165 return 0; 165 return 0;
166 } 166 }
167 if (!idb_index) 167 if (!idb_index)
168 return 0; 168 return 0;
169 return index_dispatcher_host_->map_.Add(idb_index); 169 return index_dispatcher_host_->map_.Add(idb_index);
170 } 170 }
171 171
172 int32 IndexedDBDispatcherHost::Add(WebIDBObjectStore* idb_object_store) { 172 int32 IndexedDBDispatcherHost::Add(WebIDBObjectStore* idb_object_store) {
173 if (!object_store_dispatcher_host_.get()) { 173 if (!object_store_dispatcher_host_.get()) {
174 delete idb_object_store; 174 delete idb_object_store;
175 return 0; 175 return 0;
176 } 176 }
177 if (!idb_object_store) 177 if (!idb_object_store)
178 return 0; 178 return 0;
179 return object_store_dispatcher_host_->map_.Add(idb_object_store); 179 return object_store_dispatcher_host_->map_.Add(idb_object_store);
180 } 180 }
181 181
182 int32 IndexedDBDispatcherHost::Add(WebIDBTransaction* idb_transaction) { 182 int32 IndexedDBDispatcherHost::Add(WebIDBTransaction* idb_transaction,
183 const GURL& url) {
183 if (!transaction_dispatcher_host_.get()) { 184 if (!transaction_dispatcher_host_.get()) {
184 delete idb_transaction; 185 delete idb_transaction;
185 return 0; 186 return 0;
186 } 187 }
187 int32 id = transaction_dispatcher_host_->map_.Add(idb_transaction); 188 int32 id = transaction_dispatcher_host_->map_.Add(idb_transaction);
188 idb_transaction->setCallbacks(new IndexedDBTransactionCallbacks(this, id)); 189 idb_transaction->setCallbacks(new IndexedDBTransactionCallbacks(this, id));
190 transaction_dispatcher_host_->transaction_url_map_[id] = url;
189 return id; 191 return id;
190 } 192 }
191 193
192 void IndexedDBDispatcherHost::OnIDBFactoryOpen( 194 void IndexedDBDispatcherHost::OnIDBFactoryOpen(
193 const IndexedDBHostMsg_FactoryOpen_Params& params) { 195 const IndexedDBHostMsg_FactoryOpen_Params& params) {
196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
194 FilePath base_path = webkit_context_->data_path(); 197 FilePath base_path = webkit_context_->data_path();
195 FilePath indexed_db_path; 198 FilePath indexed_db_path;
196 if (!base_path.empty()) { 199 if (!base_path.empty()) {
197 indexed_db_path = base_path.Append( 200 indexed_db_path = base_path.Append(
198 IndexedDBContext::kIndexedDBDirectory); 201 IndexedDBContext::kIndexedDBDirectory);
199 } 202 }
200 203
201 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need 204 // TODO(jorlow): This doesn't support file:/// urls properly. We probably need
202 // to add some toString method to WebSecurityOrigin that doesn't 205 // to add some toString method to WebSecurityOrigin that doesn't
203 // return null for them. 206 // return null for them.
(...skipping 15 matching lines...) Expand all
219 } 222 }
220 223
221 WebKit::WebIDBFactory::BackingStoreType backingStoreType = 224 WebKit::WebIDBFactory::BackingStoreType backingStoreType =
222 WebKit::WebIDBFactory::LevelDBBackingStore; 225 WebKit::WebIDBFactory::LevelDBBackingStore;
223 226
224 if (CommandLine::ForCurrentProcess()->HasSwitch( 227 if (CommandLine::ForCurrentProcess()->HasSwitch(
225 switches::kSQLiteIndexedDatabase)) { 228 switches::kSQLiteIndexedDatabase)) {
226 backingStoreType = WebKit::WebIDBFactory::SQLiteBackingStore; 229 backingStoreType = WebKit::WebIDBFactory::SQLiteBackingStore;
227 } 230 }
228 231
232 // TODO(dgrogan): Don't let a non-existing database be opened (and therefore
233 // created) if this origin is already over quota.
229 Context()->GetIDBFactory()->open( 234 Context()->GetIDBFactory()->open(
230 params.name, 235 params.name,
231 new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id, 236 new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id,
232 origin_url), 237 origin_url),
233 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path), quota, 238 origin, NULL, webkit_glue::FilePathToWebString(indexed_db_path), quota,
234 backingStoreType); 239 backingStoreType);
235 } 240 }
236 241
237 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase( 242 void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase(
238 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) { 243 const IndexedDBHostMsg_FactoryDeleteDatabase_Params& params) {
239 FilePath base_path = webkit_context_->data_path(); 244 FilePath base_path = webkit_context_->data_path();
240 FilePath indexed_db_path; 245 FilePath indexed_db_path;
241 if (!base_path.empty()) { 246 if (!base_path.empty()) {
242 indexed_db_path = base_path.Append( 247 indexed_db_path = base_path.Append(
243 IndexedDBContext::kIndexedDBDirectory); 248 IndexedDBContext::kIndexedDBDirectory);
244 } 249 }
245 250
246 WebSecurityOrigin origin( 251 WebSecurityOrigin origin(
247 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); 252 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin));
248 GURL url(origin.toString()); 253 GURL url(origin.toString());
249 254
250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
251 Context()->GetIDBFactory()->deleteDatabase( 256 Context()->GetIDBFactory()->deleteDatabase(
252 params.name, 257 params.name,
253 new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id, url), 258 new IndexedDBCallbacks<WebIDBDatabase>(this, params.response_id, url),
254 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin), NULL, 259 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin), NULL,
255 webkit_glue::FilePathToWebString(indexed_db_path)); 260 webkit_glue::FilePathToWebString(indexed_db_path));
256 } 261 }
257 262
263 void IndexedDBDispatcherHost::TransactionComplete(int32 transaction_id) {
264 Context()->TransactionComplete(
265 transaction_dispatcher_host_->transaction_url_map_[transaction_id]);
266 }
267
258 ////////////////////////////////////////////////////////////////////// 268 //////////////////////////////////////////////////////////////////////
259 // Helper templates. 269 // Helper templates.
260 // 270 //
261 271
262 template <typename ObjectType> 272 template <typename ObjectType>
263 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( 273 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess(
264 IDMap<ObjectType, IDMapOwnPointer>* map, int32 return_object_id) { 274 IDMap<ObjectType, IDMapOwnPointer>* map, int32 return_object_id) {
265 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 275 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
266 ObjectType* return_object = map->Lookup(return_object_id); 276 ObjectType* return_object = map->Lookup(return_object_id);
267 if (!return_object) { 277 if (!return_object) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 374 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
365 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); 375 &parent_->transaction_dispatcher_host_->map_, params.transaction_id);
366 if (!idb_database || !idb_transaction) 376 if (!idb_database || !idb_transaction)
367 return; 377 return;
368 378
369 *ec = 0; 379 *ec = 0;
370 WebIDBObjectStore* object_store = idb_database->createObjectStore( 380 WebIDBObjectStore* object_store = idb_database->createObjectStore(
371 params.name, params.key_path, params.auto_increment, 381 params.name, params.key_path, params.auto_increment,
372 *idb_transaction, *ec); 382 *idb_transaction, *ec);
373 *object_store_id = *ec ? 0 : parent_->Add(object_store); 383 *object_store_id = *ec ? 0 : parent_->Add(object_store);
384 if (parent_->Context()->IsOverQuota(
385 database_url_map_[params.idb_database_id])) {
386 idb_transaction->abort();
387 }
374 } 388 }
375 389
376 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( 390 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore(
377 int32 idb_database_id, 391 int32 idb_database_id,
378 const string16& name, 392 const string16& name,
379 int32 transaction_id, 393 int32 transaction_id,
380 WebKit::WebExceptionCode* ec) { 394 WebKit::WebExceptionCode* ec) {
381 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 395 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
382 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( 396 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess(
383 &map_, idb_database_id); 397 &map_, idb_database_id);
(...skipping 13 matching lines...) Expand all
397 WebKit::WebExceptionCode* ec) { 411 WebKit::WebExceptionCode* ec) {
398 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 412 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
399 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( 413 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess(
400 &map_, idb_database_id); 414 &map_, idb_database_id);
401 if (!idb_database) 415 if (!idb_database)
402 return; 416 return;
403 417
404 *ec = 0; 418 *ec = 0;
405 idb_database->setVersion( 419 idb_database->setVersion(
406 version, 420 version,
407 new IndexedDBCallbacks<WebIDBTransaction>(parent_, response_id), 421 new IndexedDBCallbacks<WebIDBTransaction>(parent_, response_id,
422 database_url_map_[idb_database_id]),
408 *ec); 423 *ec);
409 } 424 }
410 425
411 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnTransaction( 426 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnTransaction(
412 int32 idb_database_id, 427 int32 idb_database_id,
413 const std::vector<string16>& names, 428 const std::vector<string16>& names,
414 int32 mode, 429 int32 mode,
415 int32 timeout, 430 int32 timeout,
416 int32* idb_transaction_id, 431 int32* idb_transaction_id,
417 WebKit::WebExceptionCode* ec) { 432 WebKit::WebExceptionCode* ec) {
418 WebIDBDatabase* database = parent_->GetOrTerminateProcess( 433 WebIDBDatabase* database = parent_->GetOrTerminateProcess(
419 &map_, idb_database_id); 434 &map_, idb_database_id);
420 if (!database) 435 if (!database)
421 return; 436 return;
422 437
423 WebDOMStringList object_stores; 438 WebDOMStringList object_stores;
424 for (std::vector<string16>::const_iterator it = names.begin(); 439 for (std::vector<string16>::const_iterator it = names.begin();
425 it != names.end(); ++it) { 440 it != names.end(); ++it) {
426 object_stores.append(*it); 441 object_stores.append(*it);
427 } 442 }
428 443
429 *ec = 0; 444 *ec = 0;
430 WebIDBTransaction* transaction = database->transaction( 445 WebIDBTransaction* transaction = database->transaction(
431 object_stores, mode, timeout, *ec); 446 object_stores, mode, timeout, *ec);
432 DCHECK(!transaction != !*ec); 447 DCHECK(!transaction != !*ec);
433 *idb_transaction_id = *ec ? 0 : parent_->Add(transaction); 448 *idb_transaction_id =
449 *ec ? 0 : parent_->Add(transaction, database_url_map_[idb_database_id]);
434 } 450 }
435 451
436 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpen( 452 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpen(
437 int32 idb_database_id, int32 response_id) { 453 int32 idb_database_id, int32 response_id) {
438 WebIDBDatabase* database = parent_->GetOrTerminateProcess( 454 WebIDBDatabase* database = parent_->GetOrTerminateProcess(
439 &map_, idb_database_id); 455 &map_, idb_database_id);
440 database->open(new IndexedDBDatabaseCallbacks(parent_, response_id)); 456 database->open(new IndexedDBDatabaseCallbacks(parent_, response_id));
441 } 457 }
442 458
443 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose( 459 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose(
444 int32 idb_database_id) { 460 int32 idb_database_id) {
445 WebIDBDatabase* database = parent_->GetOrTerminateProcess( 461 WebIDBDatabase* database = parent_->GetOrTerminateProcess(
446 &map_, idb_database_id); 462 &map_, idb_database_id);
447 database->close(); 463 database->close();
448 parent_->Context()->quota_manager_proxy()->NotifyStorageAccessed( 464 const GURL origin_url = database_url_map_[idb_database_id];
449 quota::QuotaClient::kIndexedDatabase, url_map_[idb_database_id], 465 parent_->Context()->ConnectionClosed(origin_url);
450 quota::kStorageTypeTemporary);
451 url_map_.erase(idb_database_id);
452 } 466 }
453 467
454 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( 468 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed(
455 int32 object_id) { 469 int32 object_id) {
470 database_url_map_.erase(object_id);
456 parent_->DestroyObject(&map_, object_id); 471 parent_->DestroyObject(&map_, object_id);
457 } 472 }
458 473
459 474
460 ////////////////////////////////////////////////////////////////////// 475 //////////////////////////////////////////////////////////////////////
461 // IndexedDBDispatcherHost::IndexDispatcherHost 476 // IndexedDBDispatcherHost::IndexDispatcherHost
462 // 477 //
463 478
464 IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost( 479 IndexedDBDispatcherHost::IndexDispatcherHost::IndexDispatcherHost(
465 IndexedDBDispatcherHost* parent) 480 IndexedDBDispatcherHost* parent)
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 712 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
698 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); 713 &parent_->transaction_dispatcher_host_->map_, params.transaction_id);
699 if (!idb_transaction || !idb_object_store) 714 if (!idb_transaction || !idb_object_store)
700 return; 715 return;
701 716
702 *ec = 0; 717 *ec = 0;
703 scoped_ptr<WebIDBCallbacks> callbacks( 718 scoped_ptr<WebIDBCallbacks> callbacks(
704 new IndexedDBCallbacks<WebIDBKey>(parent_, params.response_id)); 719 new IndexedDBCallbacks<WebIDBKey>(parent_, params.response_id));
705 idb_object_store->put(params.serialized_value, params.key, params.put_mode, 720 idb_object_store->put(params.serialized_value, params.key, params.put_mode,
706 callbacks.release(), *idb_transaction, *ec); 721 callbacks.release(), *idb_transaction, *ec);
722 if (*ec)
723 return;
724 int64 size = UTF16ToUTF8(params.serialized_value.data()).size();
725 WebIDBTransactionIDToSizeMap* map =
726 &parent_->transaction_dispatcher_host_->transaction_size_map_;
727 (*map)[params.transaction_id] += size;
707 } 728 }
708 729
709 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete( 730 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete(
710 int idb_object_store_id, 731 int idb_object_store_id,
711 int32 response_id, 732 int32 response_id,
712 const IndexedDBKey& key, 733 const IndexedDBKey& key,
713 int32 transaction_id, 734 int32 transaction_id,
714 WebKit::WebExceptionCode* ec) { 735 WebKit::WebExceptionCode* ec) {
715 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 736 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
716 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( 737 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 &map_, params.idb_object_store_id); 775 &map_, params.idb_object_store_id);
755 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 776 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
756 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); 777 &parent_->transaction_dispatcher_host_->map_, params.transaction_id);
757 if (!idb_object_store || !idb_transaction) 778 if (!idb_object_store || !idb_transaction)
758 return; 779 return;
759 780
760 *ec = 0; 781 *ec = 0;
761 WebIDBIndex* index = idb_object_store->createIndex( 782 WebIDBIndex* index = idb_object_store->createIndex(
762 params.name, params.key_path, params.unique, *idb_transaction, *ec); 783 params.name, params.key_path, params.unique, *idb_transaction, *ec);
763 *index_id = *ec ? 0 : parent_->Add(index); 784 *index_id = *ec ? 0 : parent_->Add(index);
785 WebIDBObjectIDToURLMap* transaction_url_map =
786 &parent_->transaction_dispatcher_host_->transaction_url_map_;
787 if (parent_->Context()->IsOverQuota(
788 (*transaction_url_map)[params.transaction_id])) {
789 idb_transaction->abort();
790 }
764 } 791 }
765 792
766 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndex( 793 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndex(
767 int32 idb_object_store_id, 794 int32 idb_object_store_id,
768 const string16& name, 795 const string16& name,
769 int32* idb_index_id, 796 int32* idb_index_id,
770 WebKit::WebExceptionCode* ec) { 797 WebKit::WebExceptionCode* ec) {
771 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( 798 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess(
772 &map_, idb_object_store_id); 799 &map_, idb_object_store_id);
773 if (!idb_object_store) 800 if (!idb_object_store)
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 } 1053 }
1027 1054
1028 void IndexedDBDispatcherHost:: 1055 void IndexedDBDispatcherHost::
1029 TransactionDispatcherHost::OnDidCompleteTaskEvents(int transaction_id) { 1056 TransactionDispatcherHost::OnDidCompleteTaskEvents(int transaction_id) {
1030 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 1057 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
1031 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 1058 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
1032 &map_, transaction_id); 1059 &map_, transaction_id);
1033 if (!idb_transaction) 1060 if (!idb_transaction)
1034 return; 1061 return;
1035 1062
1063 // TODO(dgrogan): Tell the page the transaction aborted because of quota.
1064 if (parent_->Context()->WouldBeOverQuota(
1065 transaction_url_map_[transaction_id],
1066 transaction_size_map_[transaction_id])) {
1067 idb_transaction->abort();
1068 return;
1069 }
1036 idb_transaction->didCompleteTaskEvents(); 1070 idb_transaction->didCompleteTaskEvents();
1037 } 1071 }
1038 1072
1039 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( 1073 void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed(
1040 int32 object_id) { 1074 int32 object_id) {
1075 transaction_size_map_.erase(object_id);
1076 transaction_url_map_.erase(object_id);
1041 parent_->DestroyObject(&map_, object_id); 1077 parent_->DestroyObject(&map_, object_id);
1042 } 1078 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698