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

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp

Issue 1407883002: Add new experimental IDBObjectStore.getKey(query) API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl format 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 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 if (!keyRange) { 107 if (!keyRange) {
108 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange ErrorMessage); 108 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange ErrorMessage);
109 return nullptr; 109 return nullptr;
110 } 110 }
111 if (!backendDB()) { 111 if (!backendDB()) {
112 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage); 112 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
113 return nullptr; 113 return nullptr;
114 } 114 }
115 115
116 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get()); 116 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
117 backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, key Range, false, WebIDBCallbacksImpl::create(request).release()); 117 backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, key Range, false /* keyOnly */, WebIDBCallbacksImpl::create(request).release());
118 return request; 118 return request;
119 } 119 }
120 120
121 IDBRequest* IDBObjectStore::getKey(ScriptState* scriptState, const ScriptValue& key, ExceptionState& exceptionState)
122 {
123 IDB_TRACE("IDBObjectStore::getKey");
124 if (isDeleted()) {
125 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage);
126 return nullptr;
127 }
128 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
129 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage);
130 return nullptr;
131 }
132 if (!m_transaction->isActive()) {
133 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage);
134 return nullptr;
135 }
136 IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecuti onContext(), key, exceptionState);
137 if (exceptionState.hadException())
138 return nullptr;
139 if (!keyRange) {
140 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange ErrorMessage);
141 return nullptr;
142 }
143 if (!backendDB()) {
144 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::databas eClosedErrorMessage);
145 return nullptr;
146 }
147
148 IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
149 backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, key Range, true /* keyOnly */, WebIDBCallbacksImpl::create(request).release());
150 return request;
151 }
152
121 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue& keyRange, ExceptionState& exceptionState) 153 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue& keyRange, ExceptionState& exceptionState)
122 { 154 {
123 return getAll(scriptState, keyRange, std::numeric_limits<uint32_t>::max(), e xceptionState); 155 return getAll(scriptState, keyRange, std::numeric_limits<uint32_t>::max(), e xceptionState);
124 } 156 }
125 157
126 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue& keyRange, unsigned long maxCount, ExceptionState& exceptionState) 158 IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue& keyRange, unsigned long maxCount, ExceptionState& exceptionState)
127 { 159 {
128 IDB_TRACE("IDBObjectStore::getAll"); 160 IDB_TRACE("IDBObjectStore::getAll");
129 if (!maxCount) 161 if (!maxCount)
130 maxCount = std::numeric_limits<uint32_t>::max(); 162 maxCount = std::numeric_limits<uint32_t>::max();
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 } 791 }
760 return IDBIndexMetadata::InvalidId; 792 return IDBIndexMetadata::InvalidId;
761 } 793 }
762 794
763 WebIDBDatabase* IDBObjectStore::backendDB() const 795 WebIDBDatabase* IDBObjectStore::backendDB() const
764 { 796 {
765 return m_transaction->backendDB(); 797 return m_transaction->backendDB();
766 } 798 }
767 799
768 } // namespace blink 800 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698