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.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/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "content/browser/indexed_db/indexed_db_blob_info.h" | 17 #include "content/browser/indexed_db/indexed_db_blob_info.h" |
18 #include "content/browser/indexed_db/indexed_db_connection.h" | 18 #include "content/browser/indexed_db/indexed_db_connection.h" |
19 #include "content/browser/indexed_db/indexed_db_context_impl.h" | 19 #include "content/browser/indexed_db/indexed_db_context_impl.h" |
20 #include "content/browser/indexed_db/indexed_db_cursor.h" | 20 #include "content/browser/indexed_db/indexed_db_cursor.h" |
21 #include "content/browser/indexed_db/indexed_db_factory.h" | 21 #include "content/browser/indexed_db/indexed_db_factory.h" |
22 #include "content/browser/indexed_db/indexed_db_index_writer.h" | 22 #include "content/browser/indexed_db/indexed_db_index_writer.h" |
23 #include "content/browser/indexed_db/indexed_db_pending_connection.h" | 23 #include "content/browser/indexed_db/indexed_db_pending_connection.h" |
24 #include "content/browser/indexed_db/indexed_db_tracing.h" | 24 #include "content/browser/indexed_db/indexed_db_tracing.h" |
25 #include "content/browser/indexed_db/indexed_db_transaction.h" | 25 #include "content/browser/indexed_db/indexed_db_transaction.h" |
26 #include "content/browser/indexed_db/indexed_db_value.h" | 26 #include "content/browser/indexed_db/indexed_db_value.h" |
27 #include "content/common/indexed_db/indexed_db_key_path.h" | 27 #include "content/common/indexed_db/indexed_db_key_path.h" |
28 #include "content/common/indexed_db/indexed_db_key_range.h" | 28 #include "content/common/indexed_db/indexed_db_key_range.h" |
29 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" | 29 #include "third_party/WebKit/public/platform/WebIDBDatabaseException.h" |
| 30 #include "third_party/leveldatabase/env_chromium.h" |
30 #include "webkit/browser/blob/blob_data_handle.h" | 31 #include "webkit/browser/blob/blob_data_handle.h" |
31 | 32 |
32 using base::ASCIIToUTF16; | 33 using base::ASCIIToUTF16; |
33 using base::Int64ToString16; | 34 using base::Int64ToString16; |
34 using blink::WebIDBKeyTypeNumber; | 35 using blink::WebIDBKeyTypeNumber; |
35 | 36 |
36 namespace content { | 37 namespace content { |
37 | 38 |
38 // PendingUpgradeCall has a scoped_ptr<IndexedDBConnection> because it owns the | 39 // PendingUpgradeCall has a scoped_ptr<IndexedDBConnection> because it owns the |
39 // in-progress connection. | 40 // in-progress connection. |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 object_store_metadata.id, | 294 object_store_metadata.id, |
294 object_store_metadata.name, | 295 object_store_metadata.name, |
295 object_store_metadata.key_path, | 296 object_store_metadata.key_path, |
296 object_store_metadata.auto_increment); | 297 object_store_metadata.auto_increment); |
297 if (!s.ok()) { | 298 if (!s.ok()) { |
298 IndexedDBDatabaseError error( | 299 IndexedDBDatabaseError error( |
299 blink::WebIDBDatabaseExceptionUnknownError, | 300 blink::WebIDBDatabaseExceptionUnknownError, |
300 ASCIIToUTF16("Internal error creating object store '") + | 301 ASCIIToUTF16("Internal error creating object store '") + |
301 object_store_metadata.name + ASCIIToUTF16("'.")); | 302 object_store_metadata.name + ASCIIToUTF16("'.")); |
302 transaction->Abort(error); | 303 transaction->Abort(error); |
303 if (s.IsCorruption()) | 304 if (leveldb_env::IsCorruption(s)) |
304 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 305 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
305 error); | 306 error); |
306 return; | 307 return; |
307 } | 308 } |
308 | 309 |
309 AddObjectStore(object_store_metadata, object_store_id); | 310 AddObjectStore(object_store_metadata, object_store_id); |
310 transaction->ScheduleAbortTask( | 311 transaction->ScheduleAbortTask( |
311 base::Bind(&IndexedDBDatabase::CreateObjectStoreAbortOperation, | 312 base::Bind(&IndexedDBDatabase::CreateObjectStoreAbortOperation, |
312 this, | 313 this, |
313 object_store_id)); | 314 object_store_id)); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 transaction->database()->id(), | 418 transaction->database()->id(), |
418 object_store_id, | 419 object_store_id, |
419 index_id); | 420 index_id); |
420 if (!s.ok()) { | 421 if (!s.ok()) { |
421 base::string16 error_string = | 422 base::string16 error_string = |
422 ASCIIToUTF16("Internal error deleting index '") + | 423 ASCIIToUTF16("Internal error deleting index '") + |
423 index_metadata.name + ASCIIToUTF16("'."); | 424 index_metadata.name + ASCIIToUTF16("'."); |
424 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 425 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
425 error_string); | 426 error_string); |
426 transaction->Abort(error); | 427 transaction->Abort(error); |
427 if (s.IsCorruption()) | 428 if (leveldb_env::IsCorruption(s)) |
428 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 429 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
429 error); | 430 error); |
430 return; | 431 return; |
431 } | 432 } |
432 | 433 |
433 RemoveIndex(object_store_id, index_id); | 434 RemoveIndex(object_store_id, index_id); |
434 transaction->ScheduleAbortTask( | 435 transaction->ScheduleAbortTask( |
435 base::Bind(&IndexedDBDatabase::DeleteIndexAbortOperation, | 436 base::Bind(&IndexedDBDatabase::DeleteIndexAbortOperation, |
436 this, | 437 this, |
437 object_store_id, | 438 object_store_id, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 index_id, | 551 index_id, |
551 *key_range, | 552 *key_range, |
552 indexed_db::CURSOR_NEXT, | 553 indexed_db::CURSOR_NEXT, |
553 &s); | 554 &s); |
554 } | 555 } |
555 | 556 |
556 if (!s.ok()) { | 557 if (!s.ok()) { |
557 DLOG(ERROR) << "Unable to open cursor operation: " << s.ToString(); | 558 DLOG(ERROR) << "Unable to open cursor operation: " << s.ToString(); |
558 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 559 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
559 "Internal error deleting data in range"); | 560 "Internal error deleting data in range"); |
560 if (s.IsCorruption()) { | 561 if (leveldb_env::IsCorruption(s)) { |
561 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 562 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
562 error); | 563 error); |
563 } | 564 } |
564 } | 565 } |
565 | 566 |
566 if (!backing_store_cursor) { | 567 if (!backing_store_cursor) { |
567 callbacks->OnSuccess(); | 568 callbacks->OnSuccess(); |
568 return; | 569 return; |
569 } | 570 } |
570 | 571 |
571 key = &backing_store_cursor->key(); | 572 key = &backing_store_cursor->key(); |
572 } | 573 } |
573 | 574 |
574 scoped_ptr<IndexedDBKey> primary_key; | 575 scoped_ptr<IndexedDBKey> primary_key; |
575 if (index_id == IndexedDBIndexMetadata::kInvalidId) { | 576 if (index_id == IndexedDBIndexMetadata::kInvalidId) { |
576 // Object Store Retrieval Operation | 577 // Object Store Retrieval Operation |
577 IndexedDBValue value; | 578 IndexedDBValue value; |
578 s = backing_store_->GetRecord(transaction->BackingStoreTransaction(), | 579 s = backing_store_->GetRecord(transaction->BackingStoreTransaction(), |
579 id(), | 580 id(), |
580 object_store_id, | 581 object_store_id, |
581 *key, | 582 *key, |
582 &value); | 583 &value); |
583 if (!s.ok()) { | 584 if (!s.ok()) { |
584 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 585 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
585 "Internal error in GetRecord."); | 586 "Internal error in GetRecord."); |
586 callbacks->OnError(error); | 587 callbacks->OnError(error); |
587 | 588 |
588 if (s.IsCorruption()) | 589 if (leveldb_env::IsCorruption(s)) |
589 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 590 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
590 error); | 591 error); |
591 return; | 592 return; |
592 } | 593 } |
593 | 594 |
594 if (value.empty()) { | 595 if (value.empty()) { |
595 callbacks->OnSuccess(); | 596 callbacks->OnSuccess(); |
596 return; | 597 return; |
597 } | 598 } |
598 | 599 |
(...skipping 12 matching lines...) Expand all Loading... |
611 transaction->BackingStoreTransaction(), | 612 transaction->BackingStoreTransaction(), |
612 id(), | 613 id(), |
613 object_store_id, | 614 object_store_id, |
614 index_id, | 615 index_id, |
615 *key, | 616 *key, |
616 &primary_key); | 617 &primary_key); |
617 if (!s.ok()) { | 618 if (!s.ok()) { |
618 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 619 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
619 "Internal error in GetPrimaryKeyViaIndex."); | 620 "Internal error in GetPrimaryKeyViaIndex."); |
620 callbacks->OnError(error); | 621 callbacks->OnError(error); |
621 if (s.IsCorruption()) | 622 if (leveldb_env::IsCorruption(s)) |
622 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 623 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
623 error); | 624 error); |
624 return; | 625 return; |
625 } | 626 } |
626 if (!primary_key) { | 627 if (!primary_key) { |
627 callbacks->OnSuccess(); | 628 callbacks->OnSuccess(); |
628 return; | 629 return; |
629 } | 630 } |
630 if (cursor_type == indexed_db::CURSOR_KEY_ONLY) { | 631 if (cursor_type == indexed_db::CURSOR_KEY_ONLY) { |
631 // Index Value Retrieval Operation | 632 // Index Value Retrieval Operation |
632 callbacks->OnSuccess(*primary_key); | 633 callbacks->OnSuccess(*primary_key); |
633 return; | 634 return; |
634 } | 635 } |
635 | 636 |
636 // Index Referenced Value Retrieval Operation | 637 // Index Referenced Value Retrieval Operation |
637 IndexedDBValue value; | 638 IndexedDBValue value; |
638 s = backing_store_->GetRecord(transaction->BackingStoreTransaction(), | 639 s = backing_store_->GetRecord(transaction->BackingStoreTransaction(), |
639 id(), | 640 id(), |
640 object_store_id, | 641 object_store_id, |
641 *primary_key, | 642 *primary_key, |
642 &value); | 643 &value); |
643 if (!s.ok()) { | 644 if (!s.ok()) { |
644 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 645 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
645 "Internal error in GetRecord."); | 646 "Internal error in GetRecord."); |
646 callbacks->OnError(error); | 647 callbacks->OnError(error); |
647 if (s.IsCorruption()) | 648 if (leveldb_env::IsCorruption(s)) |
648 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 649 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
649 error); | 650 error); |
650 return; | 651 return; |
651 } | 652 } |
652 | 653 |
653 if (value.empty()) { | 654 if (value.empty()) { |
654 callbacks->OnSuccess(); | 655 callbacks->OnSuccess(); |
655 return; | 656 return; |
656 } | 657 } |
657 if (object_store_metadata.auto_increment && | 658 if (object_store_metadata.auto_increment && |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 transaction->BackingStoreTransaction(), | 784 transaction->BackingStoreTransaction(), |
784 id(), | 785 id(), |
785 params->object_store_id, | 786 params->object_store_id, |
786 *key, | 787 *key, |
787 &record_identifier, | 788 &record_identifier, |
788 &found); | 789 &found); |
789 if (!s.ok()) { | 790 if (!s.ok()) { |
790 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 791 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
791 "Internal error checking key existence."); | 792 "Internal error checking key existence."); |
792 params->callbacks->OnError(error); | 793 params->callbacks->OnError(error); |
793 if (s.IsCorruption()) | 794 if (leveldb_env::IsCorruption(s)) |
794 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 795 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
795 error); | 796 error); |
796 return; | 797 return; |
797 } | 798 } |
798 if (found) { | 799 if (found) { |
799 params->callbacks->OnError( | 800 params->callbacks->OnError( |
800 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionConstraintError, | 801 IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionConstraintError, |
801 "Key already exists in the object store.")); | 802 "Key already exists in the object store.")); |
802 return; | 803 return; |
803 } | 804 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 params->object_store_id, | 837 params->object_store_id, |
837 *key, | 838 *key, |
838 params->value, | 839 params->value, |
839 ¶ms->handles, | 840 ¶ms->handles, |
840 &record_identifier); | 841 &record_identifier); |
841 if (!s.ok()) { | 842 if (!s.ok()) { |
842 IndexedDBDatabaseError error( | 843 IndexedDBDatabaseError error( |
843 blink::WebIDBDatabaseExceptionUnknownError, | 844 blink::WebIDBDatabaseExceptionUnknownError, |
844 "Internal error: backing store error performing put/add."); | 845 "Internal error: backing store error performing put/add."); |
845 params->callbacks->OnError(error); | 846 params->callbacks->OnError(error); |
846 if (s.IsCorruption()) | 847 if (leveldb_env::IsCorruption(s)) |
847 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 848 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
848 error); | 849 error); |
849 return; | 850 return; |
850 } | 851 } |
851 | 852 |
852 for (size_t i = 0; i < index_writers.size(); ++i) { | 853 for (size_t i = 0; i < index_writers.size(); ++i) { |
853 IndexWriter* index_writer = index_writers[i]; | 854 IndexWriter* index_writer = index_writers[i]; |
854 index_writer->WriteIndexKeys(record_identifier, | 855 index_writer->WriteIndexKeys(record_identifier, |
855 backing_store_.get(), | 856 backing_store_.get(), |
856 transaction->BackingStoreTransaction(), | 857 transaction->BackingStoreTransaction(), |
857 id(), | 858 id(), |
858 params->object_store_id); | 859 params->object_store_id); |
859 } | 860 } |
860 | 861 |
861 if (object_store.auto_increment && | 862 if (object_store.auto_increment && |
862 params->put_mode != IndexedDBDatabase::CURSOR_UPDATE && | 863 params->put_mode != IndexedDBDatabase::CURSOR_UPDATE && |
863 key->type() == WebIDBKeyTypeNumber) { | 864 key->type() == WebIDBKeyTypeNumber) { |
864 leveldb::Status s = UpdateKeyGenerator(backing_store_.get(), | 865 leveldb::Status s = UpdateKeyGenerator(backing_store_.get(), |
865 transaction, | 866 transaction, |
866 id(), | 867 id(), |
867 params->object_store_id, | 868 params->object_store_id, |
868 *key, | 869 *key, |
869 !key_was_generated); | 870 !key_was_generated); |
870 if (!s.ok()) { | 871 if (!s.ok()) { |
871 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 872 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
872 "Internal error updating key generator."); | 873 "Internal error updating key generator."); |
873 params->callbacks->OnError(error); | 874 params->callbacks->OnError(error); |
874 if (s.IsCorruption()) | 875 if (leveldb_env::IsCorruption(s)) |
875 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 876 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
876 error); | 877 error); |
877 return; | 878 return; |
878 } | 879 } |
879 } | 880 } |
880 | 881 |
881 params->callbacks->OnSuccess(*key); | 882 params->callbacks->OnSuccess(*key); |
882 } | 883 } |
883 | 884 |
884 void IndexedDBDatabase::SetIndexKeys(int64 transaction_id, | 885 void IndexedDBDatabase::SetIndexKeys(int64 transaction_id, |
(...skipping 14 matching lines...) Expand all Loading... |
899 transaction->BackingStoreTransaction(), | 900 transaction->BackingStoreTransaction(), |
900 metadata_.id, | 901 metadata_.id, |
901 object_store_id, | 902 object_store_id, |
902 *primary_key, | 903 *primary_key, |
903 &record_identifier, | 904 &record_identifier, |
904 &found); | 905 &found); |
905 if (!s.ok()) { | 906 if (!s.ok()) { |
906 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 907 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
907 "Internal error setting index keys."); | 908 "Internal error setting index keys."); |
908 transaction->Abort(error); | 909 transaction->Abort(error); |
909 if (s.IsCorruption()) | 910 if (leveldb_env::IsCorruption(s)) |
910 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 911 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
911 error); | 912 error); |
912 return; | 913 return; |
913 } | 914 } |
914 if (!found) { | 915 if (!found) { |
915 transaction->Abort(IndexedDBDatabaseError( | 916 transaction->Abort(IndexedDBDatabaseError( |
916 blink::WebIDBDatabaseExceptionUnknownError, | 917 blink::WebIDBDatabaseExceptionUnknownError, |
917 "Internal error setting index keys for object store.")); | 918 "Internal error setting index keys for object store.")); |
918 return; | 919 return; |
919 } | 920 } |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 *params->key_range, | 1079 *params->key_range, |
1079 params->direction, | 1080 params->direction, |
1080 &s); | 1081 &s); |
1081 } | 1082 } |
1082 } | 1083 } |
1083 | 1084 |
1084 if (!s.ok()) { | 1085 if (!s.ok()) { |
1085 DLOG(ERROR) << "Unable to open cursor operation: " << s.ToString(); | 1086 DLOG(ERROR) << "Unable to open cursor operation: " << s.ToString(); |
1086 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 1087 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
1087 "Internal error opening cursor operation"); | 1088 "Internal error opening cursor operation"); |
1088 if (s.IsCorruption()) { | 1089 if (leveldb_env::IsCorruption(s)) { |
1089 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 1090 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
1090 error); | 1091 error); |
1091 } | 1092 } |
1092 } | 1093 } |
1093 | 1094 |
1094 if (!backing_store_cursor) { | 1095 if (!backing_store_cursor) { |
1095 // Why is Success being called? | 1096 // Why is Success being called? |
1096 params->callbacks->OnSuccess(static_cast<IndexedDBValue*>(NULL)); | 1097 params->callbacks->OnSuccess(static_cast<IndexedDBValue*>(NULL)); |
1097 return; | 1098 return; |
1098 } | 1099 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 object_store_id, | 1154 object_store_id, |
1154 index_id, | 1155 index_id, |
1155 *key_range, | 1156 *key_range, |
1156 indexed_db::CURSOR_NEXT, | 1157 indexed_db::CURSOR_NEXT, |
1157 &s); | 1158 &s); |
1158 } | 1159 } |
1159 if (!s.ok()) { | 1160 if (!s.ok()) { |
1160 DLOG(ERROR) << "Unable perform count operation: " << s.ToString(); | 1161 DLOG(ERROR) << "Unable perform count operation: " << s.ToString(); |
1161 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 1162 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
1162 "Internal error performing count operation"); | 1163 "Internal error performing count operation"); |
1163 if (s.IsCorruption()) { | 1164 if (leveldb_env::IsCorruption(s)) { |
1164 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 1165 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
1165 error); | 1166 error); |
1166 } | 1167 } |
1167 } | 1168 } |
1168 if (!backing_store_cursor) { | 1169 if (!backing_store_cursor) { |
1169 callbacks->OnSuccess(count); | 1170 callbacks->OnSuccess(count); |
1170 return; | 1171 return; |
1171 } | 1172 } |
1172 | 1173 |
1173 do { | 1174 do { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 "Internal error deleting data in range")); | 1229 "Internal error deleting data in range")); |
1229 return; | 1230 return; |
1230 } | 1231 } |
1231 } while (backing_store_cursor->Continue(&s)); | 1232 } while (backing_store_cursor->Continue(&s)); |
1232 } | 1233 } |
1233 | 1234 |
1234 if (!s.ok()) { | 1235 if (!s.ok()) { |
1235 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 1236 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
1236 ASCIIToUTF16("Internal error deleting range")); | 1237 ASCIIToUTF16("Internal error deleting range")); |
1237 transaction->Abort(error); | 1238 transaction->Abort(error); |
1238 if (s.IsCorruption()) { | 1239 if (leveldb_env::IsCorruption(s)) { |
1239 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 1240 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
1240 error); | 1241 error); |
1241 } | 1242 } |
1242 return; | 1243 return; |
1243 } | 1244 } |
1244 | 1245 |
1245 callbacks->OnSuccess(); | 1246 callbacks->OnSuccess(); |
1246 } | 1247 } |
1247 | 1248 |
1248 void IndexedDBDatabase::Clear(int64 transaction_id, | 1249 void IndexedDBDatabase::Clear(int64 transaction_id, |
(...skipping 16 matching lines...) Expand all Loading... |
1265 int64 object_store_id, | 1266 int64 object_store_id, |
1266 scoped_refptr<IndexedDBCallbacks> callbacks, | 1267 scoped_refptr<IndexedDBCallbacks> callbacks, |
1267 IndexedDBTransaction* transaction) { | 1268 IndexedDBTransaction* transaction) { |
1268 IDB_TRACE("IndexedDBDatabase::ObjectStoreClearOperation"); | 1269 IDB_TRACE("IndexedDBDatabase::ObjectStoreClearOperation"); |
1269 leveldb::Status s = backing_store_->ClearObjectStore( | 1270 leveldb::Status s = backing_store_->ClearObjectStore( |
1270 transaction->BackingStoreTransaction(), id(), object_store_id); | 1271 transaction->BackingStoreTransaction(), id(), object_store_id); |
1271 if (!s.ok()) { | 1272 if (!s.ok()) { |
1272 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 1273 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
1273 "Internal error clearing object store"); | 1274 "Internal error clearing object store"); |
1274 callbacks->OnError(error); | 1275 callbacks->OnError(error); |
1275 if (s.IsCorruption()) { | 1276 if (leveldb_env::IsCorruption(s)) { |
1276 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 1277 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
1277 error); | 1278 error); |
1278 } | 1279 } |
1279 return; | 1280 return; |
1280 } | 1281 } |
1281 callbacks->OnSuccess(); | 1282 callbacks->OnSuccess(); |
1282 } | 1283 } |
1283 | 1284 |
1284 void IndexedDBDatabase::DeleteObjectStoreOperation( | 1285 void IndexedDBDatabase::DeleteObjectStoreOperation( |
1285 int64 object_store_id, | 1286 int64 object_store_id, |
1286 IndexedDBTransaction* transaction) { | 1287 IndexedDBTransaction* transaction) { |
1287 IDB_TRACE("IndexedDBDatabase::DeleteObjectStoreOperation"); | 1288 IDB_TRACE("IndexedDBDatabase::DeleteObjectStoreOperation"); |
1288 | 1289 |
1289 const IndexedDBObjectStoreMetadata object_store_metadata = | 1290 const IndexedDBObjectStoreMetadata object_store_metadata = |
1290 metadata_.object_stores[object_store_id]; | 1291 metadata_.object_stores[object_store_id]; |
1291 leveldb::Status s = | 1292 leveldb::Status s = |
1292 backing_store_->DeleteObjectStore(transaction->BackingStoreTransaction(), | 1293 backing_store_->DeleteObjectStore(transaction->BackingStoreTransaction(), |
1293 transaction->database()->id(), | 1294 transaction->database()->id(), |
1294 object_store_id); | 1295 object_store_id); |
1295 if (!s.ok()) { | 1296 if (!s.ok()) { |
1296 base::string16 error_string = | 1297 base::string16 error_string = |
1297 ASCIIToUTF16("Internal error deleting object store '") + | 1298 ASCIIToUTF16("Internal error deleting object store '") + |
1298 object_store_metadata.name + ASCIIToUTF16("'."); | 1299 object_store_metadata.name + ASCIIToUTF16("'."); |
1299 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 1300 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
1300 error_string); | 1301 error_string); |
1301 transaction->Abort(error); | 1302 transaction->Abort(error); |
1302 if (s.IsCorruption()) | 1303 if (leveldb_env::IsCorruption(s)) |
1303 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 1304 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
1304 error); | 1305 error); |
1305 return; | 1306 return; |
1306 } | 1307 } |
1307 | 1308 |
1308 RemoveObjectStore(object_store_id); | 1309 RemoveObjectStore(object_store_id); |
1309 transaction->ScheduleAbortTask( | 1310 transaction->ScheduleAbortTask( |
1310 base::Bind(&IndexedDBDatabase::DeleteObjectStoreAbortOperation, | 1311 base::Bind(&IndexedDBDatabase::DeleteObjectStoreAbortOperation, |
1311 this, | 1312 this, |
1312 object_store_metadata)); | 1313 object_store_metadata)); |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1761 const base::string16& previous_version, | 1762 const base::string16& previous_version, |
1762 int64 previous_int_version, | 1763 int64 previous_int_version, |
1763 IndexedDBTransaction* transaction) { | 1764 IndexedDBTransaction* transaction) { |
1764 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); | 1765 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); |
1765 DCHECK(!transaction); | 1766 DCHECK(!transaction); |
1766 metadata_.version = previous_version; | 1767 metadata_.version = previous_version; |
1767 metadata_.int_version = previous_int_version; | 1768 metadata_.int_version = previous_int_version; |
1768 } | 1769 } |
1769 | 1770 |
1770 } // namespace content | 1771 } // namespace content |
OLD | NEW |