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

Side by Side Diff: content/browser/indexed_db/indexed_db_database.cc

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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) 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.h" 5 #include "content/browser/indexed_db/indexed_db_database.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
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_connection.h" 15 #include "content/browser/indexed_db/indexed_db_connection.h"
16 #include "content/browser/indexed_db/indexed_db_cursor.h" 16 #include "content/browser/indexed_db/indexed_db_cursor.h"
17 #include "content/browser/indexed_db/indexed_db_factory.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 "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" 24 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h"
25 25
26 using base::Int64ToString16; 26 using base::Int64ToString16;
27 using WebKit::WebIDBKeyTypeNumber; 27 using blink::WebIDBKeyTypeNumber;
28 28
29 namespace content { 29 namespace content {
30 30
31 // PendingOpenCall has a scoped_refptr<IndexedDBDatabaseCallbacks> because it 31 // PendingOpenCall has a scoped_refptr<IndexedDBDatabaseCallbacks> because it
32 // isn't a connection yet. 32 // isn't a connection yet.
33 class IndexedDBDatabase::PendingOpenCall { 33 class IndexedDBDatabase::PendingOpenCall {
34 public: 34 public:
35 PendingOpenCall(scoped_refptr<IndexedDBCallbacks> callbacks, 35 PendingOpenCall(scoped_refptr<IndexedDBCallbacks> callbacks,
36 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, 36 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
37 int64 transaction_id, 37 int64 transaction_id,
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 IndexedDBTransaction* transaction) { 316 IndexedDBTransaction* transaction) {
317 IDB_TRACE("IndexedDBDatabase::CreateObjectStoreOperation"); 317 IDB_TRACE("IndexedDBDatabase::CreateObjectStoreOperation");
318 if (!backing_store_->CreateObjectStore( 318 if (!backing_store_->CreateObjectStore(
319 transaction->BackingStoreTransaction(), 319 transaction->BackingStoreTransaction(),
320 transaction->database()->id(), 320 transaction->database()->id(),
321 object_store_metadata.id, 321 object_store_metadata.id,
322 object_store_metadata.name, 322 object_store_metadata.name,
323 object_store_metadata.key_path, 323 object_store_metadata.key_path,
324 object_store_metadata.auto_increment)) { 324 object_store_metadata.auto_increment)) {
325 transaction->Abort(IndexedDBDatabaseError( 325 transaction->Abort(IndexedDBDatabaseError(
326 WebKit::WebIDBDatabaseExceptionUnknownError, 326 blink::WebIDBDatabaseExceptionUnknownError,
327 ASCIIToUTF16("Internal error creating object store '") + 327 ASCIIToUTF16("Internal error creating object store '") +
328 object_store_metadata.name + ASCIIToUTF16("'."))); 328 object_store_metadata.name + ASCIIToUTF16("'.")));
329 return; 329 return;
330 } 330 }
331 } 331 }
332 332
333 void IndexedDBDatabase::DeleteObjectStore(int64 transaction_id, 333 void IndexedDBDatabase::DeleteObjectStore(int64 transaction_id,
334 int64 object_store_id) { 334 int64 object_store_id) {
335 IDB_TRACE("IndexedDBDatabase::DeleteObjectStore"); 335 IDB_TRACE("IndexedDBDatabase::DeleteObjectStore");
336 IndexedDBTransaction* transaction = GetTransaction(transaction_id); 336 IndexedDBTransaction* transaction = GetTransaction(transaction_id);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 transaction->database()->id(), 394 transaction->database()->id(),
395 object_store_id, 395 object_store_id,
396 index_metadata.id, 396 index_metadata.id,
397 index_metadata.name, 397 index_metadata.name,
398 index_metadata.key_path, 398 index_metadata.key_path,
399 index_metadata.unique, 399 index_metadata.unique,
400 index_metadata.multi_entry)) { 400 index_metadata.multi_entry)) {
401 string16 error_string = ASCIIToUTF16("Internal error creating index '") + 401 string16 error_string = ASCIIToUTF16("Internal error creating index '") +
402 index_metadata.name + ASCIIToUTF16("'."); 402 index_metadata.name + ASCIIToUTF16("'.");
403 transaction->Abort(IndexedDBDatabaseError( 403 transaction->Abort(IndexedDBDatabaseError(
404 WebKit::WebIDBDatabaseExceptionUnknownError, error_string)); 404 blink::WebIDBDatabaseExceptionUnknownError, error_string));
405 return; 405 return;
406 } 406 }
407 } 407 }
408 408
409 void IndexedDBDatabase::CreateIndexAbortOperation( 409 void IndexedDBDatabase::CreateIndexAbortOperation(
410 int64 object_store_id, 410 int64 object_store_id,
411 int64 index_id, 411 int64 index_id,
412 IndexedDBTransaction* transaction) { 412 IndexedDBTransaction* transaction) {
413 IDB_TRACE("IndexedDBDatabase::CreateIndexAbortOperation"); 413 IDB_TRACE("IndexedDBDatabase::CreateIndexAbortOperation");
414 DCHECK(!transaction); 414 DCHECK(!transaction);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 IndexedDBTransaction* transaction) { 448 IndexedDBTransaction* transaction) {
449 IDB_TRACE("IndexedDBDatabase::DeleteIndexOperation"); 449 IDB_TRACE("IndexedDBDatabase::DeleteIndexOperation");
450 bool ok = backing_store_->DeleteIndex(transaction->BackingStoreTransaction(), 450 bool ok = backing_store_->DeleteIndex(transaction->BackingStoreTransaction(),
451 transaction->database()->id(), 451 transaction->database()->id(),
452 object_store_id, 452 object_store_id,
453 index_metadata.id); 453 index_metadata.id);
454 if (!ok) { 454 if (!ok) {
455 string16 error_string = ASCIIToUTF16("Internal error deleting index '") + 455 string16 error_string = ASCIIToUTF16("Internal error deleting index '") +
456 index_metadata.name + ASCIIToUTF16("'."); 456 index_metadata.name + ASCIIToUTF16("'.");
457 transaction->Abort(IndexedDBDatabaseError( 457 transaction->Abort(IndexedDBDatabaseError(
458 WebKit::WebIDBDatabaseExceptionUnknownError, error_string)); 458 blink::WebIDBDatabaseExceptionUnknownError, error_string));
459 } 459 }
460 } 460 }
461 461
462 void IndexedDBDatabase::DeleteIndexAbortOperation( 462 void IndexedDBDatabase::DeleteIndexAbortOperation(
463 int64 object_store_id, 463 int64 object_store_id,
464 const IndexedDBIndexMetadata& index_metadata, 464 const IndexedDBIndexMetadata& index_metadata,
465 IndexedDBTransaction* transaction) { 465 IndexedDBTransaction* transaction) {
466 IDB_TRACE("IndexedDBDatabase::DeleteIndexAbortOperation"); 466 IDB_TRACE("IndexedDBDatabase::DeleteIndexAbortOperation");
467 DCHECK(!transaction); 467 DCHECK(!transaction);
468 AddIndex(object_store_id, index_metadata, IndexedDBIndexMetadata::kInvalidId); 468 AddIndex(object_store_id, index_metadata, IndexedDBIndexMetadata::kInvalidId);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 if (index_id == IndexedDBIndexMetadata::kInvalidId) { 581 if (index_id == IndexedDBIndexMetadata::kInvalidId) {
582 // Object Store Retrieval Operation 582 // Object Store Retrieval Operation
583 std::string value; 583 std::string value;
584 ok = backing_store_->GetRecord(transaction->BackingStoreTransaction(), 584 ok = backing_store_->GetRecord(transaction->BackingStoreTransaction(),
585 id(), 585 id(),
586 object_store_id, 586 object_store_id,
587 *key, 587 *key,
588 &value); 588 &value);
589 if (!ok) { 589 if (!ok) {
590 callbacks->OnError( 590 callbacks->OnError(
591 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, 591 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError,
592 "Internal error in GetRecord.")); 592 "Internal error in GetRecord."));
593 return; 593 return;
594 } 594 }
595 595
596 if (value.empty()) { 596 if (value.empty()) {
597 callbacks->OnSuccess(); 597 callbacks->OnSuccess();
598 return; 598 return;
599 } 599 }
600 600
601 if (object_store_metadata.auto_increment && 601 if (object_store_metadata.auto_increment &&
602 !object_store_metadata.key_path.IsNull()) { 602 !object_store_metadata.key_path.IsNull()) {
603 callbacks->OnSuccess(&value, *key, object_store_metadata.key_path); 603 callbacks->OnSuccess(&value, *key, object_store_metadata.key_path);
604 return; 604 return;
605 } 605 }
606 606
607 callbacks->OnSuccess(&value); 607 callbacks->OnSuccess(&value);
608 return; 608 return;
609 } 609 }
610 610
611 // From here we are dealing only with indexes. 611 // From here we are dealing only with indexes.
612 ok = backing_store_->GetPrimaryKeyViaIndex( 612 ok = backing_store_->GetPrimaryKeyViaIndex(
613 transaction->BackingStoreTransaction(), 613 transaction->BackingStoreTransaction(),
614 id(), 614 id(),
615 object_store_id, 615 object_store_id,
616 index_id, 616 index_id,
617 *key, 617 *key,
618 &primary_key); 618 &primary_key);
619 if (!ok) { 619 if (!ok) {
620 callbacks->OnError( 620 callbacks->OnError(
621 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, 621 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError,
622 "Internal error in GetPrimaryKeyViaIndex.")); 622 "Internal error in GetPrimaryKeyViaIndex."));
623 return; 623 return;
624 } 624 }
625 if (!primary_key) { 625 if (!primary_key) {
626 callbacks->OnSuccess(); 626 callbacks->OnSuccess();
627 return; 627 return;
628 } 628 }
629 if (cursor_type == indexed_db::CURSOR_KEY_ONLY) { 629 if (cursor_type == indexed_db::CURSOR_KEY_ONLY) {
630 // Index Value Retrieval Operation 630 // Index Value Retrieval Operation
631 callbacks->OnSuccess(*primary_key); 631 callbacks->OnSuccess(*primary_key);
632 return; 632 return;
633 } 633 }
634 634
635 // Index Referenced Value Retrieval Operation 635 // Index Referenced Value Retrieval Operation
636 std::string value; 636 std::string value;
637 ok = backing_store_->GetRecord(transaction->BackingStoreTransaction(), 637 ok = backing_store_->GetRecord(transaction->BackingStoreTransaction(),
638 id(), 638 id(),
639 object_store_id, 639 object_store_id,
640 *primary_key, 640 *primary_key,
641 &value); 641 &value);
642 if (!ok) { 642 if (!ok) {
643 callbacks->OnError( 643 callbacks->OnError(
644 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, 644 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError,
645 "Internal error in GetRecord.")); 645 "Internal error in GetRecord."));
646 return; 646 return;
647 } 647 }
648 648
649 if (value.empty()) { 649 if (value.empty()) {
650 callbacks->OnSuccess(); 650 callbacks->OnSuccess();
651 return; 651 return;
652 } 652 }
653 if (object_store_metadata.auto_increment && 653 if (object_store_metadata.auto_increment &&
654 !object_store_metadata.key_path.IsNull()) { 654 !object_store_metadata.key_path.IsNull()) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 DCHECK(object_store.auto_increment || params->key->IsValid()); 754 DCHECK(object_store.auto_increment || params->key->IsValid());
755 755
756 scoped_ptr<IndexedDBKey> key; 756 scoped_ptr<IndexedDBKey> key;
757 if (params->put_mode != IndexedDBDatabase::CURSOR_UPDATE && 757 if (params->put_mode != IndexedDBDatabase::CURSOR_UPDATE &&
758 object_store.auto_increment && !params->key->IsValid()) { 758 object_store.auto_increment && !params->key->IsValid()) {
759 scoped_ptr<IndexedDBKey> auto_inc_key = 759 scoped_ptr<IndexedDBKey> auto_inc_key =
760 GenerateKey(backing_store_, transaction, id(), params->object_store_id); 760 GenerateKey(backing_store_, transaction, id(), params->object_store_id);
761 key_was_generated = true; 761 key_was_generated = true;
762 if (!auto_inc_key->IsValid()) { 762 if (!auto_inc_key->IsValid()) {
763 params->callbacks->OnError( 763 params->callbacks->OnError(
764 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionConstraintError, 764 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionConstraintError,
765 "Maximum key generator value reached.")); 765 "Maximum key generator value reached."));
766 return; 766 return;
767 } 767 }
768 key = auto_inc_key.Pass(); 768 key = auto_inc_key.Pass();
769 } else { 769 } else {
770 key = params->key.Pass(); 770 key = params->key.Pass();
771 } 771 }
772 772
773 DCHECK(key->IsValid()); 773 DCHECK(key->IsValid());
774 774
775 IndexedDBBackingStore::RecordIdentifier record_identifier; 775 IndexedDBBackingStore::RecordIdentifier record_identifier;
776 if (params->put_mode == IndexedDBDatabase::ADD_ONLY) { 776 if (params->put_mode == IndexedDBDatabase::ADD_ONLY) {
777 bool found = false; 777 bool found = false;
778 bool ok = backing_store_->KeyExistsInObjectStore( 778 bool ok = backing_store_->KeyExistsInObjectStore(
779 transaction->BackingStoreTransaction(), 779 transaction->BackingStoreTransaction(),
780 id(), 780 id(),
781 params->object_store_id, 781 params->object_store_id,
782 *key, 782 *key,
783 &record_identifier, 783 &record_identifier,
784 &found); 784 &found);
785 if (!ok) { 785 if (!ok) {
786 params->callbacks->OnError( 786 params->callbacks->OnError(
787 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, 787 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError,
788 "Internal error checking key existence.")); 788 "Internal error checking key existence."));
789 return; 789 return;
790 } 790 }
791 if (found) { 791 if (found) {
792 params->callbacks->OnError( 792 params->callbacks->OnError(
793 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionConstraintError, 793 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionConstraintError,
794 "Key already exists in the object store.")); 794 "Key already exists in the object store."));
795 return; 795 return;
796 } 796 }
797 } 797 }
798 798
799 ScopedVector<IndexWriter> index_writers; 799 ScopedVector<IndexWriter> index_writers;
800 string16 error_message; 800 string16 error_message;
801 bool obeys_constraints = false; 801 bool obeys_constraints = false;
802 bool backing_store_success = MakeIndexWriters(transaction, 802 bool backing_store_success = MakeIndexWriters(transaction,
803 backing_store_.get(), 803 backing_store_.get(),
804 id(), 804 id(),
805 object_store, 805 object_store,
806 *key, 806 *key,
807 key_was_generated, 807 key_was_generated,
808 params->index_ids, 808 params->index_ids,
809 params->index_keys, 809 params->index_keys,
810 &index_writers, 810 &index_writers,
811 &error_message, 811 &error_message,
812 &obeys_constraints); 812 &obeys_constraints);
813 if (!backing_store_success) { 813 if (!backing_store_success) {
814 params->callbacks->OnError(IndexedDBDatabaseError( 814 params->callbacks->OnError(IndexedDBDatabaseError(
815 WebKit::WebIDBDatabaseExceptionUnknownError, 815 blink::WebIDBDatabaseExceptionUnknownError,
816 "Internal error: backing store error updating index keys.")); 816 "Internal error: backing store error updating index keys."));
817 return; 817 return;
818 } 818 }
819 if (!obeys_constraints) { 819 if (!obeys_constraints) {
820 params->callbacks->OnError(IndexedDBDatabaseError( 820 params->callbacks->OnError(IndexedDBDatabaseError(
821 WebKit::WebIDBDatabaseExceptionConstraintError, error_message)); 821 blink::WebIDBDatabaseExceptionConstraintError, error_message));
822 return; 822 return;
823 } 823 }
824 824
825 // Before this point, don't do any mutation. After this point, rollback the 825 // Before this point, don't do any mutation. After this point, rollback the
826 // transaction in case of error. 826 // transaction in case of error.
827 backing_store_success = 827 backing_store_success =
828 backing_store_->PutRecord(transaction->BackingStoreTransaction(), 828 backing_store_->PutRecord(transaction->BackingStoreTransaction(),
829 id(), 829 id(),
830 params->object_store_id, 830 params->object_store_id,
831 *key, 831 *key,
832 params->value, 832 params->value,
833 &record_identifier); 833 &record_identifier);
834 if (!backing_store_success) { 834 if (!backing_store_success) {
835 params->callbacks->OnError(IndexedDBDatabaseError( 835 params->callbacks->OnError(IndexedDBDatabaseError(
836 WebKit::WebIDBDatabaseExceptionUnknownError, 836 blink::WebIDBDatabaseExceptionUnknownError,
837 "Internal error: backing store error performing put/add.")); 837 "Internal error: backing store error performing put/add."));
838 return; 838 return;
839 } 839 }
840 840
841 for (size_t i = 0; i < index_writers.size(); ++i) { 841 for (size_t i = 0; i < index_writers.size(); ++i) {
842 IndexWriter* index_writer = index_writers[i]; 842 IndexWriter* index_writer = index_writers[i];
843 index_writer->WriteIndexKeys(record_identifier, 843 index_writer->WriteIndexKeys(record_identifier,
844 backing_store_.get(), 844 backing_store_.get(),
845 transaction->BackingStoreTransaction(), 845 transaction->BackingStoreTransaction(),
846 id(), 846 id(),
847 params->object_store_id); 847 params->object_store_id);
848 } 848 }
849 849
850 if (object_store.auto_increment && 850 if (object_store.auto_increment &&
851 params->put_mode != IndexedDBDatabase::CURSOR_UPDATE && 851 params->put_mode != IndexedDBDatabase::CURSOR_UPDATE &&
852 key->type() == WebIDBKeyTypeNumber) { 852 key->type() == WebIDBKeyTypeNumber) {
853 bool ok = UpdateKeyGenerator(backing_store_, 853 bool ok = UpdateKeyGenerator(backing_store_,
854 transaction, 854 transaction,
855 id(), 855 id(),
856 params->object_store_id, 856 params->object_store_id,
857 *key, 857 *key,
858 !key_was_generated); 858 !key_was_generated);
859 if (!ok) { 859 if (!ok) {
860 params->callbacks->OnError( 860 params->callbacks->OnError(
861 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, 861 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError,
862 "Internal error updating key generator.")); 862 "Internal error updating key generator."));
863 return; 863 return;
864 } 864 }
865 } 865 }
866 866
867 params->callbacks->OnSuccess(*key); 867 params->callbacks->OnSuccess(*key);
868 } 868 }
869 869
870 void IndexedDBDatabase::SetIndexKeys(int64 transaction_id, 870 void IndexedDBDatabase::SetIndexKeys(int64 transaction_id,
871 int64 object_store_id, 871 int64 object_store_id,
(...skipping 12 matching lines...) Expand all
884 bool found = false; 884 bool found = false;
885 bool ok = backing_store_->KeyExistsInObjectStore( 885 bool ok = backing_store_->KeyExistsInObjectStore(
886 transaction->BackingStoreTransaction(), 886 transaction->BackingStoreTransaction(),
887 metadata_.id, 887 metadata_.id,
888 object_store_id, 888 object_store_id,
889 *primary_key, 889 *primary_key,
890 &record_identifier, 890 &record_identifier,
891 &found); 891 &found);
892 if (!ok) { 892 if (!ok) {
893 transaction->Abort( 893 transaction->Abort(
894 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, 894 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError,
895 "Internal error setting index keys.")); 895 "Internal error setting index keys."));
896 return; 896 return;
897 } 897 }
898 if (!found) { 898 if (!found) {
899 transaction->Abort(IndexedDBDatabaseError( 899 transaction->Abort(IndexedDBDatabaseError(
900 WebKit::WebIDBDatabaseExceptionUnknownError, 900 blink::WebIDBDatabaseExceptionUnknownError,
901 "Internal error setting index keys for object store.")); 901 "Internal error setting index keys for object store."));
902 return; 902 return;
903 } 903 }
904 904
905 ScopedVector<IndexWriter> index_writers; 905 ScopedVector<IndexWriter> index_writers;
906 string16 error_message; 906 string16 error_message;
907 bool obeys_constraints = false; 907 bool obeys_constraints = false;
908 DCHECK(metadata_.object_stores.find(object_store_id) != 908 DCHECK(metadata_.object_stores.find(object_store_id) !=
909 metadata_.object_stores.end()); 909 metadata_.object_stores.end());
910 const IndexedDBObjectStoreMetadata& object_store_metadata = 910 const IndexedDBObjectStoreMetadata& object_store_metadata =
911 metadata_.object_stores[object_store_id]; 911 metadata_.object_stores[object_store_id];
912 bool backing_store_success = MakeIndexWriters(transaction, 912 bool backing_store_success = MakeIndexWriters(transaction,
913 backing_store_, 913 backing_store_,
914 id(), 914 id(),
915 object_store_metadata, 915 object_store_metadata,
916 *primary_key, 916 *primary_key,
917 false, 917 false,
918 index_ids, 918 index_ids,
919 index_keys, 919 index_keys,
920 &index_writers, 920 &index_writers,
921 &error_message, 921 &error_message,
922 &obeys_constraints); 922 &obeys_constraints);
923 if (!backing_store_success) { 923 if (!backing_store_success) {
924 transaction->Abort(IndexedDBDatabaseError( 924 transaction->Abort(IndexedDBDatabaseError(
925 WebKit::WebIDBDatabaseExceptionUnknownError, 925 blink::WebIDBDatabaseExceptionUnknownError,
926 "Internal error: backing store error updating index keys.")); 926 "Internal error: backing store error updating index keys."));
927 return; 927 return;
928 } 928 }
929 if (!obeys_constraints) { 929 if (!obeys_constraints) {
930 transaction->Abort(IndexedDBDatabaseError( 930 transaction->Abort(IndexedDBDatabaseError(
931 WebKit::WebIDBDatabaseExceptionConstraintError, error_message)); 931 blink::WebIDBDatabaseExceptionConstraintError, error_message));
932 return; 932 return;
933 } 933 }
934 934
935 for (size_t i = 0; i < index_writers.size(); ++i) { 935 for (size_t i = 0; i < index_writers.size(); ++i) {
936 IndexWriter* index_writer = index_writers[i]; 936 IndexWriter* index_writer = index_writers[i];
937 index_writer->WriteIndexKeys(record_identifier, 937 index_writer->WriteIndexKeys(record_identifier,
938 backing_store_, 938 backing_store_,
939 transaction->BackingStoreTransaction(), 939 transaction->BackingStoreTransaction(),
940 id(), 940 id(),
941 object_store_id); 941 object_store_id);
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 *key_range, 1168 *key_range,
1169 indexed_db::CURSOR_NEXT); 1169 indexed_db::CURSOR_NEXT);
1170 if (backing_store_cursor) { 1170 if (backing_store_cursor) {
1171 do { 1171 do {
1172 if (!backing_store_->DeleteRecord( 1172 if (!backing_store_->DeleteRecord(
1173 transaction->BackingStoreTransaction(), 1173 transaction->BackingStoreTransaction(),
1174 id(), 1174 id(),
1175 object_store_id, 1175 object_store_id,
1176 backing_store_cursor->record_identifier())) { 1176 backing_store_cursor->record_identifier())) {
1177 callbacks->OnError( 1177 callbacks->OnError(
1178 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, 1178 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError,
1179 "Internal error deleting data in range")); 1179 "Internal error deleting data in range"));
1180 return; 1180 return;
1181 } 1181 }
1182 } while (backing_store_cursor->Continue()); 1182 } while (backing_store_cursor->Continue());
1183 } 1183 }
1184 1184
1185 callbacks->OnSuccess(); 1185 callbacks->OnSuccess();
1186 } 1186 }
1187 1187
1188 void IndexedDBDatabase::Clear(int64 transaction_id, 1188 void IndexedDBDatabase::Clear(int64 transaction_id,
(...skipping 13 matching lines...) Expand all
1202 } 1202 }
1203 1203
1204 void IndexedDBDatabase::ClearOperation( 1204 void IndexedDBDatabase::ClearOperation(
1205 int64 object_store_id, 1205 int64 object_store_id,
1206 scoped_refptr<IndexedDBCallbacks> callbacks, 1206 scoped_refptr<IndexedDBCallbacks> callbacks,
1207 IndexedDBTransaction* transaction) { 1207 IndexedDBTransaction* transaction) {
1208 IDB_TRACE("IndexedDBDatabase::ObjectStoreClearOperation"); 1208 IDB_TRACE("IndexedDBDatabase::ObjectStoreClearOperation");
1209 if (!backing_store_->ClearObjectStore( 1209 if (!backing_store_->ClearObjectStore(
1210 transaction->BackingStoreTransaction(), id(), object_store_id)) { 1210 transaction->BackingStoreTransaction(), id(), object_store_id)) {
1211 callbacks->OnError( 1211 callbacks->OnError(
1212 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, 1212 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError,
1213 "Internal error clearing object store")); 1213 "Internal error clearing object store"));
1214 return; 1214 return;
1215 } 1215 }
1216 callbacks->OnSuccess(); 1216 callbacks->OnSuccess();
1217 } 1217 }
1218 1218
1219 void IndexedDBDatabase::DeleteObjectStoreOperation( 1219 void IndexedDBDatabase::DeleteObjectStoreOperation(
1220 const IndexedDBObjectStoreMetadata& object_store_metadata, 1220 const IndexedDBObjectStoreMetadata& object_store_metadata,
1221 IndexedDBTransaction* transaction) { 1221 IndexedDBTransaction* transaction) {
1222 IDB_TRACE("IndexedDBDatabase::DeleteObjectStoreOperation"); 1222 IDB_TRACE("IndexedDBDatabase::DeleteObjectStoreOperation");
1223 bool ok = 1223 bool ok =
1224 backing_store_->DeleteObjectStore(transaction->BackingStoreTransaction(), 1224 backing_store_->DeleteObjectStore(transaction->BackingStoreTransaction(),
1225 transaction->database()->id(), 1225 transaction->database()->id(),
1226 object_store_metadata.id); 1226 object_store_metadata.id);
1227 if (!ok) { 1227 if (!ok) {
1228 string16 error_string = 1228 string16 error_string =
1229 ASCIIToUTF16("Internal error deleting object store '") + 1229 ASCIIToUTF16("Internal error deleting object store '") +
1230 object_store_metadata.name + ASCIIToUTF16("'."); 1230 object_store_metadata.name + ASCIIToUTF16("'.");
1231 transaction->Abort(IndexedDBDatabaseError( 1231 transaction->Abort(IndexedDBDatabaseError(
1232 WebKit::WebIDBDatabaseExceptionUnknownError, error_string)); 1232 blink::WebIDBDatabaseExceptionUnknownError, error_string));
1233 } 1233 }
1234 } 1234 }
1235 1235
1236 void IndexedDBDatabase::VersionChangeOperation( 1236 void IndexedDBDatabase::VersionChangeOperation(
1237 int64 version, 1237 int64 version,
1238 scoped_refptr<IndexedDBCallbacks> callbacks, 1238 scoped_refptr<IndexedDBCallbacks> callbacks,
1239 scoped_ptr<IndexedDBConnection> connection, 1239 scoped_ptr<IndexedDBConnection> connection,
1240 WebKit::WebIDBCallbacks::DataLoss data_loss, 1240 blink::WebIDBCallbacks::DataLoss data_loss,
1241 std::string data_loss_message, 1241 std::string data_loss_message,
1242 IndexedDBTransaction* transaction) { 1242 IndexedDBTransaction* transaction) {
1243 IDB_TRACE("IndexedDBDatabase::VersionChangeOperation"); 1243 IDB_TRACE("IndexedDBDatabase::VersionChangeOperation");
1244 int64 old_version = metadata_.int_version; 1244 int64 old_version = metadata_.int_version;
1245 DCHECK_GT(version, old_version); 1245 DCHECK_GT(version, old_version);
1246 metadata_.int_version = version; 1246 metadata_.int_version = version;
1247 if (!backing_store_->UpdateIDBDatabaseIntVersion( 1247 if (!backing_store_->UpdateIDBDatabaseIntVersion(
1248 transaction->BackingStoreTransaction(), 1248 transaction->BackingStoreTransaction(),
1249 id(), 1249 id(),
1250 metadata_.int_version)) { 1250 metadata_.int_version)) {
1251 IndexedDBDatabaseError error( 1251 IndexedDBDatabaseError error(
1252 WebKit::WebIDBDatabaseExceptionUnknownError, 1252 blink::WebIDBDatabaseExceptionUnknownError,
1253 ASCIIToUTF16( 1253 ASCIIToUTF16(
1254 "Internal error writing data to stable storage when " 1254 "Internal error writing data to stable storage when "
1255 "updating version.")); 1255 "updating version."));
1256 callbacks->OnError(error); 1256 callbacks->OnError(error);
1257 transaction->Abort(error); 1257 transaction->Abort(error);
1258 return; 1258 return;
1259 } 1259 }
1260 DCHECK(!pending_second_half_open_); 1260 DCHECK(!pending_second_half_open_);
1261 pending_second_half_open_.reset(new PendingSuccessCall( 1261 pending_second_half_open_.reset(new PendingSuccessCall(
1262 callbacks, connection.get(), transaction->id(), version)); 1262 callbacks, connection.get(), transaction->id(), version));
(...skipping 18 matching lines...) Expand all
1281 DCHECK_EQ(transaction, running_version_change_transaction_); 1281 DCHECK_EQ(transaction, running_version_change_transaction_);
1282 running_version_change_transaction_ = NULL; 1282 running_version_change_transaction_ = NULL;
1283 } 1283 }
1284 } 1284 }
1285 1285
1286 void IndexedDBDatabase::TransactionFinishedAndAbortFired( 1286 void IndexedDBDatabase::TransactionFinishedAndAbortFired(
1287 IndexedDBTransaction* transaction) { 1287 IndexedDBTransaction* transaction) {
1288 if (transaction->mode() == indexed_db::TRANSACTION_VERSION_CHANGE) { 1288 if (transaction->mode() == indexed_db::TRANSACTION_VERSION_CHANGE) {
1289 if (pending_second_half_open_) { 1289 if (pending_second_half_open_) {
1290 pending_second_half_open_->Callbacks()->OnError( 1290 pending_second_half_open_->Callbacks()->OnError(
1291 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionAbortError, 1291 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionAbortError,
1292 "Version change transaction was aborted in " 1292 "Version change transaction was aborted in "
1293 "upgradeneeded event handler.")); 1293 "upgradeneeded event handler."));
1294 pending_second_half_open_.reset(); 1294 pending_second_half_open_.reset();
1295 } 1295 }
1296 ProcessPendingCalls(); 1296 ProcessPendingCalls();
1297 } 1297 }
1298 } 1298 }
1299 1299
1300 void IndexedDBDatabase::TransactionFinishedAndCompleteFired( 1300 void IndexedDBDatabase::TransactionFinishedAndCompleteFired(
1301 IndexedDBTransaction* transaction) { 1301 IndexedDBTransaction* transaction) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 return !pending_delete_calls_.empty() || 1414 return !pending_delete_calls_.empty() ||
1415 running_version_change_transaction_ || 1415 running_version_change_transaction_ ||
1416 pending_run_version_change_transaction_call_; 1416 pending_run_version_change_transaction_call_;
1417 } 1417 }
1418 1418
1419 void IndexedDBDatabase::OpenConnection( 1419 void IndexedDBDatabase::OpenConnection(
1420 scoped_refptr<IndexedDBCallbacks> callbacks, 1420 scoped_refptr<IndexedDBCallbacks> callbacks,
1421 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, 1421 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
1422 int64 transaction_id, 1422 int64 transaction_id,
1423 int64 version) { 1423 int64 version) {
1424 const WebKit::WebIDBCallbacks::DataLoss kDataLoss = 1424 const blink::WebIDBCallbacks::DataLoss kDataLoss =
1425 WebKit::WebIDBCallbacks::DataLossNone; 1425 blink::WebIDBCallbacks::DataLossNone;
1426 OpenConnection( 1426 OpenConnection(
1427 callbacks, database_callbacks, transaction_id, version, kDataLoss, ""); 1427 callbacks, database_callbacks, transaction_id, version, kDataLoss, "");
1428 } 1428 }
1429 1429
1430 void IndexedDBDatabase::OpenConnection( 1430 void IndexedDBDatabase::OpenConnection(
1431 scoped_refptr<IndexedDBCallbacks> callbacks, 1431 scoped_refptr<IndexedDBCallbacks> callbacks,
1432 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks, 1432 scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
1433 int64 transaction_id, 1433 int64 transaction_id,
1434 int64 version, 1434 int64 version,
1435 WebKit::WebIDBCallbacks::DataLoss data_loss, 1435 blink::WebIDBCallbacks::DataLoss data_loss,
1436 std::string data_loss_message) { 1436 std::string data_loss_message) {
1437 DCHECK(backing_store_); 1437 DCHECK(backing_store_);
1438 1438
1439 // TODO(jsbell): Should have a priority queue so that higher version 1439 // TODO(jsbell): Should have a priority queue so that higher version
1440 // requests are processed first. http://crbug.com/225850 1440 // requests are processed first. http://crbug.com/225850
1441 if (IsOpenConnectionBlocked()) { 1441 if (IsOpenConnectionBlocked()) {
1442 // The backing store only detects data loss when it is first opened. The 1442 // The backing store only detects data loss when it is first opened. The
1443 // presence of existing connections means we didn't even check for data loss 1443 // presence of existing connections means we didn't even check for data loss
1444 // so there'd better not be any. 1444 // so there'd better not be any.
1445 DCHECK_NE(WebKit::WebIDBCallbacks::DataLossTotal, data_loss); 1445 DCHECK_NE(blink::WebIDBCallbacks::DataLossTotal, data_loss);
1446 pending_open_calls_.push_back(new PendingOpenCall( 1446 pending_open_calls_.push_back(new PendingOpenCall(
1447 callbacks, database_callbacks, transaction_id, version)); 1447 callbacks, database_callbacks, transaction_id, version));
1448 return; 1448 return;
1449 } 1449 }
1450 1450
1451 if (metadata_.id == kInvalidId) { 1451 if (metadata_.id == kInvalidId) {
1452 // The database was deleted then immediately re-opened; OpenInternal() 1452 // The database was deleted then immediately re-opened; OpenInternal()
1453 // recreates it in the backing store. 1453 // recreates it in the backing store.
1454 if (OpenInternal()) { 1454 if (OpenInternal()) {
1455 DCHECK_EQ(IndexedDBDatabaseMetadata::NO_INT_VERSION, 1455 DCHECK_EQ(IndexedDBDatabaseMetadata::NO_INT_VERSION,
1456 metadata_.int_version); 1456 metadata_.int_version);
1457 } else { 1457 } else {
1458 string16 message; 1458 string16 message;
1459 if (version == IndexedDBDatabaseMetadata::NO_INT_VERSION) 1459 if (version == IndexedDBDatabaseMetadata::NO_INT_VERSION)
1460 message = ASCIIToUTF16( 1460 message = ASCIIToUTF16(
1461 "Internal error opening database with no version specified."); 1461 "Internal error opening database with no version specified.");
1462 else 1462 else
1463 message = 1463 message =
1464 ASCIIToUTF16("Internal error opening database with version ") + 1464 ASCIIToUTF16("Internal error opening database with version ") +
1465 Int64ToString16(version); 1465 Int64ToString16(version);
1466 callbacks->OnError(IndexedDBDatabaseError( 1466 callbacks->OnError(IndexedDBDatabaseError(
1467 WebKit::WebIDBDatabaseExceptionUnknownError, message)); 1467 blink::WebIDBDatabaseExceptionUnknownError, message));
1468 return; 1468 return;
1469 } 1469 }
1470 } 1470 }
1471 1471
1472 // We infer that the database didn't exist from its lack of either type of 1472 // We infer that the database didn't exist from its lack of either type of
1473 // version. 1473 // version.
1474 bool is_new_database = 1474 bool is_new_database =
1475 metadata_.version == kNoStringVersion && 1475 metadata_.version == kNoStringVersion &&
1476 metadata_.int_version == IndexedDBDatabaseMetadata::NO_INT_VERSION; 1476 metadata_.int_version == IndexedDBDatabaseMetadata::NO_INT_VERSION;
1477 1477
(...skipping 26 matching lines...) Expand all
1504 RunVersionChangeTransaction(callbacks, 1504 RunVersionChangeTransaction(callbacks,
1505 connection.Pass(), 1505 connection.Pass(),
1506 transaction_id, 1506 transaction_id,
1507 version, 1507 version,
1508 data_loss, 1508 data_loss,
1509 data_loss_message); 1509 data_loss_message);
1510 return; 1510 return;
1511 } 1511 }
1512 if (version < metadata_.int_version) { 1512 if (version < metadata_.int_version) {
1513 callbacks->OnError(IndexedDBDatabaseError( 1513 callbacks->OnError(IndexedDBDatabaseError(
1514 WebKit::WebIDBDatabaseExceptionVersionError, 1514 blink::WebIDBDatabaseExceptionVersionError,
1515 ASCIIToUTF16("The requested version (") + Int64ToString16(version) + 1515 ASCIIToUTF16("The requested version (") + Int64ToString16(version) +
1516 ASCIIToUTF16(") is less than the existing version (") + 1516 ASCIIToUTF16(") is less than the existing version (") +
1517 Int64ToString16(metadata_.int_version) + ASCIIToUTF16(")."))); 1517 Int64ToString16(metadata_.int_version) + ASCIIToUTF16(").")));
1518 return; 1518 return;
1519 } 1519 }
1520 DCHECK_EQ(version, metadata_.int_version); 1520 DCHECK_EQ(version, metadata_.int_version);
1521 connections_.insert(connection.get()); 1521 connections_.insert(connection.get());
1522 callbacks->OnSuccess(connection.Pass(), this->metadata()); 1522 callbacks->OnSuccess(connection.Pass(), this->metadata());
1523 } 1523 }
1524 1524
1525 void IndexedDBDatabase::RunVersionChangeTransaction( 1525 void IndexedDBDatabase::RunVersionChangeTransaction(
1526 scoped_refptr<IndexedDBCallbacks> callbacks, 1526 scoped_refptr<IndexedDBCallbacks> callbacks,
1527 scoped_ptr<IndexedDBConnection> connection, 1527 scoped_ptr<IndexedDBConnection> connection,
1528 int64 transaction_id, 1528 int64 transaction_id,
1529 int64 requested_version, 1529 int64 requested_version,
1530 WebKit::WebIDBCallbacks::DataLoss data_loss, 1530 blink::WebIDBCallbacks::DataLoss data_loss,
1531 std::string data_loss_message) { 1531 std::string data_loss_message) {
1532 1532
1533 DCHECK(callbacks); 1533 DCHECK(callbacks);
1534 DCHECK(connections_.count(connection.get())); 1534 DCHECK(connections_.count(connection.get()));
1535 if (ConnectionCount() > 1) { 1535 if (ConnectionCount() > 1) {
1536 DCHECK_NE(WebKit::WebIDBCallbacks::DataLossTotal, data_loss); 1536 DCHECK_NE(blink::WebIDBCallbacks::DataLossTotal, data_loss);
1537 // Front end ensures the event is not fired at connections that have 1537 // Front end ensures the event is not fired at connections that have
1538 // close_pending set. 1538 // close_pending set.
1539 for (ConnectionSet::const_iterator it = connections_.begin(); 1539 for (ConnectionSet::const_iterator it = connections_.begin();
1540 it != connections_.end(); 1540 it != connections_.end();
1541 ++it) { 1541 ++it) {
1542 if (*it != connection.get()) { 1542 if (*it != connection.get()) {
1543 (*it)->callbacks()->OnVersionChange(metadata_.int_version, 1543 (*it)->callbacks()->OnVersionChange(metadata_.int_version,
1544 requested_version); 1544 requested_version);
1545 } 1545 }
1546 } 1546 }
(...skipping 13 matching lines...) Expand all
1560 requested_version, 1560 requested_version,
1561 data_loss, 1561 data_loss,
1562 data_loss_message); 1562 data_loss_message);
1563 } 1563 }
1564 1564
1565 void IndexedDBDatabase::RunVersionChangeTransactionFinal( 1565 void IndexedDBDatabase::RunVersionChangeTransactionFinal(
1566 scoped_refptr<IndexedDBCallbacks> callbacks, 1566 scoped_refptr<IndexedDBCallbacks> callbacks,
1567 scoped_ptr<IndexedDBConnection> connection, 1567 scoped_ptr<IndexedDBConnection> connection,
1568 int64 transaction_id, 1568 int64 transaction_id,
1569 int64 requested_version) { 1569 int64 requested_version) {
1570 const WebKit::WebIDBCallbacks::DataLoss kDataLoss = 1570 const blink::WebIDBCallbacks::DataLoss kDataLoss =
1571 WebKit::WebIDBCallbacks::DataLossNone; 1571 blink::WebIDBCallbacks::DataLossNone;
1572 RunVersionChangeTransactionFinal(callbacks, 1572 RunVersionChangeTransactionFinal(callbacks,
1573 connection.Pass(), 1573 connection.Pass(),
1574 transaction_id, 1574 transaction_id,
1575 requested_version, 1575 requested_version,
1576 kDataLoss, 1576 kDataLoss,
1577 ""); 1577 "");
1578 } 1578 }
1579 1579
1580 void IndexedDBDatabase::RunVersionChangeTransactionFinal( 1580 void IndexedDBDatabase::RunVersionChangeTransactionFinal(
1581 scoped_refptr<IndexedDBCallbacks> callbacks, 1581 scoped_refptr<IndexedDBCallbacks> callbacks,
1582 scoped_ptr<IndexedDBConnection> connection, 1582 scoped_ptr<IndexedDBConnection> connection,
1583 int64 transaction_id, 1583 int64 transaction_id,
1584 int64 requested_version, 1584 int64 requested_version,
1585 WebKit::WebIDBCallbacks::DataLoss data_loss, 1585 blink::WebIDBCallbacks::DataLoss data_loss,
1586 std::string data_loss_message) { 1586 std::string data_loss_message) {
1587 1587
1588 std::vector<int64> object_store_ids; 1588 std::vector<int64> object_store_ids;
1589 CreateTransaction(transaction_id, 1589 CreateTransaction(transaction_id,
1590 connection.get(), 1590 connection.get(),
1591 object_store_ids, 1591 object_store_ids,
1592 indexed_db::TRANSACTION_VERSION_CHANGE); 1592 indexed_db::TRANSACTION_VERSION_CHANGE);
1593 scoped_refptr<IndexedDBTransaction> transaction = 1593 scoped_refptr<IndexedDBTransaction> transaction =
1594 transactions_[transaction_id]; 1594 transactions_[transaction_id];
1595 1595
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 bool IndexedDBDatabase::IsDeleteDatabaseBlocked() const { 1634 bool IndexedDBDatabase::IsDeleteDatabaseBlocked() const {
1635 return !!ConnectionCount(); 1635 return !!ConnectionCount();
1636 } 1636 }
1637 1637
1638 void IndexedDBDatabase::DeleteDatabaseFinal( 1638 void IndexedDBDatabase::DeleteDatabaseFinal(
1639 scoped_refptr<IndexedDBCallbacks> callbacks) { 1639 scoped_refptr<IndexedDBCallbacks> callbacks) {
1640 DCHECK(!IsDeleteDatabaseBlocked()); 1640 DCHECK(!IsDeleteDatabaseBlocked());
1641 DCHECK(backing_store_); 1641 DCHECK(backing_store_);
1642 if (!backing_store_->DeleteDatabase(metadata_.name)) { 1642 if (!backing_store_->DeleteDatabase(metadata_.name)) {
1643 callbacks->OnError( 1643 callbacks->OnError(
1644 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, 1644 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError,
1645 "Internal error deleting database.")); 1645 "Internal error deleting database."));
1646 return; 1646 return;
1647 } 1647 }
1648 metadata_.version = kNoStringVersion; 1648 metadata_.version = kNoStringVersion;
1649 metadata_.id = kInvalidId; 1649 metadata_.id = kInvalidId;
1650 metadata_.int_version = IndexedDBDatabaseMetadata::NO_INT_VERSION; 1650 metadata_.int_version = IndexedDBDatabaseMetadata::NO_INT_VERSION;
1651 metadata_.object_stores.clear(); 1651 metadata_.object_stores.clear();
1652 callbacks->OnSuccess(); 1652 callbacks->OnSuccess();
1653 } 1653 }
1654 1654
1655 void IndexedDBDatabase::Close(IndexedDBConnection* connection, bool forced) { 1655 void IndexedDBDatabase::Close(IndexedDBConnection* connection, bool forced) {
1656 DCHECK(connections_.count(connection)); 1656 DCHECK(connections_.count(connection));
1657 DCHECK(connection->IsConnected()); 1657 DCHECK(connection->IsConnected());
1658 DCHECK(connection->database() == this); 1658 DCHECK(connection->database() == this);
1659 1659
1660 // Abort outstanding transactions from the closing connection. This 1660 // Abort outstanding transactions from the closing connection. This
1661 // can not happen if the close is requested by the connection itself 1661 // can not happen if the close is requested by the connection itself
1662 // as the front-end defers the close until all transactions are 1662 // as the front-end defers the close until all transactions are
1663 // complete, but can occur on process termination or forced close. 1663 // complete, but can occur on process termination or forced close.
1664 { 1664 {
1665 TransactionMap transactions(transactions_); 1665 TransactionMap transactions(transactions_);
1666 for (TransactionMap::const_iterator it = transactions.begin(), 1666 for (TransactionMap::const_iterator it = transactions.begin(),
1667 end = transactions.end(); 1667 end = transactions.end();
1668 it != end; 1668 it != end;
1669 ++it) { 1669 ++it) {
1670 if (it->second->connection() == connection->callbacks()) 1670 if (it->second->connection() == connection->callbacks())
1671 it->second->Abort( 1671 it->second->Abort(
1672 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError, 1672 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionUnknownError,
1673 "Connection is closing.")); 1673 "Connection is closing."));
1674 } 1674 }
1675 } 1675 }
1676 1676
1677 connections_.erase(connection); 1677 connections_.erase(connection);
1678 if (pending_second_half_open_ && 1678 if (pending_second_half_open_ &&
1679 pending_second_half_open_->Connection() == connection) { 1679 pending_second_half_open_->Connection() == connection) {
1680 pending_second_half_open_->Callbacks()->OnError( 1680 pending_second_half_open_->Callbacks()->OnError(
1681 IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionAbortError, 1681 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionAbortError,
1682 "The connection was closed.")); 1682 "The connection was closed."));
1683 pending_second_half_open_.reset(); 1683 pending_second_half_open_.reset();
1684 } 1684 }
1685 1685
1686 ProcessPendingCalls(); 1686 ProcessPendingCalls();
1687 1687
1688 // TODO(jsbell): Add a test for the pending_open_calls_ cases below. 1688 // TODO(jsbell): Add a test for the pending_open_calls_ cases below.
1689 if (!ConnectionCount() && !pending_open_calls_.size() && 1689 if (!ConnectionCount() && !pending_open_calls_.size() &&
1690 !pending_delete_calls_.size()) { 1690 !pending_delete_calls_.size()) {
1691 DCHECK(transactions_.empty()); 1691 DCHECK(transactions_.empty());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1723 const string16& previous_version, 1723 const string16& previous_version,
1724 int64 previous_int_version, 1724 int64 previous_int_version,
1725 IndexedDBTransaction* transaction) { 1725 IndexedDBTransaction* transaction) {
1726 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); 1726 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation");
1727 DCHECK(!transaction); 1727 DCHECK(!transaction);
1728 metadata_.version = previous_version; 1728 metadata_.version = previous_version;
1729 metadata_.int_version = previous_int_version; 1729 metadata_.int_version = previous_int_version;
1730 } 1730 }
1731 1731
1732 } // namespace content 1732 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_database.h ('k') | content/browser/indexed_db/indexed_db_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698