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

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

Issue 1407883002: Add new experimental IDBObjectStore.getKey(query) API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 3 months 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
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 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
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(),
891 object_store_id, 890 id(),
892 *key_range, 891 object_store_id,
893 blink::WebIDBCursorDirectionNext, 892 *key_range,
894 &s); 893 blink::WebIDBCursorDirectionNext,
894 &s);
895 } else {
896 backing_store_cursor = backing_store_->OpenObjectStoreCursor(
897 transaction->BackingStoreTransaction(),
898 id(),
899 object_store_id,
900 *key_range,
901 blink::WebIDBCursorDirectionNext,
902 &s);
903 }
895 } else if (cursor_type == indexed_db::CURSOR_KEY_ONLY) { 904 } else if (cursor_type == indexed_db::CURSOR_KEY_ONLY) {
896 // Index Value Retrieval Operation 905 // Index Value Retrieval Operation
897 backing_store_cursor = backing_store_->OpenIndexKeyCursor( 906 backing_store_cursor = backing_store_->OpenIndexKeyCursor(
898 transaction->BackingStoreTransaction(), 907 transaction->BackingStoreTransaction(),
899 id(), 908 id(),
900 object_store_id, 909 object_store_id,
901 index_id, 910 index_id,
902 *key_range, 911 *key_range,
903 blink::WebIDBCursorDirectionNext, 912 blink::WebIDBCursorDirectionNext,
904 &s); 913 &s);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 if (s.IsCorruption()) 957 if (s.IsCorruption())
949 factory_->HandleBackingStoreCorruption(backing_store_->origin(), error); 958 factory_->HandleBackingStoreCorruption(backing_store_->origin(), error);
950 return; 959 return;
951 } 960 }
952 961
953 if (value.empty()) { 962 if (value.empty()) {
954 callbacks->OnSuccess(); 963 callbacks->OnSuccess();
955 return; 964 return;
956 } 965 }
957 966
967 if (cursor_type == indexed_db::CURSOR_KEY_ONLY) {
968 callbacks->OnSuccess(*key);
cmumford 2016/08/29 19:03:22 Indenting is wrong.
969 return;
970 }
971
958 if (object_store_metadata.auto_increment && 972 if (object_store_metadata.auto_increment &&
959 !object_store_metadata.key_path.IsNull()) { 973 !object_store_metadata.key_path.IsNull()) {
960 value.primary_key = *key; 974 value.primary_key = *key;
961 value.key_path = object_store_metadata.key_path; 975 value.key_path = object_store_metadata.key_path;
962 } 976 }
963 977
964 callbacks->OnSuccess(&value); 978 callbacks->OnSuccess(&value);
965 return; 979 return;
966 } 980 }
967 981
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 2012
1999 void IndexedDBDatabase::VersionChangeAbortOperation( 2013 void IndexedDBDatabase::VersionChangeAbortOperation(
2000 int64_t previous_version, 2014 int64_t previous_version,
2001 IndexedDBTransaction* transaction) { 2015 IndexedDBTransaction* transaction) {
2002 DCHECK(!transaction); 2016 DCHECK(!transaction);
2003 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation"); 2017 IDB_TRACE("IndexedDBDatabase::VersionChangeAbortOperation");
2004 metadata_.version = previous_version; 2018 metadata_.version = previous_version;
2005 } 2019 }
2006 2020
2007 } // namespace content 2021 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698