OLD | NEW |
---|---|
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 } else { | 133 } else { |
134 ASSERT(indexMetadata.multiEntry); | 134 ASSERT(indexMetadata.multiEntry); |
135 ASSERT(indexKey->type() == IDBKey::ArrayType); | 135 ASSERT(indexKey->type() == IDBKey::ArrayType); |
136 indexKey = IDBKey::createMultiEntryArray(indexKey->array()); | 136 indexKey = IDBKey::createMultiEntryArray(indexKey->array()); |
137 | 137 |
138 for (size_t i = 0; i < indexKey->array().size(); ++i) | 138 for (size_t i = 0; i < indexKey->array().size(); ++i) |
139 indexKeys->append(indexKey->array()[i]); | 139 indexKeys->append(indexKey->array()[i]); |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 IDBRequest* IDBObjectStore::add(ScriptState* scriptState, ScriptValue& value, co nst ScriptValue& key, ExceptionState& exceptionState) | 143 IDBRequest* IDBObjectStore::add(ScriptState* scriptState, const ScriptValue& val ue, const ScriptValue& key, ExceptionState& exceptionState) |
144 { | 144 { |
145 IDB_TRACE("IDBObjectStore::add"); | 145 IDB_TRACE("IDBObjectStore::add"); |
146 return put(scriptState, WebIDBPutModeAddOnly, IDBAny::create(this), value, k ey, exceptionState); | 146 return put(scriptState, WebIDBPutModeAddOnly, IDBAny::create(this), value, k ey, exceptionState); |
147 } | 147 } |
148 | 148 |
149 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, ScriptValue& value, co nst ScriptValue& key, ExceptionState& exceptionState) | 149 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, const ScriptValue& val ue, const ScriptValue& key, ExceptionState& exceptionState) |
150 { | 150 { |
151 IDB_TRACE("IDBObjectStore::put"); | 151 IDB_TRACE("IDBObjectStore::put"); |
152 return put(scriptState, WebIDBPutModeAddOrUpdate, IDBAny::create(this), valu e, key, exceptionState); | 152 return put(scriptState, WebIDBPutModeAddOrUpdate, IDBAny::create(this), valu e, key, exceptionState); |
153 } | 153 } |
154 | 154 |
155 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode, IDBAny* source, ScriptValue& value, const ScriptValue& keyValue, ExceptionState & exceptionState) | 155 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode, IDBAny* source, const ScriptValue& value, const ScriptValue& keyValue, Exceptio nState& exceptionState) |
156 { | 156 { |
157 IDBKey* key = keyValue.isUndefined() ? nullptr : scriptValueToIDBKey(scriptS tate->isolate(), keyValue); | 157 IDBKey* key = keyValue.isUndefined() ? nullptr : scriptValueToIDBKey(scriptS tate->isolate(), keyValue); |
158 return put(scriptState, putMode, source, value, key, exceptionState); | 158 return put(scriptState, putMode, source, value, key, exceptionState); |
159 } | 159 } |
160 | 160 |
161 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode, IDBAny* source, ScriptValue& value, IDBKey* key, ExceptionState& exceptionState ) | 161 IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode, IDBAny* source, const ScriptValue& value, IDBKey* key, ExceptionState& exceptio nState) |
162 { | 162 { |
163 if (isDeleted()) { | 163 if (isDeleted()) { |
164 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); | 164 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); |
165 return 0; | 165 return 0; |
166 } | 166 } |
167 if (m_transaction->isFinished() || m_transaction->isFinishing()) { | 167 if (m_transaction->isFinished() || m_transaction->isFinishing()) { |
168 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); | 168 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionFinishedErrorMessage); |
169 return 0; | 169 return 0; |
170 } | 170 } |
171 if (!m_transaction->isActive()) { | 171 if (!m_transaction->isActive()) { |
172 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); | 172 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); |
173 return 0; | 173 return 0; |
174 } | 174 } |
175 if (m_transaction->isReadOnly()) { | 175 if (m_transaction->isReadOnly()) { |
176 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction ReadOnlyErrorMessage); | 176 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction ReadOnlyErrorMessage); |
177 return 0; | 177 return 0; |
178 } | 178 } |
179 | 179 |
180 Vector<WebBlobInfo> blobInfo; | 180 Vector<WebBlobInfo> blobInfo; |
181 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::creat e(value, &blobInfo, exceptionState, scriptState->isolate()); | 181 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::creat e(value, &blobInfo, exceptionState, scriptState->isolate()); |
182 if (exceptionState.hadException()) | 182 if (exceptionState.hadException()) |
183 return 0; | 183 return 0; |
184 | 184 |
185 // Keys that need to be extracted must be taken from a clone so that | 185 // Keys that need to be extracted must be taken from a clone so that |
186 // side effects (i.e. getters) are not triggered. Construct the | 186 // side effects (i.e. getters) are not triggered. Construct the |
187 // clone lazily since the operation may be expensive. | 187 // clone lazily since the operation may be expensive. |
188 ScriptValue clone; | 188 ScriptValue clone; |
189 value.clear(); | |
Jens Widell
2014/08/22 12:06:28
This call had to go when the reference is const. I
jsbell
2014/08/22 16:09:21
That's exactly it.
| |
190 | 189 |
191 const IDBKeyPath& keyPath = m_metadata.keyPath; | 190 const IDBKeyPath& keyPath = m_metadata.keyPath; |
192 const bool usesInLineKeys = !keyPath.isNull(); | 191 const bool usesInLineKeys = !keyPath.isNull(); |
193 const bool hasKeyGenerator = autoIncrement(); | 192 const bool hasKeyGenerator = autoIncrement(); |
194 | 193 |
195 if (putMode != WebIDBPutModeCursorUpdate && usesInLineKeys && key) { | 194 if (putMode != WebIDBPutModeCursorUpdate && usesInLineKeys && key) { |
196 exceptionState.throwDOMException(DataError, "The object store uses in-li ne keys and the key parameter was provided."); | 195 exceptionState.throwDOMException(DataError, "The object store uses in-li ne keys and the key parameter was provided."); |
197 return 0; | 196 return 0; |
198 } | 197 } |
199 | 198 |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
684 } | 683 } |
685 return IDBIndexMetadata::InvalidId; | 684 return IDBIndexMetadata::InvalidId; |
686 } | 685 } |
687 | 686 |
688 WebIDBDatabase* IDBObjectStore::backendDB() const | 687 WebIDBDatabase* IDBObjectStore::backendDB() const |
689 { | 688 { |
690 return m_transaction->backendDB(); | 689 return m_transaction->backendDB(); |
691 } | 690 } |
692 | 691 |
693 } // namespace blink | 692 } // namespace blink |
OLD | NEW |