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

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

Issue 325683002: [IndexedDB] Use consistent enums on both sides of IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Incorporated review comments as build bot was failing with previous patch. Created 6 years, 6 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
« no previous file with comments | « Source/modules/indexeddb/IDBCursor.h ('k') | Source/modules/indexeddb/IDBCursorWithValue.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 30 matching lines...) Expand all
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::Web IDBCursorDirection direction, IDBRequest* request, IDBAny* source, IDBTransactio n* transaction)
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::WebIDBCurso rDirection direction, IDBRequest* request, IDBAny* source, IDBTransaction* trans action)
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
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::WebIDBPutModeCursorUpdate, IDBAn y::create(this), 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
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::WebIDBCursorDirectionNext || m_direction == bl ink::WebIDBCursorDirectionNextNoDuplicate) {
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
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::WebIDBCursorDirection IDBCursor::stringToDirection(const String& directio nString, ExceptionState& exceptionState)
394 { 394 {
395 if (directionString.isNull() || directionString == IDBCursor::directionNext( )) 395 if (directionString.isNull() || directionString == IDBCursor::directionNext( ))
396 return WebIDBCursor::Next; 396 return blink::WebIDBCursorDirectionNext;
397 if (directionString == IDBCursor::directionNextUnique()) 397 if (directionString == IDBCursor::directionNextUnique())
398 return WebIDBCursor::NextNoDuplicate; 398 return blink::WebIDBCursorDirectionNextNoDuplicate;
399 if (directionString == IDBCursor::directionPrev()) 399 if (directionString == IDBCursor::directionPrev())
400 return WebIDBCursor::Prev; 400 return blink::WebIDBCursorDirectionPrev;
401 if (directionString == IDBCursor::directionPrevUnique()) 401 if (directionString == IDBCursor::directionPrevUnique())
402 return WebIDBCursor::PrevNoDuplicate; 402 return blink::WebIDBCursorDirectionPrevNoDuplicate;
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::WebIDBCursorDirectionNext;
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::WebIDBCursorDirectionNext:
412 return IDBCursor::directionNext(); 412 return IDBCursor::directionNext();
413 413
414 case WebIDBCursor::NextNoDuplicate: 414 case blink::WebIDBCursorDirectionNextNoDuplicate:
415 return IDBCursor::directionNextUnique(); 415 return IDBCursor::directionNextUnique();
416 416
417 case WebIDBCursor::Prev: 417 case blink::WebIDBCursorDirectionPrev:
418 return IDBCursor::directionPrev(); 418 return IDBCursor::directionPrev();
419 419
420 case WebIDBCursor::PrevNoDuplicate: 420 case blink::WebIDBCursorDirectionPrevNoDuplicate:
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
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBCursor.h ('k') | Source/modules/indexeddb/IDBCursorWithValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698