| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "modules/indexeddb/IDBCursor.h" | 27 #include "modules/indexeddb/IDBCursor.h" |
| 28 | 28 |
| 29 #include "bindings/core/v8/ExceptionState.h" | 29 #include "bindings/core/v8/ExceptionState.h" |
| 30 #include "bindings/core/v8/ScriptState.h" | 30 #include "bindings/core/v8/ScriptState.h" |
| 31 #include "bindings/modules/v8/IDBBindingUtilities.h" | 31 #include "bindings/modules/v8/IDBBindingUtilities.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/IndexedDBNames.h" |
| 35 #include "modules/indexeddb/IDBAny.h" | 36 #include "modules/indexeddb/IDBAny.h" |
| 36 #include "modules/indexeddb/IDBDatabase.h" | 37 #include "modules/indexeddb/IDBDatabase.h" |
| 37 #include "modules/indexeddb/IDBObjectStore.h" | 38 #include "modules/indexeddb/IDBObjectStore.h" |
| 38 #include "modules/indexeddb/IDBTracing.h" | 39 #include "modules/indexeddb/IDBTracing.h" |
| 39 #include "modules/indexeddb/IDBTransaction.h" | 40 #include "modules/indexeddb/IDBTransaction.h" |
| 40 #include "modules/indexeddb/WebIDBCallbacksImpl.h" | 41 #include "modules/indexeddb/WebIDBCallbacksImpl.h" |
| 41 #include "public/platform/WebBlobInfo.h" | 42 #include "public/platform/WebBlobInfo.h" |
| 42 #include "public/platform/WebIDBDatabase.h" | 43 #include "public/platform/WebIDBDatabase.h" |
| 43 #include "public/platform/WebIDBKeyRange.h" | 44 #include "public/platform/WebIDBKeyRange.h" |
| 44 #include <limits> | 45 #include <limits> |
| 45 | 46 |
| 46 using blink::WebIDBCursor; | 47 using blink::WebIDBCursor; |
| 47 using blink::WebIDBDatabase; | 48 using blink::WebIDBDatabase; |
| 48 | 49 |
| 49 namespace blink { | 50 namespace blink { |
| 50 | 51 |
| 51 IDBCursor* IDBCursor::create(PassOwnPtr<blink::WebIDBCursor> backend, blink::Web
IDBCursorDirection direction, IDBRequest* request, IDBAny* source, IDBTransactio
n* transaction) | 52 IDBCursor* IDBCursor::create(PassOwnPtr<blink::WebIDBCursor> backend, blink::Web
IDBCursorDirection direction, IDBRequest* request, IDBAny* source, IDBTransactio
n* transaction) |
| 52 { | 53 { |
| 53 return new IDBCursor(backend, direction, request, source, transaction); | 54 return new IDBCursor(backend, direction, request, source, transaction); |
| 54 } | 55 } |
| 55 | 56 |
| 56 const AtomicString& IDBCursor::directionNext() | |
| 57 { | |
| 58 DEFINE_STATIC_LOCAL(AtomicString, next, ("next", AtomicString::ConstructFrom
Literal)); | |
| 59 return next; | |
| 60 } | |
| 61 | |
| 62 const AtomicString& IDBCursor::directionNextUnique() | |
| 63 { | |
| 64 DEFINE_STATIC_LOCAL(AtomicString, nextunique, ("nextunique", AtomicString::C
onstructFromLiteral)); | |
| 65 return nextunique; | |
| 66 } | |
| 67 | |
| 68 const AtomicString& IDBCursor::directionPrev() | |
| 69 { | |
| 70 DEFINE_STATIC_LOCAL(AtomicString, prev, ("prev", AtomicString::ConstructFrom
Literal)); | |
| 71 return prev; | |
| 72 } | |
| 73 | |
| 74 const AtomicString& IDBCursor::directionPrevUnique() | |
| 75 { | |
| 76 DEFINE_STATIC_LOCAL(AtomicString, prevunique, ("prevunique", AtomicString::C
onstructFromLiteral)); | |
| 77 return prevunique; | |
| 78 } | |
| 79 | |
| 80 IDBCursor::IDBCursor(PassOwnPtr<blink::WebIDBCursor> backend, blink::WebIDBCurso
rDirection direction, IDBRequest* request, IDBAny* source, IDBTransaction* trans
action) | 57 IDBCursor::IDBCursor(PassOwnPtr<blink::WebIDBCursor> backend, blink::WebIDBCurso
rDirection direction, IDBRequest* request, IDBAny* source, IDBTransaction* trans
action) |
| 81 : m_backend(backend) | 58 : m_backend(backend) |
| 82 , m_request(request) | 59 , m_request(request) |
| 83 , m_direction(direction) | 60 , m_direction(direction) |
| 84 , m_source(source) | 61 , m_source(source) |
| 85 , m_transaction(transaction) | 62 , m_transaction(transaction) |
| 86 , m_gotValue(false) | 63 , m_gotValue(false) |
| 87 , m_keyDirty(true) | 64 , m_keyDirty(true) |
| 88 , m_primaryKeyDirty(true) | 65 , m_primaryKeyDirty(true) |
| 89 , m_valueDirty(true) | 66 , m_valueDirty(true) |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 ASSERT(m_request || !m_blobInfo || !m_blobInfo->size()); | 352 ASSERT(m_request || !m_blobInfo || !m_blobInfo->size()); |
| 376 if (m_blobInfo.get() && m_blobInfo->size()) { | 353 if (m_blobInfo.get() && m_blobInfo->size()) { |
| 377 ASSERT(m_request); | 354 ASSERT(m_request); |
| 378 m_transaction->db()->ackReceivedBlobs(m_blobInfo.get()); | 355 m_transaction->db()->ackReceivedBlobs(m_blobInfo.get()); |
| 379 m_blobInfo.clear(); | 356 m_blobInfo.clear(); |
| 380 } | 357 } |
| 381 } | 358 } |
| 382 | 359 |
| 383 blink::WebIDBCursorDirection IDBCursor::stringToDirection(const String& directio
nString, ExceptionState& exceptionState) | 360 blink::WebIDBCursorDirection IDBCursor::stringToDirection(const String& directio
nString, ExceptionState& exceptionState) |
| 384 { | 361 { |
| 385 if (directionString == IDBCursor::directionNext()) | 362 if (directionString == IndexedDBNames::next) |
| 386 return blink::WebIDBCursorDirectionNext; | 363 return blink::WebIDBCursorDirectionNext; |
| 387 if (directionString == IDBCursor::directionNextUnique()) | 364 if (directionString == IndexedDBNames::nextunique) |
| 388 return blink::WebIDBCursorDirectionNextNoDuplicate; | 365 return blink::WebIDBCursorDirectionNextNoDuplicate; |
| 389 if (directionString == IDBCursor::directionPrev()) | 366 if (directionString == IndexedDBNames::prev) |
| 390 return blink::WebIDBCursorDirectionPrev; | 367 return blink::WebIDBCursorDirectionPrev; |
| 391 if (directionString == IDBCursor::directionPrevUnique()) | 368 if (directionString == IndexedDBNames::prevunique) |
| 392 return blink::WebIDBCursorDirectionPrevNoDuplicate; | 369 return blink::WebIDBCursorDirectionPrevNoDuplicate; |
| 393 | 370 |
| 394 exceptionState.throwTypeError("The direction provided ('" + directionString
+ "') is not one of 'next', 'nextunique', 'prev', or 'prevunique'."); | 371 exceptionState.throwTypeError("The direction provided ('" + directionString
+ "') is not one of 'next', 'nextunique', 'prev', or 'prevunique'."); |
| 395 return blink::WebIDBCursorDirectionNext; | 372 return blink::WebIDBCursorDirectionNext; |
| 396 } | 373 } |
| 397 | 374 |
| 398 const AtomicString& IDBCursor::directionToString(unsigned short direction) | 375 const String& IDBCursor::direction() const |
| 399 { | 376 { |
| 400 switch (direction) { | 377 switch (m_direction) { |
| 401 case blink::WebIDBCursorDirectionNext: | 378 case blink::WebIDBCursorDirectionNext: |
| 402 return IDBCursor::directionNext(); | 379 return IndexedDBNames::next; |
| 403 | 380 |
| 404 case blink::WebIDBCursorDirectionNextNoDuplicate: | 381 case blink::WebIDBCursorDirectionNextNoDuplicate: |
| 405 return IDBCursor::directionNextUnique(); | 382 return IndexedDBNames::nextunique; |
| 406 | 383 |
| 407 case blink::WebIDBCursorDirectionPrev: | 384 case blink::WebIDBCursorDirectionPrev: |
| 408 return IDBCursor::directionPrev(); | 385 return IndexedDBNames::prev; |
| 409 | 386 |
| 410 case blink::WebIDBCursorDirectionPrevNoDuplicate: | 387 case blink::WebIDBCursorDirectionPrevNoDuplicate: |
| 411 return IDBCursor::directionPrevUnique(); | 388 return IndexedDBNames::prevunique; |
| 412 | 389 |
| 413 default: | 390 default: |
| 414 ASSERT_NOT_REACHED(); | 391 ASSERT_NOT_REACHED(); |
| 415 return IDBCursor::directionNext(); | 392 return IndexedDBNames::next; |
| 416 } | 393 } |
| 417 } | 394 } |
| 418 | 395 |
| 419 } // namespace blink | 396 } // namespace blink |
| OLD | NEW |