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 30 matching lines...) Expand all Loading... |
41 #include "public/platform/WebBlobInfo.h" | 41 #include "public/platform/WebBlobInfo.h" |
42 #include "public/platform/WebIDBDatabase.h" | 42 #include "public/platform/WebIDBDatabase.h" |
43 #include "public/platform/WebIDBKeyRange.h" | 43 #include "public/platform/WebIDBKeyRange.h" |
44 #include <limits> | 44 #include <limits> |
45 | 45 |
46 using blink::WebIDBCursor; | 46 using blink::WebIDBCursor; |
47 using blink::WebIDBDatabase; | 47 using blink::WebIDBDatabase; |
48 | 48 |
49 namespace WebCore { | 49 namespace WebCore { |
50 | 50 |
51 IDBCursor* IDBCursor::create(PassOwnPtr<blink::WebIDBCursor> backend, WebIDBCurs
or::Direction direction, IDBRequest* request, IDBAny* source, IDBTransaction* tr
ansaction) | 51 IDBCursor* IDBCursor::create(PassOwnPtr<blink::WebIDBCursor> backend, blink::Dir
ection direction, IDBRequest* request, IDBAny* source, IDBTransaction* transacti
on) |
52 { | 52 { |
53 return new IDBCursor(backend, direction, request, source, transaction); | 53 return new IDBCursor(backend, direction, request, source, transaction); |
54 } | 54 } |
55 | 55 |
56 const AtomicString& IDBCursor::directionNext() | 56 const AtomicString& IDBCursor::directionNext() |
57 { | 57 { |
58 DEFINE_STATIC_LOCAL(AtomicString, next, ("next", AtomicString::ConstructFrom
Literal)); | 58 DEFINE_STATIC_LOCAL(AtomicString, next, ("next", AtomicString::ConstructFrom
Literal)); |
59 return next; | 59 return next; |
60 } | 60 } |
61 | 61 |
62 const AtomicString& IDBCursor::directionNextUnique() | 62 const AtomicString& IDBCursor::directionNextUnique() |
63 { | 63 { |
64 DEFINE_STATIC_LOCAL(AtomicString, nextunique, ("nextunique", AtomicString::C
onstructFromLiteral)); | 64 DEFINE_STATIC_LOCAL(AtomicString, nextunique, ("nextunique", AtomicString::C
onstructFromLiteral)); |
65 return nextunique; | 65 return nextunique; |
66 } | 66 } |
67 | 67 |
68 const AtomicString& IDBCursor::directionPrev() | 68 const AtomicString& IDBCursor::directionPrev() |
69 { | 69 { |
70 DEFINE_STATIC_LOCAL(AtomicString, prev, ("prev", AtomicString::ConstructFrom
Literal)); | 70 DEFINE_STATIC_LOCAL(AtomicString, prev, ("prev", AtomicString::ConstructFrom
Literal)); |
71 return prev; | 71 return prev; |
72 } | 72 } |
73 | 73 |
74 const AtomicString& IDBCursor::directionPrevUnique() | 74 const AtomicString& IDBCursor::directionPrevUnique() |
75 { | 75 { |
76 DEFINE_STATIC_LOCAL(AtomicString, prevunique, ("prevunique", AtomicString::C
onstructFromLiteral)); | 76 DEFINE_STATIC_LOCAL(AtomicString, prevunique, ("prevunique", AtomicString::C
onstructFromLiteral)); |
77 return prevunique; | 77 return prevunique; |
78 } | 78 } |
79 | 79 |
80 IDBCursor::IDBCursor(PassOwnPtr<blink::WebIDBCursor> backend, WebIDBCursor::Dire
ction direction, IDBRequest* request, IDBAny* source, IDBTransaction* transactio
n) | 80 IDBCursor::IDBCursor(PassOwnPtr<blink::WebIDBCursor> backend, blink::Direction d
irection, IDBRequest* request, IDBAny* source, IDBTransaction* transaction) |
81 : m_backend(backend) | 81 : m_backend(backend) |
82 , m_request(request) | 82 , m_request(request) |
83 , m_direction(direction) | 83 , m_direction(direction) |
84 , m_source(source) | 84 , m_source(source) |
85 , m_transaction(transaction) | 85 , m_transaction(transaction) |
86 , m_gotValue(false) | 86 , m_gotValue(false) |
87 , m_keyDirty(true) | 87 , m_keyDirty(true) |
88 , m_primaryKeyDirty(true) | 88 , m_primaryKeyDirty(true) |
89 , m_valueDirty(true) | 89 , m_valueDirty(true) |
90 { | 90 { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 const IDBKeyPath& keyPath = objectStore->metadata().keyPath; | 142 const IDBKeyPath& keyPath = objectStore->metadata().keyPath; |
143 const bool usesInLineKeys = !keyPath.isNull(); | 143 const bool usesInLineKeys = !keyPath.isNull(); |
144 if (usesInLineKeys) { | 144 if (usesInLineKeys) { |
145 IDBKey* keyPathKey = createIDBKeyFromScriptValueAndKeyPath(scriptState->
isolate(), value, keyPath); | 145 IDBKey* keyPathKey = createIDBKeyFromScriptValueAndKeyPath(scriptState->
isolate(), value, keyPath); |
146 if (!keyPathKey || !keyPathKey->isEqual(m_primaryKey.get())) { | 146 if (!keyPathKey || !keyPathKey->isEqual(m_primaryKey.get())) { |
147 exceptionState.throwDOMException(DataError, "The effective object st
ore of this cursor uses in-line keys and evaluating the key path of the value pa
rameter results in a different value than the cursor's effective key."); | 147 exceptionState.throwDOMException(DataError, "The effective object st
ore of this cursor uses in-line keys and evaluating the key path of the value pa
rameter results in a different value than the cursor's effective key."); |
148 return 0; | 148 return 0; |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 return objectStore->put(scriptState, WebIDBDatabase::CursorUpdate, IDBAny::c
reate(this), value, m_primaryKey, exceptionState); | 152 return objectStore->put(scriptState, blink::CursorUpdate, IDBAny::create(thi
s), value, m_primaryKey, exceptionState); |
153 } | 153 } |
154 | 154 |
155 void IDBCursor::advance(unsigned long count, ExceptionState& exceptionState) | 155 void IDBCursor::advance(unsigned long count, ExceptionState& exceptionState) |
156 { | 156 { |
157 IDB_TRACE("IDBCursor::advance"); | 157 IDB_TRACE("IDBCursor::advance"); |
158 if (!count) { | 158 if (!count) { |
159 exceptionState.throwTypeError("A count argument with value 0 (zero) was
supplied, must be greater than 0."); | 159 exceptionState.throwTypeError("A count argument with value 0 (zero) was
supplied, must be greater than 0."); |
160 return; | 160 return; |
161 } | 161 } |
162 if (!m_gotValue) { | 162 if (!m_gotValue) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 return; | 223 return; |
224 } | 224 } |
225 | 225 |
226 if (isDeleted()) { | 226 if (isDeleted()) { |
227 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceD
eletedErrorMessage); | 227 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::sourceD
eletedErrorMessage); |
228 return; | 228 return; |
229 } | 229 } |
230 | 230 |
231 if (key) { | 231 if (key) { |
232 ASSERT(m_key); | 232 ASSERT(m_key); |
233 if (m_direction == WebIDBCursor::Next || m_direction == WebIDBCursor::Ne
xtNoDuplicate) { | 233 if (m_direction == blink::Next || m_direction == blink::NextNoDuplicate)
{ |
234 const bool ok = m_key->isLessThan(key) | 234 const bool ok = m_key->isLessThan(key) |
235 || (primaryKey && m_key->isEqual(key) && m_primaryKey->isLessTha
n(primaryKey)); | 235 || (primaryKey && m_key->isEqual(key) && m_primaryKey->isLessTha
n(primaryKey)); |
236 if (!ok) { | 236 if (!ok) { |
237 exceptionState.throwDOMException(DataError, "The parameter is le
ss than or equal to this cursor's position."); | 237 exceptionState.throwDOMException(DataError, "The parameter is le
ss than or equal to this cursor's position."); |
238 return; | 238 return; |
239 } | 239 } |
240 | 240 |
241 } else { | 241 } else { |
242 const bool ok = key->isLessThan(m_key.get()) | 242 const bool ok = key->isLessThan(m_key.get()) |
243 || (primaryKey && key->isEqual(m_key.get()) && primaryKey->isLes
sThan(m_primaryKey.get())); | 243 || (primaryKey && key->isEqual(m_key.get()) && primaryKey->isLes
sThan(m_primaryKey.get())); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 void IDBCursor::handleBlobAcks() | 383 void IDBCursor::handleBlobAcks() |
384 { | 384 { |
385 ASSERT(m_request || !m_blobInfo || !m_blobInfo->size()); | 385 ASSERT(m_request || !m_blobInfo || !m_blobInfo->size()); |
386 if (m_blobInfo.get() && m_blobInfo->size()) { | 386 if (m_blobInfo.get() && m_blobInfo->size()) { |
387 ASSERT(m_request); | 387 ASSERT(m_request); |
388 m_transaction->db()->ackReceivedBlobs(m_blobInfo.get()); | 388 m_transaction->db()->ackReceivedBlobs(m_blobInfo.get()); |
389 m_blobInfo.clear(); | 389 m_blobInfo.clear(); |
390 } | 390 } |
391 } | 391 } |
392 | 392 |
393 WebIDBCursor::Direction IDBCursor::stringToDirection(const String& directionStri
ng, ExceptionState& exceptionState) | 393 blink::Direction IDBCursor::stringToDirection(const String& directionString, Exc
eptionState& exceptionState) |
394 { | 394 { |
395 if (directionString.isNull() || directionString == IDBCursor::directionNext(
)) | 395 if (directionString.isNull() || directionString == IDBCursor::directionNext(
)) |
396 return WebIDBCursor::Next; | 396 return blink::Next; |
397 if (directionString == IDBCursor::directionNextUnique()) | 397 if (directionString == IDBCursor::directionNextUnique()) |
398 return WebIDBCursor::NextNoDuplicate; | 398 return blink::NextNoDuplicate; |
399 if (directionString == IDBCursor::directionPrev()) | 399 if (directionString == IDBCursor::directionPrev()) |
400 return WebIDBCursor::Prev; | 400 return blink::Prev; |
401 if (directionString == IDBCursor::directionPrevUnique()) | 401 if (directionString == IDBCursor::directionPrevUnique()) |
402 return WebIDBCursor::PrevNoDuplicate; | 402 return blink::PrevNoDuplicate; |
403 | 403 |
404 exceptionState.throwTypeError("The direction provided ('" + directionString
+ "') is not one of 'next', 'nextunique', 'prev', or 'prevunique'."); | 404 exceptionState.throwTypeError("The direction provided ('" + directionString
+ "') is not one of 'next', 'nextunique', 'prev', or 'prevunique'."); |
405 return WebIDBCursor::Next; | 405 return blink::Next; |
406 } | 406 } |
407 | 407 |
408 const AtomicString& IDBCursor::directionToString(unsigned short direction) | 408 const AtomicString& IDBCursor::directionToString(unsigned short direction) |
409 { | 409 { |
410 switch (direction) { | 410 switch (direction) { |
411 case WebIDBCursor::Next: | 411 case blink::Next: |
412 return IDBCursor::directionNext(); | 412 return IDBCursor::directionNext(); |
413 | 413 |
414 case WebIDBCursor::NextNoDuplicate: | 414 case blink::NextNoDuplicate: |
415 return IDBCursor::directionNextUnique(); | 415 return IDBCursor::directionNextUnique(); |
416 | 416 |
417 case WebIDBCursor::Prev: | 417 case blink::Prev: |
418 return IDBCursor::directionPrev(); | 418 return IDBCursor::directionPrev(); |
419 | 419 |
420 case WebIDBCursor::PrevNoDuplicate: | 420 case blink::PrevNoDuplicate: |
421 return IDBCursor::directionPrevUnique(); | 421 return IDBCursor::directionPrevUnique(); |
422 | 422 |
423 default: | 423 default: |
424 ASSERT_NOT_REACHED(); | 424 ASSERT_NOT_REACHED(); |
425 return IDBCursor::directionNext(); | 425 return IDBCursor::directionNext(); |
426 } | 426 } |
427 } | 427 } |
428 | 428 |
429 } // namespace WebCore | 429 } // namespace WebCore |
OLD | NEW |