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

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

Issue 1021713003: [bindings] Let NativeValueTraits<T>::nativeValue be variadic function and merge various convers… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: IDB related changes alone. Created 5 years, 9 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
« no previous file with comments | « Source/modules/indexeddb/IDBKeyRange.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
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).leakPtr()); 117 backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, key Range, false, WebIDBCallbacksImpl::create(request).leakPtr());
118 return request; 118 return request;
119 } 119 }
120 120
121 static void generateIndexKeysForValue(v8::Isolate* isolate, const IDBIndexMetada ta& indexMetadata, const ScriptValue& objectValue, IDBObjectStore::IndexKeys* in dexKeys) 121 static void generateIndexKeysForValue(v8::Isolate* isolate, const IDBIndexMetada ta& indexMetadata, const ScriptValue& objectValue, IDBObjectStore::IndexKeys* in dexKeys)
122 { 122 {
123 ASSERT(indexKeys); 123 ASSERT(indexKeys);
124 IDBKey* indexKey = createIDBKeyFromScriptValueAndKeyPath(isolate, objectValu e, indexMetadata.keyPath); 124 NonThrowableExceptionState exceptionState;
125 IDBKey* indexKey = ScriptValue::to<IDBKey*>(isolate, objectValue, exceptionS tate, indexMetadata.keyPath);
125 126
126 if (!indexKey) 127 if (!indexKey)
127 return; 128 return;
128 129
129 if (!indexMetadata.multiEntry || indexKey->type() != IDBKey::ArrayType) { 130 if (!indexMetadata.multiEntry || indexKey->type() != IDBKey::ArrayType) {
130 if (!indexKey->isValid()) 131 if (!indexKey->isValid())
131 return; 132 return;
132 133
133 indexKeys->append(indexKey); 134 indexKeys->append(indexKey);
134 } else { 135 } else {
(...skipping 13 matching lines...) Expand all
148 } 149 }
149 150
150 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, const ScriptValue& val ue, const ScriptValue& key, ExceptionState& exceptionState) 151 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, const ScriptValue& val ue, const ScriptValue& key, ExceptionState& exceptionState)
151 { 152 {
152 IDB_TRACE("IDBObjectStore::put"); 153 IDB_TRACE("IDBObjectStore::put");
153 return put(scriptState, WebIDBPutModeAddOrUpdate, IDBAny::create(this), valu e, key, exceptionState); 154 return put(scriptState, WebIDBPutModeAddOrUpdate, IDBAny::create(this), valu e, key, exceptionState);
154 } 155 }
155 156
156 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode, IDBAny* source, const ScriptValue& value, const ScriptValue& keyValue, Exceptio nState& exceptionState) 157 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode, IDBAny* source, const ScriptValue& value, const ScriptValue& keyValue, Exceptio nState& exceptionState)
157 { 158 {
158 IDBKey* key = keyValue.isUndefined() ? nullptr : keyValue.to<IDBKey*>(except ionState); 159 IDBKey* key = keyValue.isUndefined() ? nullptr : ScriptValue::to<IDBKey*>(sc riptState->isolate(), keyValue, exceptionState);
159 return put(scriptState, putMode, source, value, key, exceptionState); 160 return put(scriptState, putMode, source, value, key, exceptionState);
160 } 161 }
161 162
162 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode, IDBAny* source, const ScriptValue& value, IDBKey* key, ExceptionState& exceptio nState) 163 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode, IDBAny* source, const ScriptValue& value, IDBKey* key, ExceptionState& exceptio nState)
163 { 164 {
164 if (isDeleted()) { 165 if (isDeleted()) {
165 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); 166 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage);
166 return 0; 167 return 0;
167 } 168 }
168 if (m_transaction->isFinished() || m_transaction->isFinishing()) { 169 if (m_transaction->isFinished() || m_transaction->isFinishing()) {
(...skipping 26 matching lines...) Expand all
195 if (putMode != WebIDBPutModeCursorUpdate && usesInLineKeys && key) { 196 if (putMode != WebIDBPutModeCursorUpdate && usesInLineKeys && key) {
196 exceptionState.throwDOMException(DataError, "The object store uses in-li ne keys and the key parameter was provided."); 197 exceptionState.throwDOMException(DataError, "The object store uses in-li ne keys and the key parameter was provided.");
197 return 0; 198 return 0;
198 } 199 }
199 200
200 // This test logically belongs in IDBCursor, but must operate on the cloned value. 201 // This test logically belongs in IDBCursor, but must operate on the cloned value.
201 if (putMode == WebIDBPutModeCursorUpdate && usesInLineKeys) { 202 if (putMode == WebIDBPutModeCursorUpdate && usesInLineKeys) {
202 ASSERT(key); 203 ASSERT(key);
203 if (clone.isEmpty()) 204 if (clone.isEmpty())
204 clone = deserializeScriptValue(scriptState, serializedValue.get(), & blobInfo); 205 clone = deserializeScriptValue(scriptState, serializedValue.get(), & blobInfo);
205 IDBKey* keyPathKey = createIDBKeyFromScriptValueAndKeyPath(scriptState-> isolate(), clone, keyPath); 206 IDBKey* keyPathKey = ScriptValue::to<IDBKey*>(scriptState->isolate(), cl one, exceptionState, keyPath);
206 if (!keyPathKey || !keyPathKey->isEqual(key)) { 207 if (!keyPathKey || !keyPathKey->isEqual(key)) {
207 exceptionState.throwDOMException(DataError, "The effective object st ore of this cursor uses in-line keys and evaluating the key path of the value pa rameter results in a different value than the cursor's effective key."); 208 exceptionState.throwDOMException(DataError, "The effective object st ore of this cursor uses in-line keys and evaluating the key path of the value pa rameter results in a different value than the cursor's effective key.");
208 return nullptr; 209 return nullptr;
209 } 210 }
210 } 211 }
211 212
212 if (!usesInLineKeys && !hasKeyGenerator && !key) { 213 if (!usesInLineKeys && !hasKeyGenerator && !key) {
213 exceptionState.throwDOMException(DataError, "The object store uses out-o f-line keys and has no key generator and the key parameter was not provided."); 214 exceptionState.throwDOMException(DataError, "The object store uses out-o f-line keys and has no key generator and the key parameter was not provided.");
214 return 0; 215 return 0;
215 } 216 }
216 if (usesInLineKeys) { 217 if (usesInLineKeys) {
217 if (clone.isEmpty()) 218 if (clone.isEmpty())
218 clone = deserializeScriptValue(scriptState, serializedValue.get(), & blobInfo); 219 clone = deserializeScriptValue(scriptState, serializedValue.get(), & blobInfo);
219 IDBKey* keyPathKey = createIDBKeyFromScriptValueAndKeyPath(scriptState-> isolate(), clone, keyPath); 220 IDBKey* keyPathKey = ScriptValue::to<IDBKey*>(scriptState->isolate(), cl one, exceptionState, keyPath);
220 if (keyPathKey && !keyPathKey->isValid()) { 221 if (keyPathKey && !keyPathKey->isValid()) {
221 exceptionState.throwDOMException(DataError, "Evaluating the object s tore's key path yielded a value that is not a valid key."); 222 exceptionState.throwDOMException(DataError, "Evaluating the object s tore's key path yielded a value that is not a valid key.");
222 return 0; 223 return 0;
223 } 224 }
224 if (!hasKeyGenerator && !keyPathKey) { 225 if (!hasKeyGenerator && !keyPathKey) {
225 exceptionState.throwDOMException(DataError, "Evaluating the object s tore's key path did not yield a value."); 226 exceptionState.throwDOMException(DataError, "Evaluating the object s tore's key path did not yield a value.");
226 return 0; 227 return 0;
227 } 228 }
228 if (hasKeyGenerator && !keyPathKey) { 229 if (hasKeyGenerator && !keyPathKey) {
229 if (!canInjectIDBKeyIntoScriptValue(scriptState->isolate(), clone, k eyPath)) { 230 if (!canInjectIDBKeyIntoScriptValue(scriptState->isolate(), clone, k eyPath)) {
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 } 670 }
670 return IDBIndexMetadata::InvalidId; 671 return IDBIndexMetadata::InvalidId;
671 } 672 }
672 673
673 WebIDBDatabase* IDBObjectStore::backendDB() const 674 WebIDBDatabase* IDBObjectStore::backendDB() const
674 { 675 {
675 return m_transaction->backendDB(); 676 return m_transaction->backendDB();
676 } 677 }
677 678
678 } // namespace blink 679 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBKeyRange.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698