OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/indexed_db/indexed_db_database_impl.h" | 5 #include "content/browser/indexed_db/indexed_db_database.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "content/browser/indexed_db/indexed_db_backing_store.h" | 15 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
16 #include "content/browser/indexed_db/indexed_db_cursor_impl.h" | 16 #include "content/browser/indexed_db/indexed_db_cursor.h" |
17 #include "content/browser/indexed_db/indexed_db_factory_impl.h" | 17 #include "content/browser/indexed_db/indexed_db_factory.h" |
18 #include "content/browser/indexed_db/indexed_db_index_writer.h" | 18 #include "content/browser/indexed_db/indexed_db_index_writer.h" |
19 #include "content/browser/indexed_db/indexed_db_tracing.h" | 19 #include "content/browser/indexed_db/indexed_db_tracing.h" |
20 #include "content/browser/indexed_db/indexed_db_transaction.h" | 20 #include "content/browser/indexed_db/indexed_db_transaction.h" |
21 #include "content/common/indexed_db/indexed_db_key_path.h" | 21 #include "content/common/indexed_db/indexed_db_key_path.h" |
22 #include "content/common/indexed_db/indexed_db_key_range.h" | 22 #include "content/common/indexed_db/indexed_db_key_range.h" |
23 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" | 23 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" |
24 | 24 |
25 using base::Int64ToString16; | 25 using base::Int64ToString16; |
26 using WebKit::WebIDBKey; | 26 using WebKit::WebIDBKey; |
27 | 27 |
(...skipping 20 matching lines...) Expand all Loading... |
48 const IndexedDBObjectStoreMetadata& object_store_metadata) | 48 const IndexedDBObjectStoreMetadata& object_store_metadata) |
49 : backing_store_(backing_store), | 49 : backing_store_(backing_store), |
50 object_store_metadata_(object_store_metadata) {} | 50 object_store_metadata_(object_store_metadata) {} |
51 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 51 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
52 | 52 |
53 private: | 53 private: |
54 const scoped_refptr<IndexedDBBackingStore> backing_store_; | 54 const scoped_refptr<IndexedDBBackingStore> backing_store_; |
55 const IndexedDBObjectStoreMetadata object_store_metadata_; | 55 const IndexedDBObjectStoreMetadata object_store_metadata_; |
56 }; | 56 }; |
57 | 57 |
58 class IndexedDBDatabaseImpl::VersionChangeOperation | 58 class IndexedDBDatabase::VersionChangeOperation |
59 : public IndexedDBTransaction::Operation { | 59 : public IndexedDBTransaction::Operation { |
60 public: | 60 public: |
61 VersionChangeOperation( | 61 VersionChangeOperation( |
62 scoped_refptr<IndexedDBDatabaseImpl> database, | 62 scoped_refptr<IndexedDBDatabase> database, |
63 int64 transaction_id, | 63 int64 transaction_id, |
64 int64 version, | 64 int64 version, |
65 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 65 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, |
66 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks) | 66 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks) |
67 : database_(database), | 67 : database_(database), |
68 transaction_id_(transaction_id), | 68 transaction_id_(transaction_id), |
69 version_(version), | 69 version_(version), |
70 callbacks_(callbacks), | 70 callbacks_(callbacks), |
71 database_callbacks_(database_callbacks) {} | 71 database_callbacks_(database_callbacks) {} |
72 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 72 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
73 | 73 |
74 private: | 74 private: |
75 scoped_refptr<IndexedDBDatabaseImpl> database_; | 75 scoped_refptr<IndexedDBDatabase> database_; |
76 int64 transaction_id_; | 76 int64 transaction_id_; |
77 int64 version_; | 77 int64 version_; |
78 scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; | 78 scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; |
79 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks_; | 79 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks_; |
80 }; | 80 }; |
81 | 81 |
82 class CreateObjectStoreAbortOperation : public IndexedDBTransaction::Operation { | 82 class CreateObjectStoreAbortOperation : public IndexedDBTransaction::Operation { |
83 public: | 83 public: |
84 CreateObjectStoreAbortOperation(scoped_refptr<IndexedDBDatabaseImpl> database, | 84 CreateObjectStoreAbortOperation(scoped_refptr<IndexedDBDatabase> database, |
85 int64 object_store_id) | 85 int64 object_store_id) |
86 : database_(database), object_store_id_(object_store_id) {} | 86 : database_(database), object_store_id_(object_store_id) {} |
87 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 87 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
88 | 88 |
89 private: | 89 private: |
90 const scoped_refptr<IndexedDBDatabaseImpl> database_; | 90 const scoped_refptr<IndexedDBDatabase> database_; |
91 const int64 object_store_id_; | 91 const int64 object_store_id_; |
92 }; | 92 }; |
93 | 93 |
94 class DeleteObjectStoreAbortOperation : public IndexedDBTransaction::Operation { | 94 class DeleteObjectStoreAbortOperation : public IndexedDBTransaction::Operation { |
95 public: | 95 public: |
96 DeleteObjectStoreAbortOperation( | 96 DeleteObjectStoreAbortOperation( |
97 scoped_refptr<IndexedDBDatabaseImpl> database, | 97 scoped_refptr<IndexedDBDatabase> database, |
98 const IndexedDBObjectStoreMetadata& object_store_metadata) | 98 const IndexedDBObjectStoreMetadata& object_store_metadata) |
99 : database_(database), object_store_metadata_(object_store_metadata) {} | 99 : database_(database), object_store_metadata_(object_store_metadata) {} |
100 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 100 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
101 | 101 |
102 private: | 102 private: |
103 scoped_refptr<IndexedDBDatabaseImpl> database_; | 103 scoped_refptr<IndexedDBDatabase> database_; |
104 IndexedDBObjectStoreMetadata object_store_metadata_; | 104 IndexedDBObjectStoreMetadata object_store_metadata_; |
105 }; | 105 }; |
106 | 106 |
107 class IndexedDBDatabaseImpl::VersionChangeAbortOperation | 107 class IndexedDBDatabase::VersionChangeAbortOperation |
108 : public IndexedDBTransaction::Operation { | 108 : public IndexedDBTransaction::Operation { |
109 public: | 109 public: |
110 VersionChangeAbortOperation(scoped_refptr<IndexedDBDatabaseImpl> database, | 110 VersionChangeAbortOperation(scoped_refptr<IndexedDBDatabase> database, |
111 const string16& previous_version, | 111 const string16& previous_version, |
112 int64 previous_int_version) | 112 int64 previous_int_version) |
113 : database_(database), | 113 : database_(database), |
114 previous_version_(previous_version), | 114 previous_version_(previous_version), |
115 previous_int_version_(previous_int_version) {} | 115 previous_int_version_(previous_int_version) {} |
116 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 116 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
117 | 117 |
118 private: | 118 private: |
119 scoped_refptr<IndexedDBDatabaseImpl> database_; | 119 scoped_refptr<IndexedDBDatabase> database_; |
120 string16 previous_version_; | 120 string16 previous_version_; |
121 int64 previous_int_version_; | 121 int64 previous_int_version_; |
122 }; | 122 }; |
123 | 123 |
124 class CreateIndexOperation : public IndexedDBTransaction::Operation { | 124 class CreateIndexOperation : public IndexedDBTransaction::Operation { |
125 public: | 125 public: |
126 CreateIndexOperation(scoped_refptr<IndexedDBBackingStore> backing_store, | 126 CreateIndexOperation(scoped_refptr<IndexedDBBackingStore> backing_store, |
127 int64 object_store_id, | 127 int64 object_store_id, |
128 const IndexedDBIndexMetadata& index_metadata) | 128 const IndexedDBIndexMetadata& index_metadata) |
129 : backing_store_(backing_store), | 129 : backing_store_(backing_store), |
(...skipping 18 matching lines...) Expand all Loading... |
148 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 148 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
149 | 149 |
150 private: | 150 private: |
151 const scoped_refptr<IndexedDBBackingStore> backing_store_; | 151 const scoped_refptr<IndexedDBBackingStore> backing_store_; |
152 const int64 object_store_id_; | 152 const int64 object_store_id_; |
153 const IndexedDBIndexMetadata index_metadata_; | 153 const IndexedDBIndexMetadata index_metadata_; |
154 }; | 154 }; |
155 | 155 |
156 class CreateIndexAbortOperation : public IndexedDBTransaction::Operation { | 156 class CreateIndexAbortOperation : public IndexedDBTransaction::Operation { |
157 public: | 157 public: |
158 CreateIndexAbortOperation(scoped_refptr<IndexedDBDatabaseImpl> database, | 158 CreateIndexAbortOperation(scoped_refptr<IndexedDBDatabase> database, |
159 int64 object_store_id, | 159 int64 object_store_id, |
160 int64 index_id) | 160 int64 index_id) |
161 : database_(database), | 161 : database_(database), |
162 object_store_id_(object_store_id), | 162 object_store_id_(object_store_id), |
163 index_id_(index_id) {} | 163 index_id_(index_id) {} |
164 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 164 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
165 | 165 |
166 private: | 166 private: |
167 const scoped_refptr<IndexedDBDatabaseImpl> database_; | 167 const scoped_refptr<IndexedDBDatabase> database_; |
168 const int64 object_store_id_; | 168 const int64 object_store_id_; |
169 const int64 index_id_; | 169 const int64 index_id_; |
170 }; | 170 }; |
171 | 171 |
172 class DeleteIndexAbortOperation : public IndexedDBTransaction::Operation { | 172 class DeleteIndexAbortOperation : public IndexedDBTransaction::Operation { |
173 public: | 173 public: |
174 DeleteIndexAbortOperation(scoped_refptr<IndexedDBDatabaseImpl> database, | 174 DeleteIndexAbortOperation(scoped_refptr<IndexedDBDatabase> database, |
175 int64 object_store_id, | 175 int64 object_store_id, |
176 const IndexedDBIndexMetadata& index_metadata) | 176 const IndexedDBIndexMetadata& index_metadata) |
177 : database_(database), | 177 : database_(database), |
178 object_store_id_(object_store_id), | 178 object_store_id_(object_store_id), |
179 index_metadata_(index_metadata) {} | 179 index_metadata_(index_metadata) {} |
180 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 180 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
181 | 181 |
182 private: | 182 private: |
183 const scoped_refptr<IndexedDBDatabaseImpl> database_; | 183 const scoped_refptr<IndexedDBDatabase> database_; |
184 const int64 object_store_id_; | 184 const int64 object_store_id_; |
185 const IndexedDBIndexMetadata index_metadata_; | 185 const IndexedDBIndexMetadata index_metadata_; |
186 }; | 186 }; |
187 | 187 |
188 class GetOperation : public IndexedDBTransaction::Operation { | 188 class GetOperation : public IndexedDBTransaction::Operation { |
189 public: | 189 public: |
190 GetOperation(scoped_refptr<IndexedDBBackingStore> backing_store, | 190 GetOperation(scoped_refptr<IndexedDBBackingStore> backing_store, |
191 const IndexedDBDatabaseMetadata& metadata, | 191 const IndexedDBDatabaseMetadata& metadata, |
192 int64 object_store_id, | 192 int64 object_store_id, |
193 int64 index_id, | 193 int64 index_id, |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 callbacks_(callbacks) {} | 362 callbacks_(callbacks) {} |
363 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; | 363 virtual void Perform(IndexedDBTransaction* transaction) OVERRIDE; |
364 | 364 |
365 private: | 365 private: |
366 const scoped_refptr<IndexedDBBackingStore> backing_store_; | 366 const scoped_refptr<IndexedDBBackingStore> backing_store_; |
367 const int64 database_id_; | 367 const int64 database_id_; |
368 const int64 object_store_id_; | 368 const int64 object_store_id_; |
369 const scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; | 369 const scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; |
370 }; | 370 }; |
371 | 371 |
372 class IndexedDBDatabaseImpl::PendingOpenCall { | 372 class IndexedDBDatabase::PendingOpenCall { |
373 public: | 373 public: |
374 PendingOpenCall( | 374 PendingOpenCall( |
375 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 375 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, |
376 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks, | 376 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks, |
377 int64 transaction_id, | 377 int64 transaction_id, |
378 int64 version) | 378 int64 version) |
379 : callbacks_(callbacks), | 379 : callbacks_(callbacks), |
380 database_callbacks_(database_callbacks), | 380 database_callbacks_(database_callbacks), |
381 version_(version), | 381 version_(version), |
382 transaction_id_(transaction_id) {} | 382 transaction_id_(transaction_id) {} |
383 scoped_refptr<IndexedDBCallbacksWrapper> Callbacks() { return callbacks_; } | 383 scoped_refptr<IndexedDBCallbacksWrapper> Callbacks() { return callbacks_; } |
384 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> DatabaseCallbacks() { | 384 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> DatabaseCallbacks() { |
385 return database_callbacks_; | 385 return database_callbacks_; |
386 } | 386 } |
387 int64 Version() { return version_; } | 387 int64 Version() { return version_; } |
388 int64 TransactionId() const { return transaction_id_; } | 388 int64 TransactionId() const { return transaction_id_; } |
389 | 389 |
390 private: | 390 private: |
391 scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; | 391 scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; |
392 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks_; | 392 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks_; |
393 int64 version_; | 393 int64 version_; |
394 const int64 transaction_id_; | 394 const int64 transaction_id_; |
395 }; | 395 }; |
396 | 396 |
397 class IndexedDBDatabaseImpl::PendingDeleteCall { | 397 class IndexedDBDatabase::PendingDeleteCall { |
398 public: | 398 public: |
399 explicit PendingDeleteCall(scoped_refptr<IndexedDBCallbacksWrapper> callbacks) | 399 explicit PendingDeleteCall(scoped_refptr<IndexedDBCallbacksWrapper> callbacks) |
400 : callbacks_(callbacks) {} | 400 : callbacks_(callbacks) {} |
401 scoped_refptr<IndexedDBCallbacksWrapper> Callbacks() { return callbacks_; } | 401 scoped_refptr<IndexedDBCallbacksWrapper> Callbacks() { return callbacks_; } |
402 | 402 |
403 private: | 403 private: |
404 scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; | 404 scoped_refptr<IndexedDBCallbacksWrapper> callbacks_; |
405 }; | 405 }; |
406 | 406 |
407 scoped_refptr<IndexedDBDatabaseImpl> IndexedDBDatabaseImpl::Create( | 407 scoped_refptr<IndexedDBDatabase> IndexedDBDatabase::Create( |
408 const string16& name, | 408 const string16& name, |
409 IndexedDBBackingStore* database, | 409 IndexedDBBackingStore* database, |
410 IndexedDBFactoryImpl* factory, | 410 IndexedDBFactory* factory, |
411 const string16& unique_identifier) { | 411 const string16& unique_identifier) { |
412 scoped_refptr<IndexedDBDatabaseImpl> backend = | 412 scoped_refptr<IndexedDBDatabase> backend = |
413 new IndexedDBDatabaseImpl(name, database, factory, unique_identifier); | 413 new IndexedDBDatabase(name, database, factory, unique_identifier); |
414 if (!backend->OpenInternal()) | 414 if (!backend->OpenInternal()) |
415 return 0; | 415 return 0; |
416 return backend; | 416 return backend; |
417 } | 417 } |
418 | 418 |
419 namespace { | 419 namespace { |
420 const base::string16::value_type kNoStringVersion[] = {0}; | 420 const base::string16::value_type kNoStringVersion[] = {0}; |
421 } | 421 } |
422 | 422 |
423 IndexedDBDatabaseImpl::IndexedDBDatabaseImpl( | 423 IndexedDBDatabase::IndexedDBDatabase(const string16& name, |
424 const string16& name, | 424 IndexedDBBackingStore* backing_store, |
425 IndexedDBBackingStore* backing_store, | 425 IndexedDBFactory* factory, |
426 IndexedDBFactoryImpl* factory, | 426 const string16& unique_identifier) |
427 const string16& unique_identifier) | |
428 : backing_store_(backing_store), | 427 : backing_store_(backing_store), |
429 metadata_(name, | 428 metadata_(name, |
430 kInvalidId, | 429 kInvalidId, |
431 kNoStringVersion, | 430 kNoStringVersion, |
432 IndexedDBDatabaseMetadata::NO_INT_VERSION, | 431 IndexedDBDatabaseMetadata::NO_INT_VERSION, |
433 kInvalidId), | 432 kInvalidId), |
434 identifier_(unique_identifier), | 433 identifier_(unique_identifier), |
435 factory_(factory), | 434 factory_(factory), |
436 running_version_change_transaction_(NULL), | 435 running_version_change_transaction_(NULL), |
437 closing_connection_(false) { | 436 closing_connection_(false) { |
438 DCHECK(!metadata_.name.empty()); | 437 DCHECK(!metadata_.name.empty()); |
439 } | 438 } |
440 | 439 |
441 void IndexedDBDatabaseImpl::AddObjectStore( | 440 void IndexedDBDatabase::AddObjectStore( |
442 const IndexedDBObjectStoreMetadata& object_store, | 441 const IndexedDBObjectStoreMetadata& object_store, |
443 int64 new_max_object_store_id) { | 442 int64 new_max_object_store_id) { |
444 DCHECK(metadata_.object_stores.find(object_store.id) == | 443 DCHECK(metadata_.object_stores.find(object_store.id) == |
445 metadata_.object_stores.end()); | 444 metadata_.object_stores.end()); |
446 if (new_max_object_store_id != IndexedDBObjectStoreMetadata::kInvalidId) { | 445 if (new_max_object_store_id != IndexedDBObjectStoreMetadata::kInvalidId) { |
447 DCHECK_LT(metadata_.max_object_store_id, new_max_object_store_id); | 446 DCHECK_LT(metadata_.max_object_store_id, new_max_object_store_id); |
448 metadata_.max_object_store_id = new_max_object_store_id; | 447 metadata_.max_object_store_id = new_max_object_store_id; |
449 } | 448 } |
450 metadata_.object_stores[object_store.id] = object_store; | 449 metadata_.object_stores[object_store.id] = object_store; |
451 } | 450 } |
452 | 451 |
453 void IndexedDBDatabaseImpl::RemoveObjectStore(int64 object_store_id) { | 452 void IndexedDBDatabase::RemoveObjectStore(int64 object_store_id) { |
454 DCHECK(metadata_.object_stores.find(object_store_id) != | 453 DCHECK(metadata_.object_stores.find(object_store_id) != |
455 metadata_.object_stores.end()); | 454 metadata_.object_stores.end()); |
456 metadata_.object_stores.erase(object_store_id); | 455 metadata_.object_stores.erase(object_store_id); |
457 } | 456 } |
458 | 457 |
459 void IndexedDBDatabaseImpl::AddIndex(int64 object_store_id, | 458 void IndexedDBDatabase::AddIndex(int64 object_store_id, |
460 const IndexedDBIndexMetadata& index, | 459 const IndexedDBIndexMetadata& index, |
461 int64 new_max_index_id) { | 460 int64 new_max_index_id) { |
462 DCHECK(metadata_.object_stores.find(object_store_id) != | 461 DCHECK(metadata_.object_stores.find(object_store_id) != |
463 metadata_.object_stores.end()); | 462 metadata_.object_stores.end()); |
464 IndexedDBObjectStoreMetadata object_store = | 463 IndexedDBObjectStoreMetadata object_store = |
465 metadata_.object_stores[object_store_id]; | 464 metadata_.object_stores[object_store_id]; |
466 | 465 |
467 DCHECK(object_store.indexes.find(index.id) == object_store.indexes.end()); | 466 DCHECK(object_store.indexes.find(index.id) == object_store.indexes.end()); |
468 object_store.indexes[index.id] = index; | 467 object_store.indexes[index.id] = index; |
469 if (new_max_index_id != IndexedDBIndexMetadata::kInvalidId) { | 468 if (new_max_index_id != IndexedDBIndexMetadata::kInvalidId) { |
470 DCHECK_LT(object_store.max_index_id, new_max_index_id); | 469 DCHECK_LT(object_store.max_index_id, new_max_index_id); |
471 object_store.max_index_id = new_max_index_id; | 470 object_store.max_index_id = new_max_index_id; |
472 } | 471 } |
473 metadata_.object_stores[object_store_id] = object_store; | 472 metadata_.object_stores[object_store_id] = object_store; |
474 } | 473 } |
475 | 474 |
476 void IndexedDBDatabaseImpl::RemoveIndex(int64 object_store_id, int64 index_id) { | 475 void IndexedDBDatabase::RemoveIndex(int64 object_store_id, int64 index_id) { |
477 DCHECK(metadata_.object_stores.find(object_store_id) != | 476 DCHECK(metadata_.object_stores.find(object_store_id) != |
478 metadata_.object_stores.end()); | 477 metadata_.object_stores.end()); |
479 IndexedDBObjectStoreMetadata object_store = | 478 IndexedDBObjectStoreMetadata object_store = |
480 metadata_.object_stores[object_store_id]; | 479 metadata_.object_stores[object_store_id]; |
481 | 480 |
482 DCHECK(object_store.indexes.find(index_id) != object_store.indexes.end()); | 481 DCHECK(object_store.indexes.find(index_id) != object_store.indexes.end()); |
483 object_store.indexes.erase(index_id); | 482 object_store.indexes.erase(index_id); |
484 metadata_.object_stores[object_store_id] = object_store; | 483 metadata_.object_stores[object_store_id] = object_store; |
485 } | 484 } |
486 | 485 |
487 bool IndexedDBDatabaseImpl::OpenInternal() { | 486 bool IndexedDBDatabase::OpenInternal() { |
488 bool success = false; | 487 bool success = false; |
489 bool ok = backing_store_->GetIDBDatabaseMetaData( | 488 bool ok = backing_store_->GetIDBDatabaseMetaData( |
490 metadata_.name, &metadata_, &success); | 489 metadata_.name, &metadata_, &success); |
491 DCHECK(success == (metadata_.id != kInvalidId)) << "success = " << success | 490 DCHECK(success == (metadata_.id != kInvalidId)) << "success = " << success |
492 << " id_ = " << metadata_.id; | 491 << " id_ = " << metadata_.id; |
493 if (!ok) | 492 if (!ok) |
494 return false; | 493 return false; |
495 if (success) | 494 if (success) |
496 return backing_store_->GetObjectStores(metadata_.id, | 495 return backing_store_->GetObjectStores(metadata_.id, |
497 &metadata_.object_stores); | 496 &metadata_.object_stores); |
498 | 497 |
499 return backing_store_->CreateIDBDatabaseMetaData( | 498 return backing_store_->CreateIDBDatabaseMetaData( |
500 metadata_.name, metadata_.version, metadata_.int_version, &metadata_.id); | 499 metadata_.name, metadata_.version, metadata_.int_version, &metadata_.id); |
501 } | 500 } |
502 | 501 |
503 IndexedDBDatabaseImpl::~IndexedDBDatabaseImpl() { | 502 IndexedDBDatabase::~IndexedDBDatabase() { |
504 DCHECK(transactions_.empty()); | 503 DCHECK(transactions_.empty()); |
505 DCHECK(pending_open_calls_.empty()); | 504 DCHECK(pending_open_calls_.empty()); |
506 DCHECK(pending_delete_calls_.empty()); | 505 DCHECK(pending_delete_calls_.empty()); |
507 } | 506 } |
508 | 507 |
509 scoped_refptr<IndexedDBBackingStore> IndexedDBDatabaseImpl::BackingStore() | 508 scoped_refptr<IndexedDBBackingStore> IndexedDBDatabase::BackingStore() const { |
510 const { | |
511 return backing_store_; | 509 return backing_store_; |
512 } | 510 } |
513 | 511 |
514 void IndexedDBDatabaseImpl::CreateObjectStore(int64 transaction_id, | 512 void IndexedDBDatabase::CreateObjectStore(int64 transaction_id, |
515 int64 object_store_id, | 513 int64 object_store_id, |
516 const string16& name, | 514 const string16& name, |
517 const IndexedDBKeyPath& key_path, | 515 const IndexedDBKeyPath& key_path, |
518 bool auto_increment) { | 516 bool auto_increment) { |
519 IDB_TRACE("IndexedDBDatabaseImpl::create_object_store"); | 517 IDB_TRACE("IndexedDBDatabase::create_object_store"); |
520 TransactionMap::const_iterator trans_iterator = | 518 TransactionMap::const_iterator trans_iterator = |
521 transactions_.find(transaction_id); | 519 transactions_.find(transaction_id); |
522 if (trans_iterator == transactions_.end()) | 520 if (trans_iterator == transactions_.end()) |
523 return; | 521 return; |
524 IndexedDBTransaction* transaction = trans_iterator->second; | 522 IndexedDBTransaction* transaction = trans_iterator->second; |
525 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); | 523 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); |
526 | 524 |
527 DCHECK(metadata_.object_stores.find(object_store_id) == | 525 DCHECK(metadata_.object_stores.find(object_store_id) == |
528 metadata_.object_stores.end()); | 526 metadata_.object_stores.end()); |
529 IndexedDBObjectStoreMetadata object_store_metadata( | 527 IndexedDBObjectStoreMetadata object_store_metadata( |
(...skipping 15 matching lines...) Expand all Loading... |
545 if (!backing_store_->CreateObjectStore( | 543 if (!backing_store_->CreateObjectStore( |
546 transaction->BackingStoreTransaction(), | 544 transaction->BackingStoreTransaction(), |
547 transaction->database()->id(), | 545 transaction->database()->id(), |
548 object_store_metadata_.id, | 546 object_store_metadata_.id, |
549 object_store_metadata_.name, | 547 object_store_metadata_.name, |
550 object_store_metadata_.key_path, | 548 object_store_metadata_.key_path, |
551 object_store_metadata_.auto_increment)) { | 549 object_store_metadata_.auto_increment)) { |
552 transaction->Abort(IndexedDBDatabaseError( | 550 transaction->Abort(IndexedDBDatabaseError( |
553 WebKit::WebIDBDatabaseExceptionUnknownError, | 551 WebKit::WebIDBDatabaseExceptionUnknownError, |
554 ASCIIToUTF16("Internal error creating object store '") + | 552 ASCIIToUTF16("Internal error creating object store '") + |
555 object_store_metadata_.name + ASCIIToUTF16("'."))); | 553 object_store_metadata_.name + ASCIIToUTF16("'."))); |
556 return; | 554 return; |
557 } | 555 } |
558 } | 556 } |
559 | 557 |
560 void IndexedDBDatabaseImpl::DeleteObjectStore(int64 transaction_id, | 558 void IndexedDBDatabase::DeleteObjectStore(int64 transaction_id, |
561 int64 object_store_id) { | 559 int64 object_store_id) { |
562 IDB_TRACE("IndexedDBDatabaseImpl::delete_object_store"); | 560 IDB_TRACE("IndexedDBDatabase::delete_object_store"); |
563 TransactionMap::const_iterator trans_iterator = | 561 TransactionMap::const_iterator trans_iterator = |
564 transactions_.find(transaction_id); | 562 transactions_.find(transaction_id); |
565 if (trans_iterator == transactions_.end()) | 563 if (trans_iterator == transactions_.end()) |
566 return; | 564 return; |
567 IndexedDBTransaction* transaction = trans_iterator->second; | 565 IndexedDBTransaction* transaction = trans_iterator->second; |
568 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); | 566 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); |
569 | 567 |
570 DCHECK(metadata_.object_stores.find(object_store_id) != | 568 DCHECK(metadata_.object_stores.find(object_store_id) != |
571 metadata_.object_stores.end()); | 569 metadata_.object_stores.end()); |
572 const IndexedDBObjectStoreMetadata& object_store_metadata = | 570 const IndexedDBObjectStoreMetadata& object_store_metadata = |
573 metadata_.object_stores[object_store_id]; | 571 metadata_.object_stores[object_store_id]; |
574 | 572 |
575 transaction->ScheduleTask( | 573 transaction->ScheduleTask( |
576 new DeleteObjectStoreOperation(backing_store_, object_store_metadata), | 574 new DeleteObjectStoreOperation(backing_store_, object_store_metadata), |
577 new DeleteObjectStoreAbortOperation(this, object_store_metadata)); | 575 new DeleteObjectStoreAbortOperation(this, object_store_metadata)); |
578 RemoveObjectStore(object_store_id); | 576 RemoveObjectStore(object_store_id); |
579 } | 577 } |
580 | 578 |
581 void IndexedDBDatabaseImpl::CreateIndex(int64 transaction_id, | 579 void IndexedDBDatabase::CreateIndex(int64 transaction_id, |
582 int64 object_store_id, | 580 int64 object_store_id, |
583 int64 index_id, | 581 int64 index_id, |
584 const string16& name, | 582 const string16& name, |
585 const IndexedDBKeyPath& key_path, | 583 const IndexedDBKeyPath& key_path, |
586 bool unique, | 584 bool unique, |
587 bool multi_entry) { | 585 bool multi_entry) { |
588 IDB_TRACE("IndexedDBDatabaseImpl::create_index"); | 586 IDB_TRACE("IndexedDBDatabase::create_index"); |
589 TransactionMap::const_iterator trans_iterator = | 587 TransactionMap::const_iterator trans_iterator = |
590 transactions_.find(transaction_id); | 588 transactions_.find(transaction_id); |
591 if (trans_iterator == transactions_.end()) | 589 if (trans_iterator == transactions_.end()) |
592 return; | 590 return; |
593 IndexedDBTransaction* transaction = trans_iterator->second; | 591 IndexedDBTransaction* transaction = trans_iterator->second; |
594 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); | 592 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); |
595 | 593 |
596 DCHECK(metadata_.object_stores.find(object_store_id) != | 594 DCHECK(metadata_.object_stores.find(object_store_id) != |
597 metadata_.object_stores.end()); | 595 metadata_.object_stores.end()); |
598 const IndexedDBObjectStoreMetadata object_store = | 596 const IndexedDBObjectStoreMetadata object_store = |
(...skipping 27 matching lines...) Expand all Loading... |
626 return; | 624 return; |
627 } | 625 } |
628 } | 626 } |
629 | 627 |
630 void CreateIndexAbortOperation::Perform(IndexedDBTransaction* transaction) { | 628 void CreateIndexAbortOperation::Perform(IndexedDBTransaction* transaction) { |
631 IDB_TRACE("CreateIndexAbortOperation"); | 629 IDB_TRACE("CreateIndexAbortOperation"); |
632 DCHECK(!transaction); | 630 DCHECK(!transaction); |
633 database_->RemoveIndex(object_store_id_, index_id_); | 631 database_->RemoveIndex(object_store_id_, index_id_); |
634 } | 632 } |
635 | 633 |
636 void IndexedDBDatabaseImpl::DeleteIndex(int64 transaction_id, | 634 void IndexedDBDatabase::DeleteIndex(int64 transaction_id, |
637 int64 object_store_id, | 635 int64 object_store_id, |
638 int64 index_id) { | 636 int64 index_id) { |
639 IDB_TRACE("IndexedDBDatabaseImpl::delete_index"); | 637 IDB_TRACE("IndexedDBDatabase::delete_index"); |
640 TransactionMap::const_iterator trans_iterator = | 638 TransactionMap::const_iterator trans_iterator = |
641 transactions_.find(transaction_id); | 639 transactions_.find(transaction_id); |
642 if (trans_iterator == transactions_.end()) | 640 if (trans_iterator == transactions_.end()) |
643 return; | 641 return; |
644 IndexedDBTransaction* transaction = trans_iterator->second; | 642 IndexedDBTransaction* transaction = trans_iterator->second; |
645 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); | 643 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); |
646 | 644 |
647 DCHECK(metadata_.object_stores.find(object_store_id) != | 645 DCHECK(metadata_.object_stores.find(object_store_id) != |
648 metadata_.object_stores.end()); | 646 metadata_.object_stores.end()); |
649 IndexedDBObjectStoreMetadata object_store = | 647 IndexedDBObjectStoreMetadata object_store = |
(...skipping 23 matching lines...) Expand all Loading... |
673 } | 671 } |
674 } | 672 } |
675 | 673 |
676 void DeleteIndexAbortOperation::Perform(IndexedDBTransaction* transaction) { | 674 void DeleteIndexAbortOperation::Perform(IndexedDBTransaction* transaction) { |
677 IDB_TRACE("DeleteIndexAbortOperation"); | 675 IDB_TRACE("DeleteIndexAbortOperation"); |
678 DCHECK(!transaction); | 676 DCHECK(!transaction); |
679 database_->AddIndex( | 677 database_->AddIndex( |
680 object_store_id_, index_metadata_, IndexedDBIndexMetadata::kInvalidId); | 678 object_store_id_, index_metadata_, IndexedDBIndexMetadata::kInvalidId); |
681 } | 679 } |
682 | 680 |
683 void IndexedDBDatabaseImpl::Commit(int64 transaction_id) { | 681 void IndexedDBDatabase::Commit(int64 transaction_id) { |
684 // The frontend suggests that we commit, but we may have previously initiated | 682 // The frontend suggests that we commit, but we may have previously initiated |
685 // an abort, and so have disposed of the transaction. on_abort has already | 683 // an abort, and so have disposed of the transaction. on_abort has already |
686 // been dispatched to the frontend, so it will find out about that | 684 // been dispatched to the frontend, so it will find out about that |
687 // asynchronously. | 685 // asynchronously. |
688 if (transactions_.find(transaction_id) != transactions_.end()) | 686 if (transactions_.find(transaction_id) != transactions_.end()) |
689 transactions_[transaction_id]->Commit(); | 687 transactions_[transaction_id]->Commit(); |
690 } | 688 } |
691 | 689 |
692 void IndexedDBDatabaseImpl::Abort(int64 transaction_id) { | 690 void IndexedDBDatabase::Abort(int64 transaction_id) { |
693 // If the transaction is unknown, then it has already been aborted by the | 691 // If the transaction is unknown, then it has already been aborted by the |
694 // backend before this call so it is safe to ignore it. | 692 // backend before this call so it is safe to ignore it. |
695 if (transactions_.find(transaction_id) != transactions_.end()) | 693 if (transactions_.find(transaction_id) != transactions_.end()) |
696 transactions_[transaction_id]->Abort(); | 694 transactions_[transaction_id]->Abort(); |
697 } | 695 } |
698 | 696 |
699 void IndexedDBDatabaseImpl::Abort(int64 transaction_id, | 697 void IndexedDBDatabase::Abort(int64 transaction_id, |
700 const IndexedDBDatabaseError& error) { | 698 const IndexedDBDatabaseError& error) { |
701 // If the transaction is unknown, then it has already been aborted by the | 699 // If the transaction is unknown, then it has already been aborted by the |
702 // backend before this call so it is safe to ignore it. | 700 // backend before this call so it is safe to ignore it. |
703 if (transactions_.find(transaction_id) != transactions_.end()) | 701 if (transactions_.find(transaction_id) != transactions_.end()) |
704 transactions_[transaction_id]->Abort(error); | 702 transactions_[transaction_id]->Abort(error); |
705 } | 703 } |
706 | 704 |
707 void IndexedDBDatabaseImpl::Get( | 705 void IndexedDBDatabase::Get( |
708 int64 transaction_id, | 706 int64 transaction_id, |
709 int64 object_store_id, | 707 int64 object_store_id, |
710 int64 index_id, | 708 int64 index_id, |
711 scoped_ptr<IndexedDBKeyRange> key_range, | 709 scoped_ptr<IndexedDBKeyRange> key_range, |
712 bool key_only, | 710 bool key_only, |
713 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { | 711 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { |
714 IDB_TRACE("IndexedDBDatabaseImpl::get"); | 712 IDB_TRACE("IndexedDBDatabase::get"); |
715 TransactionMap::const_iterator trans_iterator = | 713 TransactionMap::const_iterator trans_iterator = |
716 transactions_.find(transaction_id); | 714 transactions_.find(transaction_id); |
717 if (trans_iterator == transactions_.end()) | 715 if (trans_iterator == transactions_.end()) |
718 return; | 716 return; |
719 IndexedDBTransaction* transaction = trans_iterator->second; | 717 IndexedDBTransaction* transaction = trans_iterator->second; |
720 | 718 |
721 transaction->ScheduleTask(new GetOperation( | 719 transaction->ScheduleTask(new GetOperation( |
722 backing_store_, | 720 backing_store_, |
723 metadata_, | 721 metadata_, |
724 object_store_id, | 722 object_store_id, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 bool ok; | 776 bool ok; |
779 if (index_id_ == IndexedDBIndexMetadata::kInvalidId) { | 777 if (index_id_ == IndexedDBIndexMetadata::kInvalidId) { |
780 // Object Store Retrieval Operation | 778 // Object Store Retrieval Operation |
781 std::vector<char> value; | 779 std::vector<char> value; |
782 ok = backing_store_->GetRecord(transaction->BackingStoreTransaction(), | 780 ok = backing_store_->GetRecord(transaction->BackingStoreTransaction(), |
783 database_id_, | 781 database_id_, |
784 object_store_id_, | 782 object_store_id_, |
785 *key, | 783 *key, |
786 &value); | 784 &value); |
787 if (!ok) { | 785 if (!ok) { |
788 callbacks_->OnError(IndexedDBDatabaseError( | 786 callbacks_->OnError( |
789 WebKit::WebIDBDatabaseExceptionUnknownError, | 787 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, |
790 "Internal error in get_record.")); | 788 "Internal error in get_record.")); |
791 return; | 789 return; |
792 } | 790 } |
793 | 791 |
794 if (value.empty()) { | 792 if (value.empty()) { |
795 callbacks_->OnSuccess(); | 793 callbacks_->OnSuccess(); |
796 return; | 794 return; |
797 } | 795 } |
798 | 796 |
799 if (auto_increment_ && !key_path_.IsNull()) { | 797 if (auto_increment_ && !key_path_.IsNull()) { |
800 callbacks_->OnSuccess(&value, *key, key_path_); | 798 callbacks_->OnSuccess(&value, *key, key_path_); |
801 return; | 799 return; |
802 } | 800 } |
803 | 801 |
804 callbacks_->OnSuccess(&value); | 802 callbacks_->OnSuccess(&value); |
805 return; | 803 return; |
806 } | 804 } |
807 | 805 |
808 // From here we are dealing only with indexes. | 806 // From here we are dealing only with indexes. |
809 ok = backing_store_->GetPrimaryKeyViaIndex( | 807 ok = backing_store_->GetPrimaryKeyViaIndex( |
810 transaction->BackingStoreTransaction(), | 808 transaction->BackingStoreTransaction(), |
811 database_id_, | 809 database_id_, |
812 object_store_id_, | 810 object_store_id_, |
813 index_id_, | 811 index_id_, |
814 *key, | 812 *key, |
815 &primary_key); | 813 &primary_key); |
816 if (!ok) { | 814 if (!ok) { |
817 callbacks_->OnError(IndexedDBDatabaseError( | 815 callbacks_->OnError( |
818 WebKit::WebIDBDatabaseExceptionUnknownError, | 816 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, |
819 "Internal error in get_primary_key_via_index.")); | 817 "Internal error in get_primary_key_via_index.")); |
820 return; | 818 return; |
821 } | 819 } |
822 if (!primary_key) { | 820 if (!primary_key) { |
823 callbacks_->OnSuccess(); | 821 callbacks_->OnSuccess(); |
824 return; | 822 return; |
825 } | 823 } |
826 if (cursor_type_ == indexed_db::CURSOR_KEY_ONLY) { | 824 if (cursor_type_ == indexed_db::CURSOR_KEY_ONLY) { |
827 // Index Value Retrieval Operation | 825 // Index Value Retrieval Operation |
828 callbacks_->OnSuccess(*primary_key); | 826 callbacks_->OnSuccess(*primary_key); |
829 return; | 827 return; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 DCHECK(key); | 886 DCHECK(key); |
889 DCHECK_EQ(WebIDBKey::NumberType, key->type()); | 887 DCHECK_EQ(WebIDBKey::NumberType, key->type()); |
890 return backing_store->MaybeUpdateKeyGeneratorCurrentNumber( | 888 return backing_store->MaybeUpdateKeyGeneratorCurrentNumber( |
891 transaction->BackingStoreTransaction(), | 889 transaction->BackingStoreTransaction(), |
892 database_id, | 890 database_id, |
893 object_store_id, | 891 object_store_id, |
894 static_cast<int64>(floor(key->number())) + 1, | 892 static_cast<int64>(floor(key->number())) + 1, |
895 check_current); | 893 check_current); |
896 } | 894 } |
897 | 895 |
898 void IndexedDBDatabaseImpl::Put( | 896 void IndexedDBDatabase::Put(int64 transaction_id, |
899 int64 transaction_id, | 897 int64 object_store_id, |
900 int64 object_store_id, | 898 std::vector<char>* value, |
901 std::vector<char>* value, | 899 scoped_ptr<IndexedDBKey> key, |
902 scoped_ptr<IndexedDBKey> key, | 900 PutMode put_mode, |
903 PutMode put_mode, | 901 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, |
904 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 902 const std::vector<int64>& index_ids, |
905 const std::vector<int64>& index_ids, | 903 const std::vector<IndexKeys>& index_keys) { |
906 const std::vector<IndexKeys>& index_keys) { | 904 IDB_TRACE("IndexedDBDatabase::put"); |
907 IDB_TRACE("IndexedDBDatabaseImpl::put"); | |
908 TransactionMap::const_iterator trans_iterator = | 905 TransactionMap::const_iterator trans_iterator = |
909 transactions_.find(transaction_id); | 906 transactions_.find(transaction_id); |
910 if (trans_iterator == transactions_.end()) | 907 if (trans_iterator == transactions_.end()) |
911 return; | 908 return; |
912 IndexedDBTransaction* transaction = trans_iterator->second; | 909 IndexedDBTransaction* transaction = trans_iterator->second; |
913 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); | 910 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); |
914 | 911 |
915 const IndexedDBObjectStoreMetadata object_store_metadata = | 912 const IndexedDBObjectStoreMetadata object_store_metadata = |
916 metadata_.object_stores[object_store_id]; | 913 metadata_.object_stores[object_store_id]; |
917 | 914 |
(...skipping 16 matching lines...) Expand all Loading... |
934 DCHECK_EQ(index_ids_.size(), index_keys_.size()); | 931 DCHECK_EQ(index_ids_.size(), index_keys_.size()); |
935 bool key_was_generated = false; | 932 bool key_was_generated = false; |
936 | 933 |
937 scoped_ptr<IndexedDBKey> key; | 934 scoped_ptr<IndexedDBKey> key; |
938 if (put_mode_ != IndexedDBDatabase::CURSOR_UPDATE && | 935 if (put_mode_ != IndexedDBDatabase::CURSOR_UPDATE && |
939 object_store_.auto_increment && !key_->IsValid()) { | 936 object_store_.auto_increment && !key_->IsValid()) { |
940 scoped_ptr<IndexedDBKey> auto_inc_key = GenerateKey( | 937 scoped_ptr<IndexedDBKey> auto_inc_key = GenerateKey( |
941 backing_store_, transaction, database_id_, object_store_.id); | 938 backing_store_, transaction, database_id_, object_store_.id); |
942 key_was_generated = true; | 939 key_was_generated = true; |
943 if (!auto_inc_key->IsValid()) { | 940 if (!auto_inc_key->IsValid()) { |
944 callbacks_->OnError(IndexedDBDatabaseError( | 941 callbacks_->OnError( |
945 WebKit::WebIDBDatabaseExceptionConstraintError, | 942 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionConstraintError, |
946 "Maximum key generator value reached.")); | 943 "Maximum key generator value reached.")); |
947 return; | 944 return; |
948 } | 945 } |
949 key = auto_inc_key.Pass(); | 946 key = auto_inc_key.Pass(); |
950 } else { | 947 } else { |
951 key = key_.Pass(); | 948 key = key_.Pass(); |
952 } | 949 } |
953 | 950 |
954 DCHECK(key->IsValid()); | 951 DCHECK(key->IsValid()); |
955 | 952 |
956 IndexedDBBackingStore::RecordIdentifier record_identifier; | 953 IndexedDBBackingStore::RecordIdentifier record_identifier; |
957 if (put_mode_ == IndexedDBDatabase::ADD_ONLY) { | 954 if (put_mode_ == IndexedDBDatabase::ADD_ONLY) { |
958 bool found = false; | 955 bool found = false; |
959 bool ok = backing_store_->KeyExistsInObjectStore( | 956 bool ok = backing_store_->KeyExistsInObjectStore( |
960 transaction->BackingStoreTransaction(), | 957 transaction->BackingStoreTransaction(), |
961 database_id_, | 958 database_id_, |
962 object_store_.id, | 959 object_store_.id, |
963 *key.get(), | 960 *key.get(), |
964 &record_identifier, | 961 &record_identifier, |
965 &found); | 962 &found); |
966 if (!ok) { | 963 if (!ok) { |
967 callbacks_->OnError(IndexedDBDatabaseError( | 964 callbacks_->OnError( |
968 WebKit::WebIDBDatabaseExceptionUnknownError, | 965 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, |
969 "Internal error checking key existence.")); | 966 "Internal error checking key existence.")); |
970 return; | 967 return; |
971 } | 968 } |
972 if (found) { | 969 if (found) { |
973 callbacks_->OnError(IndexedDBDatabaseError( | 970 callbacks_->OnError( |
974 WebKit::WebIDBDatabaseExceptionConstraintError, | 971 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionConstraintError, |
975 "Key already exists in the object store.")); | 972 "Key already exists in the object store.")); |
976 return; | 973 return; |
977 } | 974 } |
978 } | 975 } |
979 | 976 |
980 ScopedVector<IndexedDBObjectStoreImpl::IndexWriter> index_writers; | 977 ScopedVector<IndexedDBObjectStoreImpl::IndexWriter> index_writers; |
981 string16 error_message; | 978 string16 error_message; |
982 bool obeys_constraints = false; | 979 bool obeys_constraints = false; |
983 bool backing_store_success = | 980 bool backing_store_success = |
984 IndexedDBObjectStoreImpl::MakeIndexWriters(transaction, | 981 IndexedDBObjectStoreImpl::MakeIndexWriters(transaction, |
985 backing_store_.get(), | 982 backing_store_.get(), |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 if (object_store_.auto_increment && | 1029 if (object_store_.auto_increment && |
1033 put_mode_ != IndexedDBDatabase::CURSOR_UPDATE && | 1030 put_mode_ != IndexedDBDatabase::CURSOR_UPDATE && |
1034 key->type() == WebIDBKey::NumberType) { | 1031 key->type() == WebIDBKey::NumberType) { |
1035 bool ok = UpdateKeyGenerator(backing_store_, | 1032 bool ok = UpdateKeyGenerator(backing_store_, |
1036 transaction, | 1033 transaction, |
1037 database_id_, | 1034 database_id_, |
1038 object_store_.id, | 1035 object_store_.id, |
1039 key.get(), | 1036 key.get(), |
1040 !key_was_generated); | 1037 !key_was_generated); |
1041 if (!ok) { | 1038 if (!ok) { |
1042 callbacks_->OnError(IndexedDBDatabaseError( | 1039 callbacks_->OnError( |
1043 WebKit::WebIDBDatabaseExceptionUnknownError, | 1040 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, |
1044 "Internal error updating key generator.")); | 1041 "Internal error updating key generator.")); |
1045 return; | 1042 return; |
1046 } | 1043 } |
1047 } | 1044 } |
1048 | 1045 |
1049 callbacks_->OnSuccess(*key); | 1046 callbacks_->OnSuccess(*key); |
1050 } | 1047 } |
1051 | 1048 |
1052 void IndexedDBDatabaseImpl::SetIndexKeys( | 1049 void IndexedDBDatabase::SetIndexKeys(int64 transaction_id, |
1053 int64 transaction_id, | 1050 int64 object_store_id, |
1054 int64 object_store_id, | 1051 scoped_ptr<IndexedDBKey> primary_key, |
1055 scoped_ptr<IndexedDBKey> primary_key, | 1052 const std::vector<int64>& index_ids, |
1056 const std::vector<int64>& index_ids, | 1053 const std::vector<IndexKeys>& index_keys) { |
1057 const std::vector<IndexKeys>& index_keys) { | 1054 IDB_TRACE("IndexedDBDatabase::set_index_keys"); |
1058 IDB_TRACE("IndexedDBDatabaseImpl::set_index_keys"); | |
1059 TransactionMap::const_iterator trans_iterator = | 1055 TransactionMap::const_iterator trans_iterator = |
1060 transactions_.find(transaction_id); | 1056 transactions_.find(transaction_id); |
1061 if (trans_iterator == transactions_.end()) | 1057 if (trans_iterator == transactions_.end()) |
1062 return; | 1058 return; |
1063 IndexedDBTransaction* transaction = trans_iterator->second; | 1059 IndexedDBTransaction* transaction = trans_iterator->second; |
1064 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); | 1060 DCHECK_EQ(transaction->mode(), indexed_db::TRANSACTION_VERSION_CHANGE); |
1065 | 1061 |
1066 scoped_refptr<IndexedDBBackingStore> store = BackingStore(); | 1062 scoped_refptr<IndexedDBBackingStore> store = BackingStore(); |
1067 // TODO(jsbell): This method could be asynchronous, but we need to | 1063 // TODO(jsbell): This method could be asynchronous, but we need to |
1068 // evaluate if it's worth the extra complexity. | 1064 // evaluate if it's worth the extra complexity. |
1069 IndexedDBBackingStore::RecordIdentifier record_identifier; | 1065 IndexedDBBackingStore::RecordIdentifier record_identifier; |
1070 bool found = false; | 1066 bool found = false; |
1071 bool ok = | 1067 bool ok = |
1072 store->KeyExistsInObjectStore(transaction->BackingStoreTransaction(), | 1068 store->KeyExistsInObjectStore(transaction->BackingStoreTransaction(), |
1073 metadata_.id, | 1069 metadata_.id, |
1074 object_store_id, | 1070 object_store_id, |
1075 *primary_key, | 1071 *primary_key, |
1076 &record_identifier, | 1072 &record_identifier, |
1077 &found); | 1073 &found); |
1078 if (!ok) { | 1074 if (!ok) { |
1079 transaction->Abort(IndexedDBDatabaseError( | 1075 transaction->Abort( |
1080 WebKit::WebIDBDatabaseExceptionUnknownError, | 1076 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, |
1081 "Internal error setting index keys.")); | 1077 "Internal error setting index keys.")); |
1082 return; | 1078 return; |
1083 } | 1079 } |
1084 if (!found) { | 1080 if (!found) { |
1085 transaction->Abort(IndexedDBDatabaseError( | 1081 transaction->Abort(IndexedDBDatabaseError( |
1086 WebKit::WebIDBDatabaseExceptionUnknownError, | 1082 WebKit::WebIDBDatabaseExceptionUnknownError, |
1087 "Internal error setting index keys for object store.")); | 1083 "Internal error setting index keys for object store.")); |
1088 return; | 1084 return; |
1089 } | 1085 } |
1090 | 1086 |
1091 ScopedVector<IndexedDBObjectStoreImpl::IndexWriter> index_writers; | 1087 ScopedVector<IndexedDBObjectStoreImpl::IndexWriter> index_writers; |
(...skipping 30 matching lines...) Expand all Loading... |
1122 for (size_t i = 0; i < index_writers.size(); ++i) { | 1118 for (size_t i = 0; i < index_writers.size(); ++i) { |
1123 IndexedDBObjectStoreImpl::IndexWriter* index_writer = index_writers[i]; | 1119 IndexedDBObjectStoreImpl::IndexWriter* index_writer = index_writers[i]; |
1124 index_writer->WriteIndexKeys(record_identifier, | 1120 index_writer->WriteIndexKeys(record_identifier, |
1125 store.get(), | 1121 store.get(), |
1126 transaction->BackingStoreTransaction(), | 1122 transaction->BackingStoreTransaction(), |
1127 id(), | 1123 id(), |
1128 object_store_id); | 1124 object_store_id); |
1129 } | 1125 } |
1130 } | 1126 } |
1131 | 1127 |
1132 void IndexedDBDatabaseImpl::SetIndexesReady( | 1128 void IndexedDBDatabase::SetIndexesReady(int64 transaction_id, |
1133 int64 transaction_id, | 1129 int64, |
1134 int64, | 1130 const std::vector<int64>& index_ids) { |
1135 const std::vector<int64>& index_ids) { | |
1136 IDB_TRACE("IndexedDBObjectStoreImpl::set_indexes_ready"); | 1131 IDB_TRACE("IndexedDBObjectStoreImpl::set_indexes_ready"); |
1137 | 1132 |
1138 TransactionMap::const_iterator trans_iterator = | 1133 TransactionMap::const_iterator trans_iterator = |
1139 transactions_.find(transaction_id); | 1134 transactions_.find(transaction_id); |
1140 if (trans_iterator == transactions_.end()) | 1135 if (trans_iterator == transactions_.end()) |
1141 return; | 1136 return; |
1142 IndexedDBTransaction* transaction = trans_iterator->second; | 1137 IndexedDBTransaction* transaction = trans_iterator->second; |
1143 | 1138 |
1144 transaction->ScheduleTask(IndexedDBDatabase::PREEMPTIVE_TASK, | 1139 transaction->ScheduleTask(IndexedDBDatabase::PREEMPTIVE_TASK, |
1145 new SetIndexesReadyOperation(index_ids.size())); | 1140 new SetIndexesReadyOperation(index_ids.size())); |
1146 } | 1141 } |
1147 | 1142 |
1148 void SetIndexesReadyOperation::Perform(IndexedDBTransaction* transaction) { | 1143 void SetIndexesReadyOperation::Perform(IndexedDBTransaction* transaction) { |
1149 IDB_TRACE("SetIndexesReadyOperation"); | 1144 IDB_TRACE("SetIndexesReadyOperation"); |
1150 for (size_t i = 0; i < index_count_; ++i) | 1145 for (size_t i = 0; i < index_count_; ++i) |
1151 transaction->DidCompletePreemptiveEvent(); | 1146 transaction->DidCompletePreemptiveEvent(); |
1152 } | 1147 } |
1153 | 1148 |
1154 void IndexedDBDatabaseImpl::OpenCursor( | 1149 void IndexedDBDatabase::OpenCursor( |
1155 int64 transaction_id, | 1150 int64 transaction_id, |
1156 int64 object_store_id, | 1151 int64 object_store_id, |
1157 int64 index_id, | 1152 int64 index_id, |
1158 scoped_ptr<IndexedDBKeyRange> key_range, | 1153 scoped_ptr<IndexedDBKeyRange> key_range, |
1159 indexed_db::CursorDirection direction, | 1154 indexed_db::CursorDirection direction, |
1160 bool key_only, | 1155 bool key_only, |
1161 TaskType task_type, | 1156 TaskType task_type, |
1162 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { | 1157 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { |
1163 IDB_TRACE("IndexedDBDatabaseImpl::open_cursor"); | 1158 IDB_TRACE("IndexedDBDatabase::open_cursor"); |
1164 TransactionMap::const_iterator trans_iterator = | 1159 TransactionMap::const_iterator trans_iterator = |
1165 transactions_.find(transaction_id); | 1160 transactions_.find(transaction_id); |
1166 if (trans_iterator == transactions_.end()) | 1161 if (trans_iterator == transactions_.end()) |
1167 return; | 1162 return; |
1168 IndexedDBTransaction* transaction = trans_iterator->second; | 1163 IndexedDBTransaction* transaction = trans_iterator->second; |
1169 | 1164 |
1170 transaction->ScheduleTask(new OpenCursorOperation( | 1165 transaction->ScheduleTask(new OpenCursorOperation( |
1171 backing_store_, | 1166 backing_store_, |
1172 id(), | 1167 id(), |
1173 object_store_id, | 1168 object_store_id, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 } | 1214 } |
1220 } | 1215 } |
1221 | 1216 |
1222 if (!backing_store_cursor) { | 1217 if (!backing_store_cursor) { |
1223 callbacks_->OnSuccess(static_cast<std::vector<char>*>(NULL)); | 1218 callbacks_->OnSuccess(static_cast<std::vector<char>*>(NULL)); |
1224 return; | 1219 return; |
1225 } | 1220 } |
1226 | 1221 |
1227 IndexedDBDatabase::TaskType task_type( | 1222 IndexedDBDatabase::TaskType task_type( |
1228 static_cast<IndexedDBDatabase::TaskType>(task_type_)); | 1223 static_cast<IndexedDBDatabase::TaskType>(task_type_)); |
1229 scoped_refptr<IndexedDBCursorImpl> cursor = IndexedDBCursorImpl::Create( | 1224 scoped_refptr<IndexedDBCursor> cursor = IndexedDBCursor::Create( |
1230 backing_store_cursor.Pass(), cursor_type_, task_type, transaction); | 1225 backing_store_cursor.Pass(), cursor_type_, task_type, transaction); |
1231 callbacks_->OnSuccess( | 1226 callbacks_->OnSuccess( |
1232 cursor, cursor->key(), cursor->primary_key(), cursor->Value()); | 1227 cursor, cursor->key(), cursor->primary_key(), cursor->Value()); |
1233 } | 1228 } |
1234 | 1229 |
1235 void IndexedDBDatabaseImpl::Count( | 1230 void IndexedDBDatabase::Count( |
1236 int64 transaction_id, | 1231 int64 transaction_id, |
1237 int64 object_store_id, | 1232 int64 object_store_id, |
1238 int64 index_id, | 1233 int64 index_id, |
1239 scoped_ptr<IndexedDBKeyRange> key_range, | 1234 scoped_ptr<IndexedDBKeyRange> key_range, |
1240 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { | 1235 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { |
1241 IDB_TRACE("IndexedDBDatabaseImpl::count"); | 1236 IDB_TRACE("IndexedDBDatabase::count"); |
1242 TransactionMap::const_iterator trans_iterator = | 1237 TransactionMap::const_iterator trans_iterator = |
1243 transactions_.find(transaction_id); | 1238 transactions_.find(transaction_id); |
1244 if (trans_iterator == transactions_.end()) | 1239 if (trans_iterator == transactions_.end()) |
1245 return; | 1240 return; |
1246 IndexedDBTransaction* transaction = trans_iterator->second; | 1241 IndexedDBTransaction* transaction = trans_iterator->second; |
1247 | 1242 |
1248 DCHECK(metadata_.object_stores.find(object_store_id) != | 1243 DCHECK(metadata_.object_stores.find(object_store_id) != |
1249 metadata_.object_stores.end()); | 1244 metadata_.object_stores.end()); |
1250 transaction->ScheduleTask(new CountOperation(backing_store_, | 1245 transaction->ScheduleTask(new CountOperation(backing_store_, |
1251 id(), | 1246 id(), |
(...skipping 29 matching lines...) Expand all Loading... |
1281 return; | 1276 return; |
1282 } | 1277 } |
1283 | 1278 |
1284 do { | 1279 do { |
1285 ++count; | 1280 ++count; |
1286 } while (backing_store_cursor->ContinueFunction(0)); | 1281 } while (backing_store_cursor->ContinueFunction(0)); |
1287 | 1282 |
1288 callbacks_->OnSuccess(count); | 1283 callbacks_->OnSuccess(count); |
1289 } | 1284 } |
1290 | 1285 |
1291 void IndexedDBDatabaseImpl::DeleteRange( | 1286 void IndexedDBDatabase::DeleteRange( |
1292 int64 transaction_id, | 1287 int64 transaction_id, |
1293 int64 object_store_id, | 1288 int64 object_store_id, |
1294 scoped_ptr<IndexedDBKeyRange> key_range, | 1289 scoped_ptr<IndexedDBKeyRange> key_range, |
1295 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { | 1290 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { |
1296 IDB_TRACE("IndexedDBDatabaseImpl::delete_range"); | 1291 IDB_TRACE("IndexedDBDatabase::delete_range"); |
1297 TransactionMap::const_iterator trans_iterator = | 1292 TransactionMap::const_iterator trans_iterator = |
1298 transactions_.find(transaction_id); | 1293 transactions_.find(transaction_id); |
1299 if (trans_iterator == transactions_.end()) | 1294 if (trans_iterator == transactions_.end()) |
1300 return; | 1295 return; |
1301 IndexedDBTransaction* transaction = trans_iterator->second; | 1296 IndexedDBTransaction* transaction = trans_iterator->second; |
1302 | 1297 |
1303 transaction->ScheduleTask(new DeleteRangeOperation( | 1298 transaction->ScheduleTask(new DeleteRangeOperation( |
1304 backing_store_, id(), object_store_id, key_range.Pass(), callbacks)); | 1299 backing_store_, id(), object_store_id, key_range.Pass(), callbacks)); |
1305 } | 1300 } |
1306 | 1301 |
1307 void DeleteRangeOperation::Perform(IndexedDBTransaction* transaction) { | 1302 void DeleteRangeOperation::Perform(IndexedDBTransaction* transaction) { |
1308 IDB_TRACE("DeleteRangeOperation"); | 1303 IDB_TRACE("DeleteRangeOperation"); |
1309 scoped_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor = | 1304 scoped_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor = |
1310 backing_store_->OpenObjectStoreCursor( | 1305 backing_store_->OpenObjectStoreCursor( |
1311 transaction->BackingStoreTransaction(), | 1306 transaction->BackingStoreTransaction(), |
1312 database_id_, | 1307 database_id_, |
1313 object_store_id_, | 1308 object_store_id_, |
1314 *key_range_, | 1309 *key_range_, |
1315 indexed_db::CURSOR_NEXT); | 1310 indexed_db::CURSOR_NEXT); |
1316 if (backing_store_cursor) { | 1311 if (backing_store_cursor) { |
1317 do { | 1312 do { |
1318 if (!backing_store_->DeleteRecord( | 1313 if (!backing_store_->DeleteRecord( |
1319 transaction->BackingStoreTransaction(), | 1314 transaction->BackingStoreTransaction(), |
1320 database_id_, | 1315 database_id_, |
1321 object_store_id_, | 1316 object_store_id_, |
1322 backing_store_cursor->record_identifier())) { | 1317 backing_store_cursor->record_identifier())) { |
1323 callbacks_->OnError(IndexedDBDatabaseError( | 1318 callbacks_->OnError( |
1324 WebKit::WebIDBDatabaseExceptionUnknownError, | 1319 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, |
1325 "Internal error deleting data in range")); | 1320 "Internal error deleting data in range")); |
1326 return; | 1321 return; |
1327 } | 1322 } |
1328 } while (backing_store_cursor->ContinueFunction(0)); | 1323 } while (backing_store_cursor->ContinueFunction(0)); |
1329 } | 1324 } |
1330 | 1325 |
1331 callbacks_->OnSuccess(); | 1326 callbacks_->OnSuccess(); |
1332 } | 1327 } |
1333 | 1328 |
1334 void IndexedDBDatabaseImpl::Clear( | 1329 void IndexedDBDatabase::Clear( |
1335 int64 transaction_id, | 1330 int64 transaction_id, |
1336 int64 object_store_id, | 1331 int64 object_store_id, |
1337 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { | 1332 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { |
1338 IDB_TRACE("IndexedDBDatabaseImpl::clear"); | 1333 IDB_TRACE("IndexedDBDatabase::clear"); |
1339 TransactionMap::const_iterator trans_iterator = | 1334 TransactionMap::const_iterator trans_iterator = |
1340 transactions_.find(transaction_id); | 1335 transactions_.find(transaction_id); |
1341 if (trans_iterator == transactions_.end()) | 1336 if (trans_iterator == transactions_.end()) |
1342 return; | 1337 return; |
1343 IndexedDBTransaction* transaction = trans_iterator->second; | 1338 IndexedDBTransaction* transaction = trans_iterator->second; |
1344 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); | 1339 DCHECK_NE(transaction->mode(), indexed_db::TRANSACTION_READ_ONLY); |
1345 | 1340 |
1346 transaction->ScheduleTask( | 1341 transaction->ScheduleTask( |
1347 new ClearOperation(backing_store_, id(), object_store_id, callbacks)); | 1342 new ClearOperation(backing_store_, id(), object_store_id, callbacks)); |
1348 } | 1343 } |
1349 | 1344 |
1350 void ClearOperation::Perform(IndexedDBTransaction* transaction) { | 1345 void ClearOperation::Perform(IndexedDBTransaction* transaction) { |
1351 IDB_TRACE("ObjectStoreClearOperation"); | 1346 IDB_TRACE("ObjectStoreClearOperation"); |
1352 if (!backing_store_->ClearObjectStore(transaction->BackingStoreTransaction(), | 1347 if (!backing_store_->ClearObjectStore(transaction->BackingStoreTransaction(), |
1353 database_id_, | 1348 database_id_, |
1354 object_store_id_)) { | 1349 object_store_id_)) { |
1355 callbacks_->OnError(IndexedDBDatabaseError( | 1350 callbacks_->OnError( |
1356 WebKit::WebIDBDatabaseExceptionUnknownError, | 1351 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, |
1357 "Internal error clearing object store")); | 1352 "Internal error clearing object store")); |
1358 return; | 1353 return; |
1359 } | 1354 } |
1360 callbacks_->OnSuccess(); | 1355 callbacks_->OnSuccess(); |
1361 } | 1356 } |
1362 | 1357 |
1363 void DeleteObjectStoreOperation::Perform(IndexedDBTransaction* transaction) { | 1358 void DeleteObjectStoreOperation::Perform(IndexedDBTransaction* transaction) { |
1364 IDB_TRACE("DeleteObjectStoreOperation"); | 1359 IDB_TRACE("DeleteObjectStoreOperation"); |
1365 bool ok = | 1360 bool ok = |
1366 backing_store_->DeleteObjectStore(transaction->BackingStoreTransaction(), | 1361 backing_store_->DeleteObjectStore(transaction->BackingStoreTransaction(), |
1367 transaction->database()->id(), | 1362 transaction->database()->id(), |
1368 object_store_metadata_.id); | 1363 object_store_metadata_.id); |
1369 if (!ok) { | 1364 if (!ok) { |
1370 string16 error_string = | 1365 string16 error_string = |
1371 ASCIIToUTF16("Internal error deleting object store '") + | 1366 ASCIIToUTF16("Internal error deleting object store '") + |
1372 object_store_metadata_.name + ASCIIToUTF16("'."); | 1367 object_store_metadata_.name + ASCIIToUTF16("'."); |
1373 transaction->Abort(IndexedDBDatabaseError( | 1368 transaction->Abort(IndexedDBDatabaseError( |
1374 WebKit::WebIDBDatabaseExceptionUnknownError, error_string)); | 1369 WebKit::WebIDBDatabaseExceptionUnknownError, error_string)); |
1375 } | 1370 } |
1376 } | 1371 } |
1377 | 1372 |
1378 void IndexedDBDatabaseImpl::VersionChangeOperation::Perform( | 1373 void IndexedDBDatabase::VersionChangeOperation::Perform( |
1379 IndexedDBTransaction* transaction) { | 1374 IndexedDBTransaction* transaction) { |
1380 IDB_TRACE("VersionChangeOperation"); | 1375 IDB_TRACE("VersionChangeOperation"); |
1381 int64 database_id = database_->id(); | 1376 int64 database_id = database_->id(); |
1382 int64 old_version = database_->metadata_.int_version; | 1377 int64 old_version = database_->metadata_.int_version; |
1383 DCHECK_GT(version_, old_version); | 1378 DCHECK_GT(version_, old_version); |
1384 database_->metadata_.int_version = version_; | 1379 database_->metadata_.int_version = version_; |
1385 if (!database_->backing_store_->UpdateIDBDatabaseIntVersion( | 1380 if (!database_->backing_store_->UpdateIDBDatabaseIntVersion( |
1386 transaction->BackingStoreTransaction(), | 1381 transaction->BackingStoreTransaction(), |
1387 database_id, | 1382 database_id, |
1388 database_->metadata_.int_version)) { | 1383 database_->metadata_.int_version)) { |
1389 IndexedDBDatabaseError error( | 1384 IndexedDBDatabaseError error( |
1390 WebKit::WebIDBDatabaseExceptionUnknownError, | 1385 WebKit::WebIDBDatabaseExceptionUnknownError, |
1391 ASCIIToUTF16("Internal error writing data to stable storage when " | 1386 ASCIIToUTF16("Internal error writing data to stable storage when " |
1392 "updating version.")); | 1387 "updating version.")); |
1393 callbacks_->OnError(error); | 1388 callbacks_->OnError(error); |
1394 transaction->Abort(error); | 1389 transaction->Abort(error); |
1395 return; | 1390 return; |
1396 } | 1391 } |
1397 DCHECK(!database_->pending_second_half_open_); | 1392 DCHECK(!database_->pending_second_half_open_); |
1398 database_->pending_second_half_open_.reset(new PendingOpenCall( | 1393 database_->pending_second_half_open_.reset(new PendingOpenCall( |
1399 callbacks_, database_callbacks_, transaction_id_, version_)); | 1394 callbacks_, database_callbacks_, transaction_id_, version_)); |
1400 callbacks_->OnUpgradeNeeded(old_version, database_, database_->metadata()); | 1395 callbacks_->OnUpgradeNeeded(old_version, database_, database_->metadata()); |
1401 } | 1396 } |
1402 | 1397 |
1403 void IndexedDBDatabaseImpl::TransactionStarted( | 1398 void IndexedDBDatabase::TransactionStarted(IndexedDBTransaction* transaction) { |
1404 IndexedDBTransaction* transaction) { | |
1405 | 1399 |
1406 if (transaction->mode() == indexed_db::TRANSACTION_VERSION_CHANGE) { | 1400 if (transaction->mode() == indexed_db::TRANSACTION_VERSION_CHANGE) { |
1407 DCHECK(!running_version_change_transaction_); | 1401 DCHECK(!running_version_change_transaction_); |
1408 running_version_change_transaction_ = transaction; | 1402 running_version_change_transaction_ = transaction; |
1409 } | 1403 } |
1410 } | 1404 } |
1411 | 1405 |
1412 void IndexedDBDatabaseImpl::TransactionFinished( | 1406 void IndexedDBDatabase::TransactionFinished(IndexedDBTransaction* transaction) { |
1413 IndexedDBTransaction* transaction) { | |
1414 | 1407 |
1415 DCHECK(transactions_.find(transaction->id()) != transactions_.end()); | 1408 DCHECK(transactions_.find(transaction->id()) != transactions_.end()); |
1416 DCHECK_EQ(transactions_[transaction->id()], transaction); | 1409 DCHECK_EQ(transactions_[transaction->id()], transaction); |
1417 transactions_.erase(transaction->id()); | 1410 transactions_.erase(transaction->id()); |
1418 if (transaction->mode() == indexed_db::TRANSACTION_VERSION_CHANGE) { | 1411 if (transaction->mode() == indexed_db::TRANSACTION_VERSION_CHANGE) { |
1419 DCHECK_EQ(transaction, running_version_change_transaction_); | 1412 DCHECK_EQ(transaction, running_version_change_transaction_); |
1420 running_version_change_transaction_ = NULL; | 1413 running_version_change_transaction_ = NULL; |
1421 } | 1414 } |
1422 } | 1415 } |
1423 | 1416 |
1424 void IndexedDBDatabaseImpl::TransactionFinishedAndAbortFired( | 1417 void IndexedDBDatabase::TransactionFinishedAndAbortFired( |
1425 IndexedDBTransaction* transaction) { | 1418 IndexedDBTransaction* transaction) { |
1426 if (transaction->mode() == indexed_db::TRANSACTION_VERSION_CHANGE) { | 1419 if (transaction->mode() == indexed_db::TRANSACTION_VERSION_CHANGE) { |
1427 if (pending_second_half_open_) { | 1420 if (pending_second_half_open_) { |
1428 pending_second_half_open_->Callbacks()->OnError(IndexedDBDatabaseError( | 1421 pending_second_half_open_->Callbacks()->OnError( |
1429 WebKit::WebIDBDatabaseExceptionAbortError, | 1422 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionAbortError, |
1430 "Version change transaction was aborted in " | 1423 "Version change transaction was aborted in " |
1431 "upgradeneeded event handler.")); | 1424 "upgradeneeded event handler.")); |
1432 pending_second_half_open_.reset(); | 1425 pending_second_half_open_.reset(); |
1433 } | 1426 } |
1434 ProcessPendingCalls(); | 1427 ProcessPendingCalls(); |
1435 } | 1428 } |
1436 } | 1429 } |
1437 | 1430 |
1438 void IndexedDBDatabaseImpl::TransactionFinishedAndCompleteFired( | 1431 void IndexedDBDatabase::TransactionFinishedAndCompleteFired( |
1439 IndexedDBTransaction* transaction) { | 1432 IndexedDBTransaction* transaction) { |
1440 if (transaction->mode() == indexed_db::TRANSACTION_VERSION_CHANGE) { | 1433 if (transaction->mode() == indexed_db::TRANSACTION_VERSION_CHANGE) { |
1441 DCHECK(pending_second_half_open_); | 1434 DCHECK(pending_second_half_open_); |
1442 if (pending_second_half_open_) { | 1435 if (pending_second_half_open_) { |
1443 DCHECK_EQ(pending_second_half_open_->Version(), metadata_.int_version); | 1436 DCHECK_EQ(pending_second_half_open_->Version(), metadata_.int_version); |
1444 DCHECK(metadata_.id != kInvalidId); | 1437 DCHECK(metadata_.id != kInvalidId); |
1445 pending_second_half_open_->Callbacks()->OnSuccess(this, this->metadata()); | 1438 pending_second_half_open_->Callbacks()->OnSuccess(this, this->metadata()); |
1446 pending_second_half_open_.reset(); | 1439 pending_second_half_open_.reset(); |
1447 } | 1440 } |
1448 ProcessPendingCalls(); | 1441 ProcessPendingCalls(); |
1449 } | 1442 } |
1450 } | 1443 } |
1451 | 1444 |
1452 size_t IndexedDBDatabaseImpl::ConnectionCount() const { | 1445 size_t IndexedDBDatabase::ConnectionCount() const { |
1453 // This does not include pending open calls, as those should not block version | 1446 // This does not include pending open calls, as those should not block version |
1454 // changes and deletes. | 1447 // changes and deletes. |
1455 return database_callbacks_set_.size(); | 1448 return database_callbacks_set_.size(); |
1456 } | 1449 } |
1457 | 1450 |
1458 void IndexedDBDatabaseImpl::ProcessPendingCalls() { | 1451 void IndexedDBDatabase::ProcessPendingCalls() { |
1459 if (pending_second_half_open_) { | 1452 if (pending_second_half_open_) { |
1460 DCHECK_EQ(pending_second_half_open_->Version(), metadata_.int_version); | 1453 DCHECK_EQ(pending_second_half_open_->Version(), metadata_.int_version); |
1461 DCHECK(metadata_.id != kInvalidId); | 1454 DCHECK(metadata_.id != kInvalidId); |
1462 scoped_ptr<PendingOpenCall> pending_call = pending_second_half_open_.Pass(); | 1455 scoped_ptr<PendingOpenCall> pending_call = pending_second_half_open_.Pass(); |
1463 pending_call->Callbacks()->OnSuccess(this, this->metadata()); | 1456 pending_call->Callbacks()->OnSuccess(this, this->metadata()); |
1464 // Fall through when complete, as pending opens may be unblocked. | 1457 // Fall through when complete, as pending opens may be unblocked. |
1465 } | 1458 } |
1466 | 1459 |
1467 if (pending_run_version_change_transaction_call_ && ConnectionCount() == 1) { | 1460 if (pending_run_version_change_transaction_call_ && ConnectionCount() == 1) { |
1468 DCHECK(pending_run_version_change_transaction_call_->Version() > | 1461 DCHECK(pending_run_version_change_transaction_call_->Version() > |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 scoped_ptr<PendingOpenCall> pending_open_call(pending_open_calls.front()); | 1497 scoped_ptr<PendingOpenCall> pending_open_call(pending_open_calls.front()); |
1505 pending_open_calls.pop_front(); | 1498 pending_open_calls.pop_front(); |
1506 OpenConnection(pending_open_call->Callbacks(), | 1499 OpenConnection(pending_open_call->Callbacks(), |
1507 pending_open_call->DatabaseCallbacks(), | 1500 pending_open_call->DatabaseCallbacks(), |
1508 pending_open_call->TransactionId(), | 1501 pending_open_call->TransactionId(), |
1509 pending_open_call->Version()); | 1502 pending_open_call->Version()); |
1510 } | 1503 } |
1511 } | 1504 } |
1512 } | 1505 } |
1513 | 1506 |
1514 void IndexedDBDatabaseImpl::CreateTransaction( | 1507 void IndexedDBDatabase::CreateTransaction( |
1515 int64 transaction_id, | 1508 int64 transaction_id, |
1516 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> callbacks, | 1509 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> callbacks, |
1517 const std::vector<int64>& object_store_ids, | 1510 const std::vector<int64>& object_store_ids, |
1518 uint16 mode) { | 1511 uint16 mode) { |
1519 | 1512 |
1520 DCHECK(database_callbacks_set_.has(callbacks)); | 1513 DCHECK(database_callbacks_set_.has(callbacks)); |
1521 | 1514 |
1522 scoped_refptr<IndexedDBTransaction> transaction = | 1515 scoped_refptr<IndexedDBTransaction> transaction = |
1523 IndexedDBTransaction::Create( | 1516 IndexedDBTransaction::Create( |
1524 transaction_id, | 1517 transaction_id, |
1525 callbacks, | 1518 callbacks, |
1526 object_store_ids, | 1519 object_store_ids, |
1527 static_cast<indexed_db::TransactionMode>(mode), | 1520 static_cast<indexed_db::TransactionMode>(mode), |
1528 this); | 1521 this); |
1529 DCHECK(transactions_.find(transaction_id) == transactions_.end()); | 1522 DCHECK(transactions_.find(transaction_id) == transactions_.end()); |
1530 transactions_[transaction_id] = transaction; | 1523 transactions_[transaction_id] = transaction; |
1531 } | 1524 } |
1532 | 1525 |
1533 bool IndexedDBDatabaseImpl::IsOpenConnectionBlocked() const { | 1526 bool IndexedDBDatabase::IsOpenConnectionBlocked() const { |
1534 return !pending_delete_calls_.empty() || | 1527 return !pending_delete_calls_.empty() || |
1535 running_version_change_transaction_ || | 1528 running_version_change_transaction_ || |
1536 pending_run_version_change_transaction_call_; | 1529 pending_run_version_change_transaction_call_; |
1537 } | 1530 } |
1538 | 1531 |
1539 void IndexedDBDatabaseImpl::OpenConnection( | 1532 void IndexedDBDatabase::OpenConnection( |
1540 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 1533 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, |
1541 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks, | 1534 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks, |
1542 int64 transaction_id, | 1535 int64 transaction_id, |
1543 int64 version) { | 1536 int64 version) { |
1544 DCHECK(backing_store_.get()); | 1537 DCHECK(backing_store_.get()); |
1545 | 1538 |
1546 // TODO(jsbell): Should have a priority queue so that higher version | 1539 // TODO(jsbell): Should have a priority queue so that higher version |
1547 // requests are processed first. http://crbug.com/225850 | 1540 // requests are processed first. http://crbug.com/225850 |
1548 if (IsOpenConnectionBlocked()) { | 1541 if (IsOpenConnectionBlocked()) { |
1549 pending_open_calls_.push_back(new PendingOpenCall( | 1542 pending_open_calls_.push_back(new PendingOpenCall( |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 ASCIIToUTF16("The requested version (") + Int64ToString16(version) + | 1604 ASCIIToUTF16("The requested version (") + Int64ToString16(version) + |
1612 ASCIIToUTF16(") is less than the existing version (") + | 1605 ASCIIToUTF16(") is less than the existing version (") + |
1613 Int64ToString16(metadata_.int_version) + ASCIIToUTF16(")."))); | 1606 Int64ToString16(metadata_.int_version) + ASCIIToUTF16(")."))); |
1614 return; | 1607 return; |
1615 } | 1608 } |
1616 DCHECK_EQ(version, metadata_.int_version); | 1609 DCHECK_EQ(version, metadata_.int_version); |
1617 database_callbacks_set_.insert(database_callbacks); | 1610 database_callbacks_set_.insert(database_callbacks); |
1618 callbacks->OnSuccess(this, this->metadata()); | 1611 callbacks->OnSuccess(this, this->metadata()); |
1619 } | 1612 } |
1620 | 1613 |
1621 void IndexedDBDatabaseImpl::RunVersionChangeTransaction( | 1614 void IndexedDBDatabase::RunVersionChangeTransaction( |
1622 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 1615 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, |
1623 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks, | 1616 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks, |
1624 int64 transaction_id, | 1617 int64 transaction_id, |
1625 int64 requested_version) { | 1618 int64 requested_version) { |
1626 | 1619 |
1627 DCHECK(callbacks); | 1620 DCHECK(callbacks); |
1628 DCHECK(database_callbacks_set_.has(database_callbacks)); | 1621 DCHECK(database_callbacks_set_.has(database_callbacks)); |
1629 if (ConnectionCount() > 1) { | 1622 if (ConnectionCount() > 1) { |
1630 // Front end ensures the event is not fired at connections that have | 1623 // Front end ensures the event is not fired at connections that have |
1631 // close_pending set. | 1624 // close_pending set. |
(...skipping 11 matching lines...) Expand all Loading... |
1643 | 1636 |
1644 DCHECK(!pending_run_version_change_transaction_call_); | 1637 DCHECK(!pending_run_version_change_transaction_call_); |
1645 pending_run_version_change_transaction_call_.reset(new PendingOpenCall( | 1638 pending_run_version_change_transaction_call_.reset(new PendingOpenCall( |
1646 callbacks, database_callbacks, transaction_id, requested_version)); | 1639 callbacks, database_callbacks, transaction_id, requested_version)); |
1647 return; | 1640 return; |
1648 } | 1641 } |
1649 RunVersionChangeTransactionFinal( | 1642 RunVersionChangeTransactionFinal( |
1650 callbacks, database_callbacks, transaction_id, requested_version); | 1643 callbacks, database_callbacks, transaction_id, requested_version); |
1651 } | 1644 } |
1652 | 1645 |
1653 void IndexedDBDatabaseImpl::RunVersionChangeTransactionFinal( | 1646 void IndexedDBDatabase::RunVersionChangeTransactionFinal( |
1654 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, | 1647 scoped_refptr<IndexedDBCallbacksWrapper> callbacks, |
1655 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks, | 1648 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks, |
1656 int64 transaction_id, | 1649 int64 transaction_id, |
1657 int64 requested_version) { | 1650 int64 requested_version) { |
1658 | 1651 |
1659 std::vector<int64> object_store_ids; | 1652 std::vector<int64> object_store_ids; |
1660 CreateTransaction(transaction_id, | 1653 CreateTransaction(transaction_id, |
1661 database_callbacks, | 1654 database_callbacks, |
1662 object_store_ids, | 1655 object_store_ids, |
1663 indexed_db::TRANSACTION_VERSION_CHANGE); | 1656 indexed_db::TRANSACTION_VERSION_CHANGE); |
1664 scoped_refptr<IndexedDBTransaction> transaction = | 1657 scoped_refptr<IndexedDBTransaction> transaction = |
1665 transactions_[transaction_id]; | 1658 transactions_[transaction_id]; |
1666 | 1659 |
1667 transaction->ScheduleTask( | 1660 transaction->ScheduleTask( |
1668 new VersionChangeOperation(this, | 1661 new VersionChangeOperation(this, |
1669 transaction_id, | 1662 transaction_id, |
1670 requested_version, | 1663 requested_version, |
1671 callbacks, | 1664 callbacks, |
1672 database_callbacks), | 1665 database_callbacks), |
1673 new VersionChangeAbortOperation( | 1666 new VersionChangeAbortOperation( |
1674 this, metadata_.version, metadata_.int_version)); | 1667 this, metadata_.version, metadata_.int_version)); |
1675 | 1668 |
1676 DCHECK(!pending_second_half_open_); | 1669 DCHECK(!pending_second_half_open_); |
1677 } | 1670 } |
1678 | 1671 |
1679 void IndexedDBDatabaseImpl::DeleteDatabase( | 1672 void IndexedDBDatabase::DeleteDatabase( |
1680 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { | 1673 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { |
1681 | 1674 |
1682 if (IsDeleteDatabaseBlocked()) { | 1675 if (IsDeleteDatabaseBlocked()) { |
1683 for (DatabaseCallbacksSet::const_iterator it = | 1676 for (DatabaseCallbacksSet::const_iterator it = |
1684 database_callbacks_set_.begin(); | 1677 database_callbacks_set_.begin(); |
1685 it != database_callbacks_set_.end(); | 1678 it != database_callbacks_set_.end(); |
1686 ++it) { | 1679 ++it) { |
1687 // Front end ensures the event is not fired at connections that have | 1680 // Front end ensures the event is not fired at connections that have |
1688 // close_pending set. | 1681 // close_pending set. |
1689 (*it)->OnVersionChange(metadata_.int_version, | 1682 (*it)->OnVersionChange(metadata_.int_version, |
1690 IndexedDBDatabaseMetadata::NO_INT_VERSION); | 1683 IndexedDBDatabaseMetadata::NO_INT_VERSION); |
1691 } | 1684 } |
1692 // TODO(jsbell): Only fire on_blocked if there are open | 1685 // TODO(jsbell): Only fire on_blocked if there are open |
1693 // connections after the VersionChangeEvents are received, not | 1686 // connections after the VersionChangeEvents are received, not |
1694 // just set up to fire. http://crbug.com/100123 | 1687 // just set up to fire. http://crbug.com/100123 |
1695 callbacks->OnBlocked(metadata_.int_version); | 1688 callbacks->OnBlocked(metadata_.int_version); |
1696 pending_delete_calls_.push_back(new PendingDeleteCall(callbacks)); | 1689 pending_delete_calls_.push_back(new PendingDeleteCall(callbacks)); |
1697 return; | 1690 return; |
1698 } | 1691 } |
1699 DeleteDatabaseFinal(callbacks); | 1692 DeleteDatabaseFinal(callbacks); |
1700 } | 1693 } |
1701 | 1694 |
1702 bool IndexedDBDatabaseImpl::IsDeleteDatabaseBlocked() const { | 1695 bool IndexedDBDatabase::IsDeleteDatabaseBlocked() const { |
1703 return !!ConnectionCount(); | 1696 return !!ConnectionCount(); |
1704 } | 1697 } |
1705 | 1698 |
1706 void IndexedDBDatabaseImpl::DeleteDatabaseFinal( | 1699 void IndexedDBDatabase::DeleteDatabaseFinal( |
1707 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { | 1700 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) { |
1708 DCHECK(!IsDeleteDatabaseBlocked()); | 1701 DCHECK(!IsDeleteDatabaseBlocked()); |
1709 DCHECK(backing_store_); | 1702 DCHECK(backing_store_); |
1710 if (!backing_store_->DeleteDatabase(metadata_.name)) { | 1703 if (!backing_store_->DeleteDatabase(metadata_.name)) { |
1711 callbacks->OnError(IndexedDBDatabaseError( | 1704 callbacks->OnError( |
1712 WebKit::WebIDBDatabaseExceptionUnknownError, | 1705 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, |
1713 "Internal error deleting database.")); | 1706 "Internal error deleting database.")); |
1714 return; | 1707 return; |
1715 } | 1708 } |
1716 metadata_.version = kNoStringVersion; | 1709 metadata_.version = kNoStringVersion; |
1717 metadata_.id = kInvalidId; | 1710 metadata_.id = kInvalidId; |
1718 metadata_.int_version = IndexedDBDatabaseMetadata::NO_INT_VERSION; | 1711 metadata_.int_version = IndexedDBDatabaseMetadata::NO_INT_VERSION; |
1719 metadata_.object_stores.clear(); | 1712 metadata_.object_stores.clear(); |
1720 callbacks->OnSuccess(); | 1713 callbacks->OnSuccess(); |
1721 } | 1714 } |
1722 | 1715 |
1723 void IndexedDBDatabaseImpl::Close( | 1716 void IndexedDBDatabase::Close( |
1724 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> callbacks) { | 1717 scoped_refptr<IndexedDBDatabaseCallbacksWrapper> callbacks) { |
1725 DCHECK(callbacks); | 1718 DCHECK(callbacks); |
1726 DCHECK(database_callbacks_set_.has(callbacks)); | 1719 DCHECK(database_callbacks_set_.has(callbacks)); |
1727 | 1720 |
1728 // Close outstanding transactions from the closing connection. This | 1721 // Close outstanding transactions from the closing connection. This |
1729 // can not happen if the close is requested by the connection itself | 1722 // can not happen if the close is requested by the connection itself |
1730 // as the front-end defers the close until all transactions are | 1723 // as the front-end defers the close until all transactions are |
1731 // complete, so something unusual has happened e.g. unexpected | 1724 // complete, so something unusual has happened e.g. unexpected |
1732 // process termination. | 1725 // process termination. |
1733 { | 1726 { |
(...skipping 12 matching lines...) Expand all Loading... |
1746 database_callbacks_set_.erase(callbacks); | 1739 database_callbacks_set_.erase(callbacks); |
1747 if (pending_second_half_open_ && | 1740 if (pending_second_half_open_ && |
1748 pending_second_half_open_->DatabaseCallbacks() == callbacks) { | 1741 pending_second_half_open_->DatabaseCallbacks() == callbacks) { |
1749 pending_second_half_open_->Callbacks()->OnError( | 1742 pending_second_half_open_->Callbacks()->OnError( |
1750 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionAbortError, | 1743 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionAbortError, |
1751 "The connection was closed.")); | 1744 "The connection was closed.")); |
1752 pending_second_half_open_.reset(); | 1745 pending_second_half_open_.reset(); |
1753 } | 1746 } |
1754 | 1747 |
1755 // process_pending_calls allows the inspector to process a pending open call | 1748 // process_pending_calls allows the inspector to process a pending open call |
1756 // and call close, reentering IndexedDBDatabaseImpl::close. Then the | 1749 // and call close, reentering IndexedDBDatabase::close. Then the |
1757 // backend would be removed both by the inspector closing its connection, and | 1750 // backend would be removed both by the inspector closing its connection, and |
1758 // by the connection that first called close. | 1751 // by the connection that first called close. |
1759 // To avoid that situation, don't proceed in case of reentrancy. | 1752 // To avoid that situation, don't proceed in case of reentrancy. |
1760 if (closing_connection_) | 1753 if (closing_connection_) |
1761 return; | 1754 return; |
1762 base::AutoReset<bool> ClosingConnection(&closing_connection_, true); | 1755 base::AutoReset<bool> ClosingConnection(&closing_connection_, true); |
1763 ProcessPendingCalls(); | 1756 ProcessPendingCalls(); |
1764 | 1757 |
1765 // TODO(jsbell): Add a test for the pending_open_calls_ cases below. | 1758 // TODO(jsbell): Add a test for the pending_open_calls_ cases below. |
1766 if (!ConnectionCount() && !pending_open_calls_.size() && | 1759 if (!ConnectionCount() && !pending_open_calls_.size() && |
(...skipping 17 matching lines...) Expand all Loading... |
1784 } | 1777 } |
1785 | 1778 |
1786 void DeleteObjectStoreAbortOperation::Perform( | 1779 void DeleteObjectStoreAbortOperation::Perform( |
1787 IndexedDBTransaction* transaction) { | 1780 IndexedDBTransaction* transaction) { |
1788 IDB_TRACE("DeleteObjectStoreAbortOperation"); | 1781 IDB_TRACE("DeleteObjectStoreAbortOperation"); |
1789 DCHECK(!transaction); | 1782 DCHECK(!transaction); |
1790 database_->AddObjectStore(object_store_metadata_, | 1783 database_->AddObjectStore(object_store_metadata_, |
1791 IndexedDBObjectStoreMetadata::kInvalidId); | 1784 IndexedDBObjectStoreMetadata::kInvalidId); |
1792 } | 1785 } |
1793 | 1786 |
1794 void IndexedDBDatabaseImpl::VersionChangeAbortOperation::Perform( | 1787 void IndexedDBDatabase::VersionChangeAbortOperation::Perform( |
1795 IndexedDBTransaction* transaction) { | 1788 IndexedDBTransaction* transaction) { |
1796 IDB_TRACE("VersionChangeAbortOperation"); | 1789 IDB_TRACE("VersionChangeAbortOperation"); |
1797 DCHECK(!transaction); | 1790 DCHECK(!transaction); |
1798 database_->metadata_.version = previous_version_; | 1791 database_->metadata_.version = previous_version_; |
1799 database_->metadata_.int_version = previous_int_version_; | 1792 database_->metadata_.int_version = previous_int_version_; |
1800 } | 1793 } |
1801 | 1794 |
1802 } // namespace content | 1795 } // namespace content |
OLD | NEW |