| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 ASSERT(m_objectStore); | 44 ASSERT(m_objectStore); |
| 45 ASSERT(m_transaction); | 45 ASSERT(m_transaction); |
| 46 ASSERT(m_metadata.id != IDBIndexMetadata::InvalidId); | 46 ASSERT(m_metadata.id != IDBIndexMetadata::InvalidId); |
| 47 ScriptWrappable::init(this); | 47 ScriptWrappable::init(this); |
| 48 } | 48 } |
| 49 | 49 |
| 50 IDBIndex::~IDBIndex() | 50 IDBIndex::~IDBIndex() |
| 51 { | 51 { |
| 52 } | 52 } |
| 53 | 53 |
| 54 PassRefPtr<IDBRequest> IDBIndex::openCursor(ExecutionContext* context, const Scr
iptValue& range, const String& directionString, ExceptionState& es) | 54 PassRefPtr<IDBRequest> IDBIndex::openCursor(ExecutionContext* context, const Scr
iptValue& range, const String& directionString, ExceptionState& exceptionState) |
| 55 { | 55 { |
| 56 IDB_TRACE("IDBIndex::openCursor"); | 56 IDB_TRACE("IDBIndex::openCursor"); |
| 57 if (isDeleted()) { | 57 if (isDeleted()) { |
| 58 es.throwDOMException(InvalidStateError, IDBDatabase::indexDeletedErrorMe
ssage); | 58 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe
letedErrorMessage); |
| 59 return 0; | 59 return 0; |
| 60 } | 60 } |
| 61 if (m_transaction->isFinished()) { | 61 if (m_transaction->isFinished()) { |
| 62 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionF
inishedErrorMessage); | 62 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 63 return 0; | 63 return 0; |
| 64 } | 64 } |
| 65 if (!m_transaction->isActive()) { | 65 if (!m_transaction->isActive()) { |
| 66 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionI
nactiveErrorMessage); | 66 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 67 return 0; | 67 return 0; |
| 68 } | 68 } |
| 69 IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directio
nString, es); | 69 IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directio
nString, exceptionState); |
| 70 if (es.hadException()) | 70 if (exceptionState.hadException()) |
| 71 return 0; | 71 return 0; |
| 72 | 72 |
| 73 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(context, range,
es); | 73 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(context, range,
exceptionState); |
| 74 if (es.hadException()) | 74 if (exceptionState.hadException()) |
| 75 return 0; | 75 return 0; |
| 76 | 76 |
| 77 return openCursor(context, keyRange, direction); | 77 return openCursor(context, keyRange, direction); |
| 78 } | 78 } |
| 79 | 79 |
| 80 PassRefPtr<IDBRequest> IDBIndex::openCursor(ExecutionContext* context, PassRefPt
r<IDBKeyRange> keyRange, IndexedDB::CursorDirection direction) | 80 PassRefPtr<IDBRequest> IDBIndex::openCursor(ExecutionContext* context, PassRefPt
r<IDBKeyRange> keyRange, IndexedDB::CursorDirection direction) |
| 81 { | 81 { |
| 82 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), m_transaction.get()); | 82 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), m_transaction.get()); |
| 83 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); | 83 request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction); |
| 84 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata
.id, keyRange, direction, false, IDBDatabaseBackendInterface::NormalTask, reques
t); | 84 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata
.id, keyRange, direction, false, IDBDatabaseBackendInterface::NormalTask, reques
t); |
| 85 return request; | 85 return request; |
| 86 } | 86 } |
| 87 | 87 |
| 88 PassRefPtr<IDBRequest> IDBIndex::count(ExecutionContext* context, const ScriptVa
lue& range, ExceptionState& es) | 88 PassRefPtr<IDBRequest> IDBIndex::count(ExecutionContext* context, const ScriptVa
lue& range, ExceptionState& exceptionState) |
| 89 { | 89 { |
| 90 IDB_TRACE("IDBIndex::count"); | 90 IDB_TRACE("IDBIndex::count"); |
| 91 if (isDeleted()) { | 91 if (isDeleted()) { |
| 92 es.throwDOMException(InvalidStateError, IDBDatabase::indexDeletedErrorMe
ssage); | 92 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe
letedErrorMessage); |
| 93 return 0; | 93 return 0; |
| 94 } | 94 } |
| 95 if (m_transaction->isFinished()) { | 95 if (m_transaction->isFinished()) { |
| 96 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionF
inishedErrorMessage); | 96 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 97 return 0; | 97 return 0; |
| 98 } | 98 } |
| 99 if (!m_transaction->isActive()) { | 99 if (!m_transaction->isActive()) { |
| 100 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionI
nactiveErrorMessage); | 100 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 101 return 0; | 101 return 0; |
| 102 } | 102 } |
| 103 | 103 |
| 104 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(context, range,
es); | 104 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(context, range,
exceptionState); |
| 105 if (es.hadException()) | 105 if (exceptionState.hadException()) |
| 106 return 0; | 106 return 0; |
| 107 | 107 |
| 108 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), m_transaction.get()); | 108 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), m_transaction.get()); |
| 109 backendDB()->count(m_transaction->id(), m_objectStore->id(), m_metadata.id,
keyRange, request); | 109 backendDB()->count(m_transaction->id(), m_objectStore->id(), m_metadata.id,
keyRange, request); |
| 110 return request; | 110 return request; |
| 111 } | 111 } |
| 112 | 112 |
| 113 PassRefPtr<IDBRequest> IDBIndex::openKeyCursor(ExecutionContext* context, const
ScriptValue& range, const String& directionString, ExceptionState& es) | 113 PassRefPtr<IDBRequest> IDBIndex::openKeyCursor(ExecutionContext* context, const
ScriptValue& range, const String& directionString, ExceptionState& exceptionStat
e) |
| 114 { | 114 { |
| 115 IDB_TRACE("IDBIndex::openKeyCursor"); | 115 IDB_TRACE("IDBIndex::openKeyCursor"); |
| 116 if (isDeleted()) { | 116 if (isDeleted()) { |
| 117 es.throwDOMException(InvalidStateError, IDBDatabase::indexDeletedErrorMe
ssage); | 117 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe
letedErrorMessage); |
| 118 return 0; | 118 return 0; |
| 119 } | 119 } |
| 120 if (m_transaction->isFinished()) { | 120 if (m_transaction->isFinished()) { |
| 121 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionF
inishedErrorMessage); | 121 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 122 return 0; | 122 return 0; |
| 123 } | 123 } |
| 124 if (!m_transaction->isActive()) { | 124 if (!m_transaction->isActive()) { |
| 125 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionI
nactiveErrorMessage); | 125 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 126 return 0; | 126 return 0; |
| 127 } | 127 } |
| 128 IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directio
nString, es); | 128 IndexedDB::CursorDirection direction = IDBCursor::stringToDirection(directio
nString, exceptionState); |
| 129 if (es.hadException()) | 129 if (exceptionState.hadException()) |
| 130 return 0; | 130 return 0; |
| 131 | 131 |
| 132 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(context, range,
es); | 132 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(context, range,
exceptionState); |
| 133 if (es.hadException()) | 133 if (exceptionState.hadException()) |
| 134 return 0; | 134 return 0; |
| 135 | 135 |
| 136 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), m_transaction.get()); | 136 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), m_transaction.get()); |
| 137 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); | 137 request->setCursorDetails(IndexedDB::CursorKeyOnly, direction); |
| 138 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata
.id, keyRange, direction, true, IDBDatabaseBackendInterface::NormalTask, request
); | 138 backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata
.id, keyRange, direction, true, IDBDatabaseBackendInterface::NormalTask, request
); |
| 139 return request; | 139 return request; |
| 140 } | 140 } |
| 141 | 141 |
| 142 PassRefPtr<IDBRequest> IDBIndex::get(ExecutionContext* context, const ScriptValu
e& key, ExceptionState& es) | 142 PassRefPtr<IDBRequest> IDBIndex::get(ExecutionContext* context, const ScriptValu
e& key, ExceptionState& exceptionState) |
| 143 { | 143 { |
| 144 IDB_TRACE("IDBIndex::get"); | 144 IDB_TRACE("IDBIndex::get"); |
| 145 if (isDeleted()) { | 145 if (isDeleted()) { |
| 146 es.throwDOMException(InvalidStateError, IDBDatabase::indexDeletedErrorMe
ssage); | 146 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe
letedErrorMessage); |
| 147 return 0; | 147 return 0; |
| 148 } | 148 } |
| 149 if (m_transaction->isFinished()) { | 149 if (m_transaction->isFinished()) { |
| 150 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionF
inishedErrorMessage); | 150 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 151 return 0; | 151 return 0; |
| 152 } | 152 } |
| 153 if (!m_transaction->isActive()) { | 153 if (!m_transaction->isActive()) { |
| 154 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionI
nactiveErrorMessage); | 154 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 155 return 0; | 155 return 0; |
| 156 } | 156 } |
| 157 | 157 |
| 158 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(context, key, es
); | 158 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(context, key, ex
ceptionState); |
| 159 if (es.hadException()) | 159 if (exceptionState.hadException()) |
| 160 return 0; | 160 return 0; |
| 161 if (!keyRange) { | 161 if (!keyRange) { |
| 162 es.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRangeErrorMessage
); | 162 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); |
| 163 return 0; | 163 return 0; |
| 164 } | 164 } |
| 165 | 165 |
| 166 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), m_transaction.get()); | 166 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), m_transaction.get()); |
| 167 backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, ke
yRange, false, request); | 167 backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, ke
yRange, false, request); |
| 168 return request; | 168 return request; |
| 169 } | 169 } |
| 170 | 170 |
| 171 PassRefPtr<IDBRequest> IDBIndex::getKey(ExecutionContext* context, const ScriptV
alue& key, ExceptionState& es) | 171 PassRefPtr<IDBRequest> IDBIndex::getKey(ExecutionContext* context, const ScriptV
alue& key, ExceptionState& exceptionState) |
| 172 { | 172 { |
| 173 IDB_TRACE("IDBIndex::getKey"); | 173 IDB_TRACE("IDBIndex::getKey"); |
| 174 if (isDeleted()) { | 174 if (isDeleted()) { |
| 175 es.throwDOMException(InvalidStateError, IDBDatabase::indexDeletedErrorMe
ssage); | 175 exceptionState.throwDOMException(InvalidStateError, IDBDatabase::indexDe
letedErrorMessage); |
| 176 return 0; | 176 return 0; |
| 177 } | 177 } |
| 178 if (m_transaction->isFinished()) { | 178 if (m_transaction->isFinished()) { |
| 179 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionF
inishedErrorMessage); | 179 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionFinishedErrorMessage); |
| 180 return 0; | 180 return 0; |
| 181 } | 181 } |
| 182 if (!m_transaction->isActive()) { | 182 if (!m_transaction->isActive()) { |
| 183 es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionI
nactiveErrorMessage); | 183 exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::
transactionInactiveErrorMessage); |
| 184 return 0; | 184 return 0; |
| 185 } | 185 } |
| 186 | 186 |
| 187 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(context, key, es
); | 187 RefPtr<IDBKeyRange> keyRange = IDBKeyRange::fromScriptValue(context, key, ex
ceptionState); |
| 188 if (es.hadException()) | 188 if (exceptionState.hadException()) |
| 189 return 0; | 189 return 0; |
| 190 if (!keyRange) { | 190 if (!keyRange) { |
| 191 es.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRangeErrorMessage
); | 191 exceptionState.throwDOMException(DataError, IDBDatabase::noKeyOrKeyRange
ErrorMessage); |
| 192 return 0; | 192 return 0; |
| 193 } | 193 } |
| 194 | 194 |
| 195 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), m_transaction.get()); | 195 RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this
), m_transaction.get()); |
| 196 backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, ke
yRange, true, request); | 196 backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, ke
yRange, true, request); |
| 197 return request; | 197 return request; |
| 198 } | 198 } |
| 199 | 199 |
| 200 IDBDatabaseBackendInterface* IDBIndex::backendDB() const | 200 IDBDatabaseBackendInterface* IDBIndex::backendDB() const |
| 201 { | 201 { |
| 202 return m_transaction->backendDB(); | 202 return m_transaction->backendDB(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 bool IDBIndex::isDeleted() const | 205 bool IDBIndex::isDeleted() const |
| 206 { | 206 { |
| 207 return m_deleted || m_objectStore->isDeleted(); | 207 return m_deleted || m_objectStore->isDeleted(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 } // namespace WebCore | 210 } // namespace WebCore |
| OLD | NEW |