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

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

Issue 266583002: Switch WebIDBDatabase::put over to the version with blobs. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Even better! Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/modules/indexeddb/WebIDBCallbacksImpl.h » ('j') | 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 22 matching lines...) Expand all
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
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
176 if (serializedValue->containsBlobs()) { 182 if (serializedValue->containsBlobs()) {
177 // FIXME: Add Blob/File/FileList support 183 // FIXME: Add Blob/File/FileList support
178 exceptionState.throwDOMException(DataCloneError, "The object store curre ntly does not support blob values."); 184 exceptionState.throwDOMException(DataCloneError, "The object store curre ntly does not support blob values.");
179 return nullptr; 185 return nullptr;
180 } 186 }
187 ASSERT(blobInfo.isEmpty());
181 188
182 const IDBKeyPath& keyPath = m_metadata.keyPath; 189 const IDBKeyPath& keyPath = m_metadata.keyPath;
183 const bool usesInLineKeys = !keyPath.isNull(); 190 const bool usesInLineKeys = !keyPath.isNull();
184 const bool hasKeyGenerator = autoIncrement(); 191 const bool hasKeyGenerator = autoIncrement();
185 192
186 if (putMode != WebIDBDatabase::CursorUpdate && usesInLineKeys && key) { 193 if (putMode != WebIDBDatabase::CursorUpdate && usesInLineKeys && key) {
187 exceptionState.throwDOMException(DataError, "The object store uses in-li ne keys and the key parameter was provided."); 194 exceptionState.throwDOMException(DataError, "The object store uses in-li ne keys and the key parameter was provided.");
188 return nullptr; 195 return nullptr;
189 } 196 }
190 if (!usesInLineKeys && !hasKeyGenerator && !key) { 197 if (!usesInLineKeys && !hasKeyGenerator && !key) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 IndexKeys keys; 233 IndexKeys keys;
227 generateIndexKeysForValue(toIsolate(executionContext), it->value, value, &keys); 234 generateIndexKeysForValue(toIsolate(executionContext), it->value, value, &keys);
228 indexIds.append(it->key); 235 indexIds.append(it->key);
229 indexKeys.append(keys); 236 indexKeys.append(keys);
230 } 237 }
231 238
232 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(executionContext , source, m_transaction.get()); 239 RefPtrWillBeRawPtr<IDBRequest> request = IDBRequest::create(executionContext , source, m_transaction.get());
233 Vector<char> wireBytes; 240 Vector<char> wireBytes;
234 serializedValue->toWireBytes(wireBytes); 241 serializedValue->toWireBytes(wireBytes);
235 RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes); 242 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); 243
244 backendDB()->put(m_transaction->id(), id(), blink::WebData(valueBuffer), blo bInfo, key.release(), static_cast<WebIDBDatabase::PutMode>(putMode), WebIDBCallb acksImpl::create(request).leakPtr(), indexIds, indexKeys);
237 return request.release(); 245 return request.release();
238 } 246 }
239 247
240 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::deleteFunction(ExecutionConte xt* context, const ScriptValue& key, ExceptionState& exceptionState) 248 PassRefPtrWillBeRawPtr<IDBRequest> IDBObjectStore::deleteFunction(ExecutionConte xt* context, const ScriptValue& key, ExceptionState& exceptionState)
241 { 249 {
242 IDB_TRACE("IDBObjectStore::delete"); 250 IDB_TRACE("IDBObjectStore::delete");
243 if (isDeleted()) { 251 if (isDeleted()) {
244 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage); 252 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectS toreDeletedErrorMessage);
245 return nullptr; 253 return nullptr;
246 } 254 }
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 } 664 }
657 return IDBIndexMetadata::InvalidId; 665 return IDBIndexMetadata::InvalidId;
658 } 666 }
659 667
660 WebIDBDatabase* IDBObjectStore::backendDB() const 668 WebIDBDatabase* IDBObjectStore::backendDB() const
661 { 669 {
662 return m_transaction->backendDB(); 670 return m_transaction->backendDB();
663 } 671 }
664 672
665 } // namespace WebCore 673 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/modules/indexeddb/WebIDBCallbacksImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698