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 20 matching lines...) Expand all Loading... | |
31 #include "bindings/v8/ScriptState.h" | 31 #include "bindings/v8/ScriptState.h" |
32 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
33 #include "core/dom/ExecutionContext.h" | 33 #include "core/dom/ExecutionContext.h" |
34 #include "core/inspector/ScriptCallStack.h" | 34 #include "core/inspector/ScriptCallStack.h" |
35 #include "modules/indexeddb/IDBAny.h" | 35 #include "modules/indexeddb/IDBAny.h" |
36 #include "modules/indexeddb/IDBDatabase.h" | 36 #include "modules/indexeddb/IDBDatabase.h" |
37 #include "modules/indexeddb/IDBObjectStore.h" | 37 #include "modules/indexeddb/IDBObjectStore.h" |
38 #include "modules/indexeddb/IDBTracing.h" | 38 #include "modules/indexeddb/IDBTracing.h" |
39 #include "modules/indexeddb/IDBTransaction.h" | 39 #include "modules/indexeddb/IDBTransaction.h" |
40 #include "modules/indexeddb/WebIDBCallbacksImpl.h" | 40 #include "modules/indexeddb/WebIDBCallbacksImpl.h" |
41 #include "public/platform/WebBlobInfo.h" | |
41 #include "public/platform/WebIDBDatabase.h" | 42 #include "public/platform/WebIDBDatabase.h" |
42 #include "public/platform/WebIDBKeyRange.h" | 43 #include "public/platform/WebIDBKeyRange.h" |
43 #include <limits> | 44 #include <limits> |
44 | 45 |
45 using blink::WebIDBCursor; | 46 using blink::WebIDBCursor; |
46 using blink::WebIDBDatabase; | 47 using blink::WebIDBDatabase; |
47 | 48 |
48 namespace WebCore { | 49 namespace WebCore { |
49 | 50 |
50 PassRefPtr<IDBCursor> IDBCursor::create(PassOwnPtr<blink::WebIDBCursor> backend, WebIDBCursor::Direction direction, IDBRequest* request, IDBAny* source, IDBTran saction* transaction) | 51 PassRefPtr<IDBCursor> IDBCursor::create(PassOwnPtr<blink::WebIDBCursor> backend, WebIDBCursor::Direction direction, IDBRequest* request, IDBAny* source, IDBTran saction* transaction) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 { | 90 { |
90 ASSERT(m_backend); | 91 ASSERT(m_backend); |
91 ASSERT(m_request); | 92 ASSERT(m_request); |
92 ASSERT(m_source->type() == IDBAny::IDBObjectStoreType || m_source->type() == IDBAny::IDBIndexType); | 93 ASSERT(m_source->type() == IDBAny::IDBObjectStoreType || m_source->type() == IDBAny::IDBIndexType); |
93 ASSERT(m_transaction); | 94 ASSERT(m_transaction); |
94 ScriptWrappable::init(this); | 95 ScriptWrappable::init(this); |
95 } | 96 } |
96 | 97 |
97 IDBCursor::~IDBCursor() | 98 IDBCursor::~IDBCursor() |
98 { | 99 { |
100 handleBlobAcks(); | |
99 } | 101 } |
100 | 102 |
101 PassRefPtr<IDBRequest> IDBCursor::update(ScriptState* state, ScriptValue& value, ExceptionState& exceptionState) | 103 PassRefPtr<IDBRequest> IDBCursor::update(ScriptState* state, ScriptValue& value, ExceptionState& exceptionState) |
102 { | 104 { |
103 IDB_TRACE("IDBCursor::update"); | 105 IDB_TRACE("IDBCursor::update"); |
104 | 106 |
105 if (!m_gotValue) { | 107 if (!m_gotValue) { |
106 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue ErrorMessage); | 108 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::noValue ErrorMessage); |
107 return nullptr; | 109 return nullptr; |
108 } | 110 } |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 } | 323 } |
322 | 324 |
323 ScriptValue IDBCursor::value(NewScriptState* scriptState) | 325 ScriptValue IDBCursor::value(NewScriptState* scriptState) |
324 { | 326 { |
325 ASSERT(isCursorWithValue()); | 327 ASSERT(isCursorWithValue()); |
326 | 328 |
327 RefPtr<IDBObjectStore> objectStore = effectiveObjectStore(); | 329 RefPtr<IDBObjectStore> objectStore = effectiveObjectStore(); |
328 const IDBObjectStoreMetadata& metadata = objectStore->metadata(); | 330 const IDBObjectStoreMetadata& metadata = objectStore->metadata(); |
329 RefPtr<IDBAny> value; | 331 RefPtr<IDBAny> value; |
330 if (metadata.autoIncrement && !metadata.keyPath.isNull()) { | 332 if (metadata.autoIncrement && !metadata.keyPath.isNull()) { |
331 value = IDBAny::create(m_value, m_primaryKey, metadata.keyPath); | 333 value = IDBAny::create(m_value, m_blobInfo.get(), m_primaryKey, metadata .keyPath); |
332 #ifndef NDEBUG | 334 #ifndef NDEBUG |
333 assertPrimaryKeyValidOrInjectable(scriptState, m_value, m_primaryKey, me tadata.keyPath); | 335 assertPrimaryKeyValidOrInjectable(scriptState, m_value, m_blobInfo.get() , m_primaryKey, metadata.keyPath); |
334 #endif | 336 #endif |
335 } else { | 337 } else { |
336 value = IDBAny::create(m_value); | 338 value = IDBAny::create(m_value, m_blobInfo.get()); |
337 } | 339 } |
338 | 340 |
339 m_valueDirty = false; | 341 m_valueDirty = false; |
340 return idbAnyToScriptValue(scriptState, value); | 342 ScriptValue scriptValue = idbAnyToScriptValue(scriptState, value); |
343 handleBlobAcks(); | |
344 return scriptValue; | |
341 } | 345 } |
342 | 346 |
343 ScriptValue IDBCursor::source(NewScriptState* scriptState) const | 347 ScriptValue IDBCursor::source(NewScriptState* scriptState) const |
344 { | 348 { |
345 return idbAnyToScriptValue(scriptState, m_source); | 349 return idbAnyToScriptValue(scriptState, m_source); |
346 } | 350 } |
347 | 351 |
348 void IDBCursor::setValueReady(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primary Key, PassRefPtr<SharedBuffer> value) | 352 void IDBCursor::setValueReady(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primary Key, PassRefPtr<SharedBuffer> value, PassOwnPtr<Vector<blink::WebBlobInfo> > blo bInfo) |
349 { | 353 { |
350 m_key = key; | 354 m_key = key; |
351 m_keyDirty = true; | 355 m_keyDirty = true; |
352 | 356 |
353 m_primaryKey = primaryKey; | 357 m_primaryKey = primaryKey; |
354 m_primaryKeyDirty = true; | 358 m_primaryKeyDirty = true; |
355 | 359 |
356 if (isCursorWithValue()) { | 360 if (isCursorWithValue()) { |
357 m_value = value; | 361 m_value = value; |
362 m_blobInfo = blobInfo; | |
358 m_valueDirty = true; | 363 m_valueDirty = true; |
359 } | 364 } |
360 | 365 |
361 m_gotValue = true; | 366 m_gotValue = true; |
362 } | 367 } |
363 | 368 |
364 PassRefPtr<IDBObjectStore> IDBCursor::effectiveObjectStore() const | 369 PassRefPtr<IDBObjectStore> IDBCursor::effectiveObjectStore() const |
365 { | 370 { |
366 if (m_source->type() == IDBAny::IDBObjectStoreType) | 371 if (m_source->type() == IDBAny::IDBObjectStoreType) |
367 return m_source->idbObjectStore(); | 372 return m_source->idbObjectStore(); |
368 RefPtr<IDBIndex> index = m_source->idbIndex(); | 373 RefPtr<IDBIndex> index = m_source->idbIndex(); |
369 return index->objectStore(); | 374 return index->objectStore(); |
370 } | 375 } |
371 | 376 |
372 bool IDBCursor::isDeleted() const | 377 bool IDBCursor::isDeleted() const |
373 { | 378 { |
374 if (m_source->type() == IDBAny::IDBObjectStoreType) | 379 if (m_source->type() == IDBAny::IDBObjectStoreType) |
375 return m_source->idbObjectStore()->isDeleted(); | 380 return m_source->idbObjectStore()->isDeleted(); |
376 return m_source->idbIndex()->isDeleted(); | 381 return m_source->idbIndex()->isDeleted(); |
377 } | 382 } |
378 | 383 |
384 void IDBCursor::handleBlobAcks() | |
385 { | |
386 if (m_blobInfo.get() && m_blobInfo->size()) { | |
387 m_request->ackReceivedBlobs(m_blobInfo.get()); | |
jsbell
2014/04/15 18:29:07
I think m_request could be null if called from des
ericu
2014/04/16 23:04:14
Good point; in that case, we'd not only crash, we'
jsbell
2014/04/17 19:00:33
For the reference cycle breaking - although oilpan
| |
388 m_blobInfo.clear(); | |
389 } | |
390 } | |
391 | |
379 WebIDBCursor::Direction IDBCursor::stringToDirection(const String& directionStri ng, ExceptionState& exceptionState) | 392 WebIDBCursor::Direction IDBCursor::stringToDirection(const String& directionStri ng, ExceptionState& exceptionState) |
380 { | 393 { |
381 if (directionString.isNull() || directionString == IDBCursor::directionNext( )) | 394 if (directionString.isNull() || directionString == IDBCursor::directionNext( )) |
382 return WebIDBCursor::Next; | 395 return WebIDBCursor::Next; |
383 if (directionString == IDBCursor::directionNextUnique()) | 396 if (directionString == IDBCursor::directionNextUnique()) |
384 return WebIDBCursor::NextNoDuplicate; | 397 return WebIDBCursor::NextNoDuplicate; |
385 if (directionString == IDBCursor::directionPrev()) | 398 if (directionString == IDBCursor::directionPrev()) |
386 return WebIDBCursor::Prev; | 399 return WebIDBCursor::Prev; |
387 if (directionString == IDBCursor::directionPrevUnique()) | 400 if (directionString == IDBCursor::directionPrevUnique()) |
388 return WebIDBCursor::PrevNoDuplicate; | 401 return WebIDBCursor::PrevNoDuplicate; |
(...skipping 17 matching lines...) Expand all Loading... | |
406 case WebIDBCursor::PrevNoDuplicate: | 419 case WebIDBCursor::PrevNoDuplicate: |
407 return IDBCursor::directionPrevUnique(); | 420 return IDBCursor::directionPrevUnique(); |
408 | 421 |
409 default: | 422 default: |
410 ASSERT_NOT_REACHED(); | 423 ASSERT_NOT_REACHED(); |
411 return IDBCursor::directionNext(); | 424 return IDBCursor::directionNext(); |
412 } | 425 } |
413 } | 426 } |
414 | 427 |
415 } // namespace WebCore | 428 } // namespace WebCore |
OLD | NEW |