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

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: add TODO about opening database when over quota 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 ResetDispatcherHosts(); 89 ResetDispatcherHosts();
91 } 90 }
92 91
93 void IndexedDBDispatcherHost::ResetDispatcherHosts() { 92 void IndexedDBDispatcherHost::ResetDispatcherHosts() {
94 // It is important that the various *_dispatcher_host_ members are reset 93 // It is important that the various *_dispatcher_host_ members are reset
95 // on the WebKit thread, since there might be incoming messages on that 94 // on the WebKit thread, since there might be incoming messages on that
96 // thread, and we must not reset the dispatcher hosts until after those 95 // thread, and we must not reset the dispatcher hosts until after those
97 // messages are processed. 96 // messages are processed.
98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT) || 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT) ||
99 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)); 98 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess));
100 99
michaeln 2011/08/03 03:40:40 On a child process crash the call sequence will no
101 database_dispatcher_host_.reset(); 100 database_dispatcher_host_.reset();
102 index_dispatcher_host_.reset(); 101 index_dispatcher_host_.reset();
103 object_store_dispatcher_host_.reset(); 102 object_store_dispatcher_host_.reset();
104 cursor_dispatcher_host_.reset(); 103 cursor_dispatcher_host_.reset();
105 transaction_dispatcher_host_.reset(); 104 transaction_dispatcher_host_.reset();
106 } 105 }
107 106
108 void IndexedDBDispatcherHost::OverrideThreadForMessage( 107 void IndexedDBDispatcherHost::OverrideThreadForMessage(
109 const IPC::Message& message, 108 const IPC::Message& message,
110 BrowserThread::ID* thread) { 109 BrowserThread::ID* thread) {
(...skipping 37 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()->NewConnection(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.
204 WebSecurityOrigin origin( 207 WebSecurityOrigin origin(
205 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin)); 208 WebSecurityOrigin::createFromDatabaseIdentifier(params.origin));
206 GURL origin_url(origin.toString()); 209 GURL origin_url(origin.toString());
207 210
208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
209 DCHECK(kDefaultQuota == params.maximum_size); 212 DCHECK(kDefaultQuota == params.maximum_size);
210 213
211 uint64 quota = kDefaultQuota; 214 uint64 quota = kDefaultQuota;
michaeln 2011/08/03 03:40:40 Is this old quota code needed anymore? Is the valu
dgrogan 2011/08/04 19:47:50 Not by default, only if --indexeddb-use-sqlite is
212 if (Context()->IsUnlimitedStorageGranted(origin_url) || 215 if (Context()->IsUnlimitedStorageGranted(origin_url) ||
213 CommandLine::ForCurrentProcess()->HasSwitch( 216 CommandLine::ForCurrentProcess()->HasSwitch(
214 switches::kUnlimitedQuotaForIndexedDB)) { 217 switches::kUnlimitedQuotaForIndexedDB)) {
215 // TODO(jorlow): For the IsUnlimitedStorageGranted case, we need some 218 // TODO(jorlow): For the IsUnlimitedStorageGranted case, we need some
216 // way to revoke it. 219 // way to revoke it.
217 // TODO(jorlow): Use kint64max once we think we can scale over 1GB. 220 // TODO(jorlow): Use kint64max once we think we can scale over 1GB.
218 quota = 1024 * 1024 * 1024; // 1GB. More or less "unlimited". 221 quota = 1024 * 1024 * 1024; // 1GB. More or less "unlimited".
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]);
michaeln 2011/08/03 03:40:40 where are transaction_url_map_ entries erased?
266 transaction_dispatcher_host_->transaction_size_map_.erase(transaction_id);
michaeln 2011/08/03 03:40:40 maybe let TransactionDispatcherHost::OnDestroyed t
267 }
268
258 ////////////////////////////////////////////////////////////////////// 269 //////////////////////////////////////////////////////////////////////
259 // Helper templates. 270 // Helper templates.
260 // 271 //
261 272
262 template <typename ObjectType> 273 template <typename ObjectType>
263 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess( 274 ObjectType* IndexedDBDispatcherHost::GetOrTerminateProcess(
264 IDMap<ObjectType, IDMapOwnPointer>* map, int32 return_object_id) { 275 IDMap<ObjectType, IDMapOwnPointer>* map, int32 return_object_id) {
265 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 276 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
266 ObjectType* return_object = map->Lookup(return_object_id); 277 ObjectType* return_object = map->Lookup(return_object_id);
267 if (!return_object) { 278 if (!return_object) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 375 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
365 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); 376 &parent_->transaction_dispatcher_host_->map_, params.transaction_id);
366 if (!idb_database || !idb_transaction) 377 if (!idb_database || !idb_transaction)
367 return; 378 return;
368 379
369 *ec = 0; 380 *ec = 0;
370 WebIDBObjectStore* object_store = idb_database->createObjectStore( 381 WebIDBObjectStore* object_store = idb_database->createObjectStore(
371 params.name, params.key_path, params.auto_increment, 382 params.name, params.key_path, params.auto_increment,
372 *idb_transaction, *ec); 383 *idb_transaction, *ec);
373 *object_store_id = *ec ? 0 : parent_->Add(object_store); 384 *object_store_id = *ec ? 0 : parent_->Add(object_store);
385 if (parent_->Context()->IsOverQuota(
michaeln 2011/08/03 03:40:40 Is there a WebExceptionCode that means 'quota erro
kinuko 2011/08/03 09:12:22 QUOTA_EXCEEDED_ERR (22)?
dgrogan 2011/08/03 21:45:47 Same comment as below about what's in the spec. I
386 database_url_map_[params.idb_database_id])) {
387 idb_transaction->abort();
388 }
374 } 389 }
375 390
376 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore( 391 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore(
377 int32 idb_database_id, 392 int32 idb_database_id,
378 const string16& name, 393 const string16& name,
379 int32 transaction_id, 394 int32 transaction_id,
380 WebKit::WebExceptionCode* ec) { 395 WebKit::WebExceptionCode* ec) {
381 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 396 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
382 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( 397 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess(
383 &map_, idb_database_id); 398 &map_, idb_database_id);
(...skipping 13 matching lines...) Expand all
397 WebKit::WebExceptionCode* ec) { 412 WebKit::WebExceptionCode* ec) {
398 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 413 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
399 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess( 414 WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess(
400 &map_, idb_database_id); 415 &map_, idb_database_id);
401 if (!idb_database) 416 if (!idb_database)
402 return; 417 return;
403 418
404 *ec = 0; 419 *ec = 0;
405 idb_database->setVersion( 420 idb_database->setVersion(
406 version, 421 version,
407 new IndexedDBCallbacks<WebIDBTransaction>(parent_, response_id), 422 new IndexedDBCallbacks<WebIDBTransaction>(parent_, response_id,
423 database_url_map_[idb_database_id]),
408 *ec); 424 *ec);
409 } 425 }
410 426
411 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnTransaction( 427 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnTransaction(
412 int32 idb_database_id, 428 int32 idb_database_id,
413 const std::vector<string16>& names, 429 const std::vector<string16>& names,
414 int32 mode, 430 int32 mode,
415 int32 timeout, 431 int32 timeout,
416 int32* idb_transaction_id, 432 int32* idb_transaction_id,
417 WebKit::WebExceptionCode* ec) { 433 WebKit::WebExceptionCode* ec) {
418 WebIDBDatabase* database = parent_->GetOrTerminateProcess( 434 WebIDBDatabase* database = parent_->GetOrTerminateProcess(
419 &map_, idb_database_id); 435 &map_, idb_database_id);
420 if (!database) 436 if (!database)
421 return; 437 return;
422 438
423 WebDOMStringList object_stores; 439 WebDOMStringList object_stores;
424 for (std::vector<string16>::const_iterator it = names.begin(); 440 for (std::vector<string16>::const_iterator it = names.begin();
425 it != names.end(); ++it) { 441 it != names.end(); ++it) {
426 object_stores.append(*it); 442 object_stores.append(*it);
427 } 443 }
428 444
429 *ec = 0; 445 *ec = 0;
430 WebIDBTransaction* transaction = database->transaction( 446 WebIDBTransaction* transaction = database->transaction(
431 object_stores, mode, timeout, *ec); 447 object_stores, mode, timeout, *ec);
432 DCHECK(!transaction != !*ec); 448 DCHECK(!transaction != !*ec);
michaeln 2011/08/03 03:40:40 unrelated: curious DCHECK :)
433 *idb_transaction_id = *ec ? 0 : parent_->Add(transaction); 449 *idb_transaction_id =
450 *ec ? 0 : parent_->Add(transaction, database_url_map_[idb_database_id]);
434 } 451 }
435 452
436 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpen( 453 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnOpen(
437 int32 idb_database_id, int32 response_id) { 454 int32 idb_database_id, int32 response_id) {
438 WebIDBDatabase* database = parent_->GetOrTerminateProcess( 455 WebIDBDatabase* database = parent_->GetOrTerminateProcess(
439 &map_, idb_database_id); 456 &map_, idb_database_id);
440 database->open(new IndexedDBDatabaseCallbacks(parent_, response_id)); 457 database->open(new IndexedDBDatabaseCallbacks(parent_, response_id));
441 } 458 }
442 459
443 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose( 460 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClose(
444 int32 idb_database_id) { 461 int32 idb_database_id) {
445 WebIDBDatabase* database = parent_->GetOrTerminateProcess( 462 WebIDBDatabase* database = parent_->GetOrTerminateProcess(
446 &map_, idb_database_id); 463 &map_, idb_database_id);
447 database->close(); 464 database->close();
448 parent_->Context()->quota_manager_proxy()->NotifyStorageAccessed( 465 const GURL origin_url = database_url_map_[idb_database_id];
449 quota::QuotaClient::kIndexedDatabase, url_map_[idb_database_id], 466 database_url_map_.erase(idb_database_id);
450 quota::kStorageTypeTemporary); 467 parent_->Context()->ConnectionClosed(origin_url);
michaeln 2011/08/03 03:40:40 Is OnClose called in all cases or can this method
dgrogan 2011/08/04 23:44:55 Yes it would. Moved.
michaeln 2011/08/05 01:21:47 Any reason not to move the ConnectionClosed() call
dgrogan 2011/08/05 03:06:58 Moved. Though I'm not sure that OnDestroyed is mo
451 url_map_.erase(idb_database_id);
452 } 468 }
453 469
454 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( 470 void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed(
455 int32 object_id) { 471 int32 object_id) {
456 parent_->DestroyObject(&map_, object_id); 472 parent_->DestroyObject(&map_, object_id);
457 } 473 }
458 474
459 475
460 ////////////////////////////////////////////////////////////////////// 476 //////////////////////////////////////////////////////////////////////
461 // IndexedDBDispatcherHost::IndexDispatcherHost 477 // IndexedDBDispatcherHost::IndexDispatcherHost
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 713 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
698 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); 714 &parent_->transaction_dispatcher_host_->map_, params.transaction_id);
699 if (!idb_transaction || !idb_object_store) 715 if (!idb_transaction || !idb_object_store)
700 return; 716 return;
701 717
702 *ec = 0; 718 *ec = 0;
703 scoped_ptr<WebIDBCallbacks> callbacks( 719 scoped_ptr<WebIDBCallbacks> callbacks(
704 new IndexedDBCallbacks<WebIDBKey>(parent_, params.response_id)); 720 new IndexedDBCallbacks<WebIDBKey>(parent_, params.response_id));
705 idb_object_store->put(params.serialized_value, params.key, params.put_mode, 721 idb_object_store->put(params.serialized_value, params.key, params.put_mode,
706 callbacks.release(), *idb_transaction, *ec); 722 callbacks.release(), *idb_transaction, *ec);
723 if (*ec)
724 return;
725 int64 size = UTF16ToUTF8(params.serialized_value.data()).size();
726 WebIDBTransactionIDToSizeMap* map =
727 &parent_->transaction_dispatcher_host_->transaction_size_map_;
728 (*map)[params.transaction_id] += size;
707 } 729 }
708 730
709 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete( 731 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnDelete(
710 int idb_object_store_id, 732 int idb_object_store_id,
711 int32 response_id, 733 int32 response_id,
712 const IndexedDBKey& key, 734 const IndexedDBKey& key,
713 int32 transaction_id, 735 int32 transaction_id,
714 WebKit::WebExceptionCode* ec) { 736 WebKit::WebExceptionCode* ec) {
715 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 737 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
716 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( 738 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); 776 &map_, params.idb_object_store_id);
755 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 777 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
756 &parent_->transaction_dispatcher_host_->map_, params.transaction_id); 778 &parent_->transaction_dispatcher_host_->map_, params.transaction_id);
757 if (!idb_object_store || !idb_transaction) 779 if (!idb_object_store || !idb_transaction)
758 return; 780 return;
759 781
760 *ec = 0; 782 *ec = 0;
761 WebIDBIndex* index = idb_object_store->createIndex( 783 WebIDBIndex* index = idb_object_store->createIndex(
762 params.name, params.key_path, params.unique, *idb_transaction, *ec); 784 params.name, params.key_path, params.unique, *idb_transaction, *ec);
763 *index_id = *ec ? 0 : parent_->Add(index); 785 *index_id = *ec ? 0 : parent_->Add(index);
786 WebIDBObjectIDToURLMap* transaction_url_map =
dgrogan 2011/08/03 01:41:29 Getting a handle to this variable is just for read
787 &parent_->transaction_dispatcher_host_->transaction_url_map_;
788 if (parent_->Context()->IsOverQuota(
michaeln 2011/08/03 03:40:40 Is there a WebExceptionCode that means 'quota erro
dgrogan 2011/08/03 21:45:47 I did it this way because of the following text fr
789 (*transaction_url_map)[params.transaction_id])) {
790 idb_transaction->abort();
791 }
764 } 792 }
765 793
766 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndex( 794 void IndexedDBDispatcherHost::ObjectStoreDispatcherHost::OnIndex(
767 int32 idb_object_store_id, 795 int32 idb_object_store_id,
768 const string16& name, 796 const string16& name,
769 int32* idb_index_id, 797 int32* idb_index_id,
770 WebKit::WebExceptionCode* ec) { 798 WebKit::WebExceptionCode* ec) {
771 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess( 799 WebIDBObjectStore* idb_object_store = parent_->GetOrTerminateProcess(
772 &map_, idb_object_store_id); 800 &map_, idb_object_store_id);
773 if (!idb_object_store) 801 if (!idb_object_store)
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 &map_, transaction_id); 1047 &map_, transaction_id);
1020 if (!idb_transaction) 1048 if (!idb_transaction)
1021 return; 1049 return;
1022 1050
1023 *ec = 0; 1051 *ec = 0;
1024 WebIDBObjectStore* object_store = idb_transaction->objectStore(name, *ec); 1052 WebIDBObjectStore* object_store = idb_transaction->objectStore(name, *ec);
1025 *object_store_id = object_store ? parent_->Add(object_store) : 0; 1053 *object_store_id = object_store ? parent_->Add(object_store) : 0;
1026 } 1054 }
1027 1055
1028 void IndexedDBDispatcherHost:: 1056 void IndexedDBDispatcherHost::
1029 TransactionDispatcherHost::OnDidCompleteTaskEvents(int transaction_id) { 1057 TransactionDispatcherHost::OnDidCompleteTaskEvents(int transaction_id) {
michaeln 2011/08/03 03:40:40 I'm not familiar with these methods or the sequenc
dgrogan 2011/08/04 23:44:55 This is called after the success event of each ope
michaeln 2011/08/05 01:21:47 Thnx for the explanation. Sounds like it makes for
1030 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); 1058 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
1031 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( 1059 WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess(
1032 &map_, transaction_id); 1060 &map_, transaction_id);
1033 if (!idb_transaction) 1061 if (!idb_transaction)
1034 return; 1062 return;
1035 1063
1064 if (parent_->Context()->WouldBeOverQuota(
1065 transaction_url_map_[transaction_id],
1066 transaction_size_map_[transaction_id])) {
1067 idb_transaction->abort();
michaeln 2011/08/03 03:40:40 When trans->abort() is called, what does applicati
dgrogan 2011/08/03 21:45:47 I don't think so. This was bothering me as well,
michaeln 2011/08/04 00:23:27 Probably worthy of a TODO? We definitely want to i
dgrogan 2011/08/04 19:47:50 Done.
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) {
1041 parent_->DestroyObject(&map_, object_id); 1075 parent_->DestroyObject(&map_, object_id);
michaeln 2011/08/03 03:40:40 would this be a good place to erase from the trans
1042 } 1076 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698