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 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 metadata_.object_stores[object_store_id]; | 876 metadata_.object_stores[object_store_id]; |
877 | 877 |
878 const IndexedDBKey* key; | 878 const IndexedDBKey* key; |
879 | 879 |
880 leveldb::Status s; | 880 leveldb::Status s; |
881 std::unique_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; | 881 std::unique_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor; |
882 if (key_range->IsOnlyKey()) { | 882 if (key_range->IsOnlyKey()) { |
883 key = &key_range->lower(); | 883 key = &key_range->lower(); |
884 } else { | 884 } else { |
885 if (index_id == IndexedDBIndexMetadata::kInvalidId) { | 885 if (index_id == IndexedDBIndexMetadata::kInvalidId) { |
886 DCHECK_NE(cursor_type, indexed_db::CURSOR_KEY_ONLY); | |
887 // ObjectStore Retrieval Operation | 886 // ObjectStore Retrieval Operation |
888 backing_store_cursor = backing_store_->OpenObjectStoreCursor( | 887 if (cursor_type == indexed_db::CURSOR_KEY_ONLY) { |
889 transaction->BackingStoreTransaction(), | 888 backing_store_cursor = backing_store_->OpenObjectStoreKeyCursor( |
890 id(), | 889 transaction->BackingStoreTransaction(), id(), object_store_id, |
891 object_store_id, | 890 *key_range, blink::WebIDBCursorDirectionNext, &s); |
892 *key_range, | 891 } else { |
893 blink::WebIDBCursorDirectionNext, | 892 backing_store_cursor = backing_store_->OpenObjectStoreCursor( |
894 &s); | 893 transaction->BackingStoreTransaction(), id(), object_store_id, |
| 894 *key_range, blink::WebIDBCursorDirectionNext, &s); |
| 895 } |
895 } else if (cursor_type == indexed_db::CURSOR_KEY_ONLY) { | 896 } else if (cursor_type == indexed_db::CURSOR_KEY_ONLY) { |
896 // Index Value Retrieval Operation | 897 // Index Value Retrieval Operation |
897 backing_store_cursor = backing_store_->OpenIndexKeyCursor( | 898 backing_store_cursor = backing_store_->OpenIndexKeyCursor( |
898 transaction->BackingStoreTransaction(), | 899 transaction->BackingStoreTransaction(), |
899 id(), | 900 id(), |
900 object_store_id, | 901 object_store_id, |
901 index_id, | 902 index_id, |
902 *key_range, | 903 *key_range, |
903 blink::WebIDBCursorDirectionNext, | 904 blink::WebIDBCursorDirectionNext, |
904 &s); | 905 &s); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 if (s.IsCorruption()) | 949 if (s.IsCorruption()) |
949 factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); | 950 factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); |
950 return; | 951 return; |
951 } | 952 } |
952 | 953 |
953 if (value.empty()) { | 954 if (value.empty()) { |
954 callbacks->OnSuccess(); | 955 callbacks->OnSuccess(); |
955 return; | 956 return; |
956 } | 957 } |
957 | 958 |
| 959 if (cursor_type == indexed_db::CURSOR_KEY_ONLY) { |
| 960 callbacks->OnSuccess(*key); |
| 961 return; |
| 962 } |
| 963 |
958 if (object_store_metadata.auto_increment && | 964 if (object_store_metadata.auto_increment && |
959 !object_store_metadata.key_path.IsNull()) { | 965 !object_store_metadata.key_path.IsNull()) { |
960 value.primary_key = *key; | 966 value.primary_key = *key; |
961 value.key_path = object_store_metadata.key_path; | 967 value.key_path = object_store_metadata.key_path; |
962 } | 968 } |
963 | 969 |
964 callbacks->OnSuccess(&value); | 970 callbacks->OnSuccess(&value); |
965 return; | 971 return; |
966 } | 972 } |
967 | 973 |
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1998 | 2004 |
1999 void IndexedDBDatabase::VersionChangeAbortOperation( | 2005 void IndexedDBDatabase::VersionChangeAbortOperation( |
2000 int64_t previous_version, | 2006 int64_t previous_version, |
2001 IndexedDBTransaction* transaction) { | 2007 IndexedDBTransaction* transaction) { |
2002 DCHECK(!transaction); | 2008 DCHECK(!transaction); |
2003 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); | 2009 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); |
2004 metadata_.version = previous_version; | 2010 metadata_.version = previous_version; |
2005 } | 2011 } |
2006 | 2012 |
2007 } // namespace content | 2013 } // namespace content |
OLD | NEW |