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 22 matching lines...) Expand all Loading... | |
33 #include "core/dom/DOMStringList.h" | 33 #include "core/dom/DOMStringList.h" |
34 #include "core/dom/ExceptionCode.h" | 34 #include "core/dom/ExceptionCode.h" |
35 #include "core/dom/ExecutionContext.h" | 35 #include "core/dom/ExecutionContext.h" |
36 #include "modules/indexeddb/IDBAny.h" | 36 #include "modules/indexeddb/IDBAny.h" |
37 #include "modules/indexeddb/IDBCursorWithValue.h" | 37 #include "modules/indexeddb/IDBCursorWithValue.h" |
38 #include "modules/indexeddb/IDBDatabase.h" | 38 #include "modules/indexeddb/IDBDatabase.h" |
39 #include "modules/indexeddb/IDBKeyPath.h" | 39 #include "modules/indexeddb/IDBKeyPath.h" |
40 #include "modules/indexeddb/IDBTracing.h" | 40 #include "modules/indexeddb/IDBTracing.h" |
41 #include "modules/indexeddb/WebIDBCallbacksImpl.h" | 41 #include "modules/indexeddb/WebIDBCallbacksImpl.h" |
42 #include "platform/SharedBuffer.h" | 42 #include "platform/SharedBuffer.h" |
43 #include "public/platform/WebBlobInfo.h" | |
43 #include "public/platform/WebData.h" | 44 #include "public/platform/WebData.h" |
44 #include "public/platform/WebIDBKey.h" | 45 #include "public/platform/WebIDBKey.h" |
45 #include "public/platform/WebIDBKeyRange.h" | 46 #include "public/platform/WebIDBKeyRange.h" |
47 #include "public/platform/WebVector.h" | |
46 | 48 |
49 using blink::WebBlobInfo; | |
47 using blink::WebIDBCallbacks; | 50 using blink::WebIDBCallbacks; |
48 using blink::WebIDBCursor; | 51 using blink::WebIDBCursor; |
49 using blink::WebIDBDatabase; | 52 using blink::WebIDBDatabase; |
53 using blink::WebVector; | |
50 | 54 |
51 namespace WebCore { | 55 namespace WebCore { |
52 | 56 |
53 IDBObjectStore::IDBObjectStore(const IDBObjectStoreMetadata& metadata, IDBTransa ction* transaction) | 57 IDBObjectStore::IDBObjectStore(const IDBObjectStoreMetadata& metadata, IDBTransa ction* transaction) |
54 : m_metadata(metadata) | 58 : m_metadata(metadata) |
55 , m_transaction(transaction) | 59 , m_transaction(transaction) |
56 , m_deleted(false) | 60 , m_deleted(false) |
57 { | 61 { |
58 ASSERT(m_transaction); | 62 ASSERT(m_transaction); |
59 // We pass a reference to this object before it can be adopted. | 63 // We pass a reference to this object before it can be adopted. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 } | 166 } |
163 if (!m_transaction->isActive()) { | 167 if (!m_transaction->isActive()) { |
164 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); | 168 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase:: transactionInactiveErrorMessage); |
165 return nullptr; | 169 return nullptr; |
166 } | 170 } |
167 if (m_transaction->isReadOnly()) { | 171 if (m_transaction->isReadOnly()) { |
168 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction ReadOnlyErrorMessage); | 172 exceptionState.throwDOMException(ReadOnlyError, IDBDatabase::transaction ReadOnlyErrorMessage); |
169 return nullptr; | 173 return nullptr; |
170 } | 174 } |
171 | 175 |
172 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::creat e(value, 0, exceptionState, toIsolate(executionContext)); | 176 Vector<WebBlobInfo> blobInfo; |
177 | |
178 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::creat e(value, &blobInfo, exceptionState, toIsolate(executionContext)); | |
173 if (exceptionState.hadException()) | 179 if (exceptionState.hadException()) |
174 return nullptr; | 180 return nullptr; |
175 | 181 |
182 | |
jsbell
2014/04/30 21:38:33
remove extra blank line
ericu
2014/04/30 22:30:44
Done.
| |
176 if (serializedValue->containsBlobs()) { | 183 if (serializedValue->containsBlobs()) { |
177 // FIXME: Add Blob/File/FileList support | 184 // FIXME: Add Blob/File/FileList support |
178 exceptionState.throwDOMException(DataCloneError, "The object store curre ntly does not support blob values."); | 185 exceptionState.throwDOMException(DataCloneError, "The object store curre ntly does not support blob values."); |
179 return nullptr; | 186 return nullptr; |
180 } | 187 } |
188 ASSERT(blobInfo.isEmpty()); | |
181 | 189 |
182 const IDBKeyPath& keyPath = m_metadata.keyPath; | 190 const IDBKeyPath& keyPath = m_metadata.keyPath; |
183 const bool usesInLineKeys = !keyPath.isNull(); | 191 const bool usesInLineKeys = !keyPath.isNull(); |
184 const bool hasKeyGenerator = autoIncrement(); | 192 const bool hasKeyGenerator = autoIncrement(); |
185 | 193 |
186 if (putMode != WebIDBDatabase::CursorUpdate && usesInLineKeys && key) { | 194 if (putMode != WebIDBDatabase::CursorUpdate && usesInLineKeys && key) { |
187 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."); |
188 return nullptr; | 196 return nullptr; |
189 } | 197 } |
190 if (!usesInLineKeys && !hasKeyGenerator && !key) { | 198 if (!usesInLineKeys && !hasKeyGenerator && !key) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 IndexKeys keys; | 234 IndexKeys keys; |
227 generateIndexKeysForValue(toIsolate(executionContext), it->value, value, &keys); | 235 generateIndexKeysForValue(toIsolate(executionContext), it->value, value, &keys); |
228 indexIds.append(it->key); | 236 indexIds.append(it->key); |
229 indexKeys.append(keys); | 237 indexKeys.append(keys); |
230 } | 238 } |
231 | 239 |
232 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(executionContext , source, m_transaction.get()); | 240 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(executionContext , source, m_transaction.get()); |
233 Vector<char> wireBytes; | 241 Vector<char> wireBytes; |
234 serializedValue->toWireBytes(wireBytes); | 242 serializedValue->toWireBytes(wireBytes); |
235 RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes); | 243 RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes); |
236 backendDB()->put(m_transaction->id(), id(), blink::WebData(valueBuffer), key .release(), static_cast<WebIDBDatabase::PutMode>(putMode), WebIDBCallbacksImpl:: create(request).leakPtr(), indexIds, indexKeys); | 244 |
245 WebVector<WebBlobInfo> webBlobInfo(blobInfo.size()); | |
246 for (size_t i = 0; i < blobInfo.size(); ++i) { | |
247 const WebBlobInfo& info = blobInfo[i]; | |
248 if (info.isFile()) | |
jsbell
2014/04/30 21:38:33
Move this to a WebBlobInfo(const WebBlobInfo&) con
ericu
2014/04/30 22:30:44
Heh; it turns out that this dates back to when I w
| |
249 webBlobInfo[i] = WebBlobInfo(info.uuid(), info.filePath(), info.file Name(), info.type()); | |
250 else | |
251 webBlobInfo[i] = WebBlobInfo(info.uuid(), info.type(), info.size()); | |
252 } | |
253 | |
254 backendDB()->put(m_transaction->id(), id(), blink::WebData(valueBuffer), web BlobInfo, key.release(), static_cast<WebIDBDatabase::PutMode>(putMode), WebIDBCa llbacksImpl::create(request).leakPtr(), indexIds, indexKeys); | |
237 return request.release(); | 255 return request.release(); |
238 } | 256 } |
239 | 257 |
240 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::deleteFunction(ExecutionConte xt* context, const ScriptValue& key, ExceptionState& exceptionState) | 258 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::deleteFunction(ExecutionConte xt* context, const ScriptValue& key, ExceptionState& exceptionState) |
241 { | 259 { |
242 IDB_TRACE("IDBObjectStore::delete"); | 260 IDB_TRACE("IDBObjectStore::delete"); |
243 if (isDeleted()) { | 261 if (isDeleted()) { |
244 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); | 262 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); |
245 return nullptr; | 263 return nullptr; |
246 } | 264 } |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
656 } | 674 } |
657 return IDBIndexMetadata::InvalidId; | 675 return IDBIndexMetadata::InvalidId; |
658 } | 676 } |
659 | 677 |
660 WebIDBDatabase* IDBObjectStore::backendDB() const | 678 WebIDBDatabase* IDBObjectStore::backendDB() const |
661 { | 679 { |
662 return m_transaction->backendDB(); | 680 return m_transaction->backendDB(); |
663 } | 681 } |
664 | 682 |
665 } // namespace WebCore | 683 } // namespace WebCore |
OLD | NEW |