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 <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
528 IDB_TRACE1("IndexedDBDatabase::Abort(error)", "txn.id", transaction_id); | 528 IDB_TRACE1("IndexedDBDatabase::Abort(error)", "txn.id", transaction_id); |
529 // If the transaction is unknown, then it has already been aborted by the | 529 // If the transaction is unknown, then it has already been aborted by the |
530 // backend before this call so it is safe to ignore it. | 530 // backend before this call so it is safe to ignore it. |
531 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 531 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
532 if (transaction) | 532 if (transaction) |
533 transaction->Abort(error); | 533 transaction->Abort(error); |
534 } | 534 } |
535 | 535 |
536 void IndexedDBDatabase::GetAll(int64 transaction_id, | 536 void IndexedDBDatabase::GetAll(int64 transaction_id, |
537 int64 object_store_id, | 537 int64 object_store_id, |
538 int64 index_id, | |
538 scoped_ptr<IndexedDBKeyRange> key_range, | 539 scoped_ptr<IndexedDBKeyRange> key_range, |
539 int64 max_count, | 540 int64 max_count, |
540 scoped_refptr<IndexedDBCallbacks> callbacks) { | 541 scoped_refptr<IndexedDBCallbacks> callbacks) { |
541 IDB_TRACE1("IndexedDBDatabase::GetAll", "txn.id", transaction_id); | 542 IDB_TRACE1("IndexedDBDatabase::GetAll", "txn.id", transaction_id); |
542 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 543 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
543 if (!transaction) | 544 if (!transaction) |
544 return; | 545 return; |
545 | 546 |
546 if (!ValidateObjectStoreId(object_store_id)) | 547 if (!ValidateObjectStoreId(object_store_id)) |
547 return; | 548 return; |
548 | 549 |
549 transaction->ScheduleTask( | 550 transaction->ScheduleTask( |
550 base::Bind(&IndexedDBDatabase::GetAllOperation, this, object_store_id, | 551 base::Bind(&IndexedDBDatabase::GetAllOperation, this, object_store_id, |
551 Passed(&key_range), max_count, callbacks)); | 552 index_id, Passed(&key_range), max_count, callbacks)); |
552 } | 553 } |
553 | 554 |
554 void IndexedDBDatabase::Get(int64 transaction_id, | 555 void IndexedDBDatabase::Get(int64 transaction_id, |
555 int64 object_store_id, | 556 int64 object_store_id, |
556 int64 index_id, | 557 int64 index_id, |
557 scoped_ptr<IndexedDBKeyRange> key_range, | 558 scoped_ptr<IndexedDBKeyRange> key_range, |
558 bool key_only, | 559 bool key_only, |
559 scoped_refptr<IndexedDBCallbacks> callbacks) { | 560 scoped_refptr<IndexedDBCallbacks> callbacks) { |
560 IDB_TRACE1("IndexedDBDatabase::Get", "txn.id", transaction_id); | 561 IDB_TRACE1("IndexedDBDatabase::Get", "txn.id", transaction_id); |
561 IndexedDBTransaction* transaction = GetTransaction(transaction_id); | 562 IndexedDBTransaction* transaction = GetTransaction(transaction_id); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
732 if (object_store_metadata.auto_increment && | 733 if (object_store_metadata.auto_increment && |
733 !object_store_metadata.key_path.IsNull()) { | 734 !object_store_metadata.key_path.IsNull()) { |
734 value.primary_key = *primary_key; | 735 value.primary_key = *primary_key; |
735 value.key_path = object_store_metadata.key_path; | 736 value.key_path = object_store_metadata.key_path; |
736 } | 737 } |
737 callbacks->OnSuccess(&value); | 738 callbacks->OnSuccess(&value); |
738 } | 739 } |
739 | 740 |
740 void IndexedDBDatabase::GetAllOperation( | 741 void IndexedDBDatabase::GetAllOperation( |
741 int64 object_store_id, | 742 int64 object_store_id, |
743 int64 index_id, | |
742 scoped_ptr<IndexedDBKeyRange> key_range, | 744 scoped_ptr<IndexedDBKeyRange> key_range, |
743 int64 max_count, | 745 int64 max_count, |
744 scoped_refptr<IndexedDBCallbacks> callbacks, | 746 scoped_refptr<IndexedDBCallbacks> callbacks, |
745 IndexedDBTransaction* transaction) { | 747 IndexedDBTransaction* transaction) { |
746 IDB_TRACE1("IndexedDBDatabase::GetAllOperation", "txn.id", transaction->id()); | 748 IDB_TRACE1("IndexedDBDatabase::GetAllOperation", "txn.id", transaction->id()); |
747 | 749 |
748 DCHECK_GE(max_count, 0); | 750 DCHECK_GE(max_count, 0); |
749 if (!max_count) | 751 if (!max_count) |
750 max_count = std::numeric_limits<decltype(max_count)>::max(); | 752 max_count = std::numeric_limits<decltype(max_count)>::max(); |
751 | 753 |
752 DCHECK(metadata_.object_stores.find(object_store_id) != | 754 DCHECK(metadata_.object_stores.find(object_store_id) != |
753 metadata_.object_stores.end()); | 755 metadata_.object_stores.end()); |
754 const IndexedDBObjectStoreMetadata& object_store_metadata = | 756 const IndexedDBObjectStoreMetadata& object_store_metadata = |
755 metadata_.object_stores[object_store_id]; | 757 metadata_.object_stores[object_store_id]; |
756 | 758 |
757 leveldb::Status s; | 759 leveldb::Status s; |
758 | 760 |
759 scoped_ptr<IndexedDBBackingStore::Cursor> cursor = | 761 scoped_ptr<IndexedDBBackingStore::Cursor> cursor; |
760 backing_store_->OpenObjectStoreCursor( | 762 |
761 transaction->BackingStoreTransaction(), id(), object_store_id, | 763 if (index_id == IndexedDBIndexMetadata::kInvalidId) { |
762 *key_range, blink::WebIDBCursorDirectionNext, &s); | 764 // ObjectStore Retrieval Operation |
jsbell
2015/05/14 22:22:50
nit: This doesn't match the spec's "blah blah Retr
cmumford
2015/05/15 20:55:07
Done.
| |
765 cursor = backing_store_->OpenObjectStoreCursor( | |
766 transaction->BackingStoreTransaction(), id(), object_store_id, | |
767 *key_range, blink::WebIDBCursorDirectionNext, &s); | |
768 } else { | |
769 // Index Referenced Value Retrieval Operation | |
770 cursor = backing_store_->OpenIndexCursor( | |
771 transaction->BackingStoreTransaction(), id(), object_store_id, index_id, | |
772 *key_range, blink::WebIDBCursorDirectionNext, &s); | |
773 } | |
763 | 774 |
764 if (!s.ok()) { | 775 if (!s.ok()) { |
765 DLOG(ERROR) << "Unable to open cursor operation: " << s.ToString(); | 776 DLOG(ERROR) << "Unable to open cursor operation: " << s.ToString(); |
766 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, | 777 IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError, |
767 "Internal error in GetAllOperation"); | 778 "Internal error in GetAllOperation"); |
768 callbacks->OnError(error); | 779 callbacks->OnError(error); |
769 if (s.IsCorruption()) { | 780 if (s.IsCorruption()) { |
770 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), | 781 factory_->HandleBackingStoreCorruption(backing_store_->origin_url(), |
771 error); | 782 error); |
772 } | 783 } |
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1925 IndexedDBTransaction* transaction) { | 1936 IndexedDBTransaction* transaction) { |
1926 DCHECK(!transaction); | 1937 DCHECK(!transaction); |
1927 IDB_TRACE1("IndexedDBDatabase::VersionChangeAbortOperation", | 1938 IDB_TRACE1("IndexedDBDatabase::VersionChangeAbortOperation", |
1928 "txn.id", | 1939 "txn.id", |
1929 transaction->id()); | 1940 transaction->id()); |
1930 metadata_.version = previous_version; | 1941 metadata_.version = previous_version; |
1931 metadata_.int_version = previous_int_version; | 1942 metadata_.int_version = previous_int_version; |
1932 } | 1943 } |
1933 | 1944 |
1934 } // namespace content | 1945 } // namespace content |
OLD | NEW |