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