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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionI nactiveErrorMessage); | 156 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionI nactiveErrorMessage); |
157 return 0; | 157 return 0; |
158 } | 158 } |
159 if (m_transaction->isReadOnly()) { | 159 if (m_transaction->isReadOnly()) { |
160 es.throwDOMException(ReadOnlyError); | 160 es.throwDOMException(ReadOnlyError); |
161 return 0; | 161 return 0; |
162 } | 162 } |
163 | 163 |
164 // FIXME: Make serialize etc take an ExceptionState or use ScriptState::setD OMException. | 164 // FIXME: Make serialize etc take an ExceptionState or use ScriptState::setD OMException. |
165 bool didThrow = false; | 165 bool didThrow = false; |
166 RefPtr<SerializedScriptValue> serializedValue = value.serialize(state, 0, 0, didThrow); | 166 Vector<BlobInfo> blobInfo; |
167 RefPtr<SerializedScriptValue> serializedValue = value.serialize(state, &blob Info, didThrow); | |
168 ASSERT(serializedValue->blobInfo() == &blobInfo); | |
167 if (didThrow) | 169 if (didThrow) |
168 return 0; | 170 return 0; |
169 | 171 |
170 if (serializedValue->blobURLs().size() > 0) { | |
171 // FIXME: Add Blob/File/FileList support | |
172 es.throwDOMException(DataCloneError); | |
173 return 0; | |
174 } | |
175 | |
176 const IDBKeyPath& keyPath = m_metadata.keyPath; | 172 const IDBKeyPath& keyPath = m_metadata.keyPath; |
177 const bool usesInLineKeys = !keyPath.isNull(); | 173 const bool usesInLineKeys = !keyPath.isNull(); |
178 const bool hasKeyGenerator = autoIncrement(); | 174 const bool hasKeyGenerator = autoIncrement(); |
179 | 175 |
180 ScriptExecutionContext* context = state->scriptExecutionContext(); | 176 ScriptExecutionContext* context = state->scriptExecutionContext(); |
181 DOMRequestState requestState(context); | 177 DOMRequestState requestState(context); |
182 | 178 |
183 if (putMode != IDBDatabaseBackendInterface::CursorUpdate && usesInLineKeys & & key) { | 179 if (putMode != IDBDatabaseBackendInterface::CursorUpdate && usesInLineKeys & & key) { |
184 es.throwDOMException(DataError, "The object store uses in-line keys and the key parameter was provided."); | 180 es.throwDOMException(DataError, "The object store uses in-line keys and the key parameter was provided."); |
185 return 0; | 181 return 0; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 IndexKeys keys; | 214 IndexKeys keys; |
219 generateIndexKeysForValue(&requestState, it->value, value, &keys); | 215 generateIndexKeysForValue(&requestState, it->value, value, &keys); |
220 indexIds.append(it->key); | 216 indexIds.append(it->key); |
221 indexKeys.append(keys); | 217 indexKeys.append(keys); |
222 } | 218 } |
223 | 219 |
224 RefPtr<IDBRequest> request = IDBRequest::create(context, source, m_transacti on.get()); | 220 RefPtr<IDBRequest> request = IDBRequest::create(context, source, m_transacti on.get()); |
225 Vector<char> wireBytes; | 221 Vector<char> wireBytes; |
226 serializedValue->toWireBytes(wireBytes); | 222 serializedValue->toWireBytes(wireBytes); |
227 RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes); | 223 RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes); |
228 backendDB()->put(m_transaction->id(), id(), valueBuffer, key.release(), stat ic_cast<IDBDatabaseBackendInterface::PutMode>(putMode), request, indexIds, index Keys); | 224 backendDB()->put(m_transaction->id(), id(), valueBuffer, serializedValue->bl obInfo(), key.release(), static_cast<IDBDatabaseBackendInterface::PutMode>(putMo de), request, indexIds, indexKeys); |
jsbell
2013/09/12 22:52:17
If we remove m_blobInfo from SSV, this can just th
ericu
2013/11/20 23:06:08
Done.
| |
225 // TODO(ericu): Hold a reference to each blob in serializedValue->blobInfo() | |
jsbell
2013/09/12 22:52:17
Adding a vector of blob refs to IDBTransaction sou
ericu
2013/11/20 23:06:08
Updated TODO.
| |
226 // until the transaction's committed or this value is overwritten or | |
227 // otherwise removed. We have to grab it here, rather than the backend, to | |
228 // avoid a race. Blobs live on the IO thread in the backend, and IDB | |
229 // requests are handled on the IDB task runner; if we grabbed the blob | |
230 // references on the IO thread before switching to the IDB task runner, that | |
231 // would work too, but it's probably safer to have the refs held in the | |
232 // renderer, in case of crashes, request failures, etc. | |
229 return request.release(); | 233 return request.release(); |
230 } | 234 } |
231 | 235 |
232 PassRefPtr<IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* co ntext, const ScriptValue& key, ExceptionState& es) | 236 PassRefPtr<IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* co ntext, const ScriptValue& key, ExceptionState& es) |
233 { | 237 { |
234 IDB_TRACE("IDBObjectStore::delete"); | 238 IDB_TRACE("IDBObjectStore::delete"); |
235 if (isDeleted()) { | 239 if (isDeleted()) { |
236 es.throwDOMException(InvalidStateError, IDBDatabase::objectStoreDeletedE rrorMessage); | 240 es.throwDOMException(InvalidStateError, IDBDatabase::objectStoreDeletedE rrorMessage); |
237 return 0; | 241 return 0; |
238 } | 242 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 | 332 |
329 Vector<int64_t, 1> indexIds; | 333 Vector<int64_t, 1> indexIds; |
330 indexIds.append(m_indexMetadata.id); | 334 indexIds.append(m_indexMetadata.id); |
331 if (cursor) { | 335 if (cursor) { |
332 cursor->continueFunction(static_cast<IDBKey*>(0), ASSERT_NO_EXCEPTIO N); | 336 cursor->continueFunction(static_cast<IDBKey*>(0), ASSERT_NO_EXCEPTIO N); |
333 | 337 |
334 RefPtr<IDBKey> primaryKey = cursor->idbPrimaryKey(); | 338 RefPtr<IDBKey> primaryKey = cursor->idbPrimaryKey(); |
335 ScriptValue value = cursor->value(context); | 339 ScriptValue value = cursor->value(context); |
336 | 340 |
337 IDBObjectStore::IndexKeys indexKeys; | 341 IDBObjectStore::IndexKeys indexKeys; |
338 generateIndexKeysForValue(request->requestState(), m_indexMetadata, value, &indexKeys); | 342 generateIndexKeysForValue(request->requestState(), m_indexMetadata, value, &indexKeys); |
jsbell
2013/09/12 22:52:17
Although it's not obvious in the spec, this needs
ericu
2013/11/20 23:06:08
Ah, I hadn't noticed that the blob properties were
ericu
2013/11/26 00:26:14
OK, I was confused--this is all taking place on th
| |
339 | 343 |
340 Vector<IDBObjectStore::IndexKeys, 1> indexKeysList; | 344 Vector<IDBObjectStore::IndexKeys, 1> indexKeysList; |
341 indexKeysList.append(indexKeys); | 345 indexKeysList.append(indexKeys); |
342 | 346 |
343 m_databaseBackend->setIndexKeys(m_transactionId, m_objectStoreId, pr imaryKey, indexIds, indexKeysList); | 347 m_databaseBackend->setIndexKeys(m_transactionId, m_objectStoreId, pr imaryKey, indexIds, indexKeysList); |
344 } else { | 348 } else { |
345 // Now that we are done indexing, tell the backend to go | 349 // Now that we are done indexing, tell the backend to go |
346 // back to processing tasks of type NormalTask. | 350 // back to processing tasks of type NormalTask. |
347 m_databaseBackend->setIndexesReady(m_transactionId, m_objectStoreId, indexIds); | 351 m_databaseBackend->setIndexesReady(m_transactionId, m_objectStoreId, indexIds); |
348 m_databaseBackend.clear(); | 352 m_databaseBackend.clear(); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 } | 586 } |
583 return IDBIndexMetadata::InvalidId; | 587 return IDBIndexMetadata::InvalidId; |
584 } | 588 } |
585 | 589 |
586 IDBDatabaseBackendInterface* IDBObjectStore::backendDB() const | 590 IDBDatabaseBackendInterface* IDBObjectStore::backendDB() const |
587 { | 591 { |
588 return m_transaction->backendDB(); | 592 return m_transaction->backendDB(); |
589 } | 593 } |
590 | 594 |
591 } // namespace WebCore | 595 } // namespace WebCore |
OLD | NEW |