| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 wrapper, ToV8(request_.Get(), wrapper, isolate)); | 97 wrapper, ToV8(request_.Get(), wrapper, isolate)); |
| 98 } | 98 } |
| 99 return wrapper; | 99 return wrapper; |
| 100 } | 100 } |
| 101 | 101 |
| 102 IDBRequest* IDBCursor::update(ScriptState* script_state, | 102 IDBRequest* IDBCursor::update(ScriptState* script_state, |
| 103 const ScriptValue& value, | 103 const ScriptValue& value, |
| 104 ExceptionState& exception_state) { | 104 ExceptionState& exception_state) { |
| 105 IDB_TRACE("IDBCursor::update"); | 105 IDB_TRACE("IDBCursor::update"); |
| 106 | 106 |
| 107 if (transaction_->IsFinished() || transaction_->IsFinishing()) { | |
| 108 exception_state.ThrowDOMException( | |
| 109 kTransactionInactiveError, | |
| 110 IDBDatabase::kTransactionFinishedErrorMessage); | |
| 111 return nullptr; | |
| 112 } | |
| 113 if (!transaction_->IsActive()) { | 107 if (!transaction_->IsActive()) { |
| 114 exception_state.ThrowDOMException( | 108 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 115 kTransactionInactiveError, | 109 transaction_->InactiveErrorMessage()); |
| 116 IDBDatabase::kTransactionInactiveErrorMessage); | |
| 117 return nullptr; | 110 return nullptr; |
| 118 } | 111 } |
| 119 if (transaction_->IsReadOnly()) { | 112 if (transaction_->IsReadOnly()) { |
| 120 exception_state.ThrowDOMException( | 113 exception_state.ThrowDOMException( |
| 121 kReadOnlyError, | 114 kReadOnlyError, |
| 122 "The record may not be updated inside a read-only transaction."); | 115 "The record may not be updated inside a read-only transaction."); |
| 123 return nullptr; | 116 return nullptr; |
| 124 } | 117 } |
| 125 if (IsDeleted()) { | 118 if (IsDeleted()) { |
| 126 exception_state.ThrowDOMException(kInvalidStateError, | 119 exception_state.ThrowDOMException(kInvalidStateError, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 145 } | 138 } |
| 146 | 139 |
| 147 void IDBCursor::advance(unsigned count, ExceptionState& exception_state) { | 140 void IDBCursor::advance(unsigned count, ExceptionState& exception_state) { |
| 148 IDB_TRACE("IDBCursor::advance"); | 141 IDB_TRACE("IDBCursor::advance"); |
| 149 if (!count) { | 142 if (!count) { |
| 150 exception_state.ThrowTypeError( | 143 exception_state.ThrowTypeError( |
| 151 "A count argument with value 0 (zero) was supplied, must be greater " | 144 "A count argument with value 0 (zero) was supplied, must be greater " |
| 152 "than 0."); | 145 "than 0."); |
| 153 return; | 146 return; |
| 154 } | 147 } |
| 155 if (transaction_->IsFinished() || transaction_->IsFinishing()) { | |
| 156 exception_state.ThrowDOMException( | |
| 157 kTransactionInactiveError, | |
| 158 IDBDatabase::kTransactionFinishedErrorMessage); | |
| 159 return; | |
| 160 } | |
| 161 if (!transaction_->IsActive()) { | 148 if (!transaction_->IsActive()) { |
| 162 exception_state.ThrowDOMException( | 149 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 163 kTransactionInactiveError, | 150 transaction_->InactiveErrorMessage()); |
| 164 IDBDatabase::kTransactionInactiveErrorMessage); | |
| 165 return; | 151 return; |
| 166 } | 152 } |
| 167 if (IsDeleted()) { | 153 if (IsDeleted()) { |
| 168 exception_state.ThrowDOMException(kInvalidStateError, | 154 exception_state.ThrowDOMException(kInvalidStateError, |
| 169 IDBDatabase::kSourceDeletedErrorMessage); | 155 IDBDatabase::kSourceDeletedErrorMessage); |
| 170 return; | 156 return; |
| 171 } | 157 } |
| 172 if (!got_value_) { | 158 if (!got_value_) { |
| 173 exception_state.ThrowDOMException(kInvalidStateError, | 159 exception_state.ThrowDOMException(kInvalidStateError, |
| 174 IDBDatabase::kNoValueErrorMessage); | 160 IDBDatabase::kNoValueErrorMessage); |
| 175 return; | 161 return; |
| 176 } | 162 } |
| 177 | 163 |
| 178 request_->SetPendingCursor(this); | 164 request_->SetPendingCursor(this); |
| 179 got_value_ = false; | 165 got_value_ = false; |
| 180 backend_->Advance(count, request_->CreateWebCallbacks().release()); | 166 backend_->Advance(count, request_->CreateWebCallbacks().release()); |
| 181 } | 167 } |
| 182 | 168 |
| 183 void IDBCursor::continueFunction(ScriptState* script_state, | 169 void IDBCursor::continueFunction(ScriptState* script_state, |
| 184 const ScriptValue& key_value, | 170 const ScriptValue& key_value, |
| 185 ExceptionState& exception_state) { | 171 ExceptionState& exception_state) { |
| 186 IDB_TRACE("IDBCursor::continue"); | 172 IDB_TRACE("IDBCursor::continue"); |
| 187 | 173 |
| 188 if (transaction_->IsFinished() || transaction_->IsFinishing()) { | |
| 189 exception_state.ThrowDOMException( | |
| 190 kTransactionInactiveError, | |
| 191 IDBDatabase::kTransactionFinishedErrorMessage); | |
| 192 return; | |
| 193 } | |
| 194 if (!transaction_->IsActive()) { | 174 if (!transaction_->IsActive()) { |
| 195 exception_state.ThrowDOMException( | 175 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 196 kTransactionInactiveError, | 176 transaction_->InactiveErrorMessage()); |
| 197 IDBDatabase::kTransactionInactiveErrorMessage); | |
| 198 return; | 177 return; |
| 199 } | 178 } |
| 200 if (!got_value_) { | 179 if (!got_value_) { |
| 201 exception_state.ThrowDOMException(kInvalidStateError, | 180 exception_state.ThrowDOMException(kInvalidStateError, |
| 202 IDBDatabase::kNoValueErrorMessage); | 181 IDBDatabase::kNoValueErrorMessage); |
| 203 return; | 182 return; |
| 204 } | 183 } |
| 205 if (IsDeleted()) { | 184 if (IsDeleted()) { |
| 206 exception_state.ThrowDOMException(kInvalidStateError, | 185 exception_state.ThrowDOMException(kInvalidStateError, |
| 207 IDBDatabase::kSourceDeletedErrorMessage); | 186 IDBDatabase::kSourceDeletedErrorMessage); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 221 } | 200 } |
| 222 Continue(key, nullptr, exception_state); | 201 Continue(key, nullptr, exception_state); |
| 223 } | 202 } |
| 224 | 203 |
| 225 void IDBCursor::continuePrimaryKey(ScriptState* script_state, | 204 void IDBCursor::continuePrimaryKey(ScriptState* script_state, |
| 226 const ScriptValue& key_value, | 205 const ScriptValue& key_value, |
| 227 const ScriptValue& primary_key_value, | 206 const ScriptValue& primary_key_value, |
| 228 ExceptionState& exception_state) { | 207 ExceptionState& exception_state) { |
| 229 IDB_TRACE("IDBCursor::continuePrimaryKey"); | 208 IDB_TRACE("IDBCursor::continuePrimaryKey"); |
| 230 | 209 |
| 231 if (transaction_->IsFinished() || transaction_->IsFinishing()) { | |
| 232 exception_state.ThrowDOMException( | |
| 233 kTransactionInactiveError, | |
| 234 IDBDatabase::kTransactionFinishedErrorMessage); | |
| 235 return; | |
| 236 } | |
| 237 if (!transaction_->IsActive()) { | 210 if (!transaction_->IsActive()) { |
| 238 exception_state.ThrowDOMException( | 211 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 239 kTransactionInactiveError, | 212 transaction_->InactiveErrorMessage()); |
| 240 IDBDatabase::kTransactionInactiveErrorMessage); | |
| 241 return; | 213 return; |
| 242 } | 214 } |
| 243 | 215 |
| 244 if (IsDeleted()) { | 216 if (IsDeleted()) { |
| 245 exception_state.ThrowDOMException(kInvalidStateError, | 217 exception_state.ThrowDOMException(kInvalidStateError, |
| 246 IDBDatabase::kSourceDeletedErrorMessage); | 218 IDBDatabase::kSourceDeletedErrorMessage); |
| 247 return; | 219 return; |
| 248 } | 220 } |
| 249 | 221 |
| 250 if (source_->GetType() != IDBAny::kIDBIndexType) { | 222 if (source_->GetType() != IDBAny::kIDBIndexType) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // on. Is this right? | 301 // on. Is this right? |
| 330 request_->SetPendingCursor(this); | 302 request_->SetPendingCursor(this); |
| 331 got_value_ = false; | 303 got_value_ = false; |
| 332 backend_->ContinueFunction(key, primary_key, | 304 backend_->ContinueFunction(key, primary_key, |
| 333 request_->CreateWebCallbacks().release()); | 305 request_->CreateWebCallbacks().release()); |
| 334 } | 306 } |
| 335 | 307 |
| 336 IDBRequest* IDBCursor::deleteFunction(ScriptState* script_state, | 308 IDBRequest* IDBCursor::deleteFunction(ScriptState* script_state, |
| 337 ExceptionState& exception_state) { | 309 ExceptionState& exception_state) { |
| 338 IDB_TRACE("IDBCursor::delete"); | 310 IDB_TRACE("IDBCursor::delete"); |
| 339 if (transaction_->IsFinished() || transaction_->IsFinishing()) { | |
| 340 exception_state.ThrowDOMException( | |
| 341 kTransactionInactiveError, | |
| 342 IDBDatabase::kTransactionFinishedErrorMessage); | |
| 343 return nullptr; | |
| 344 } | |
| 345 if (!transaction_->IsActive()) { | 311 if (!transaction_->IsActive()) { |
| 346 exception_state.ThrowDOMException( | 312 exception_state.ThrowDOMException(kTransactionInactiveError, |
| 347 kTransactionInactiveError, | 313 transaction_->InactiveErrorMessage()); |
| 348 IDBDatabase::kTransactionInactiveErrorMessage); | |
| 349 return nullptr; | 314 return nullptr; |
| 350 } | 315 } |
| 351 if (transaction_->IsReadOnly()) { | 316 if (transaction_->IsReadOnly()) { |
| 352 exception_state.ThrowDOMException( | 317 exception_state.ThrowDOMException( |
| 353 kReadOnlyError, | 318 kReadOnlyError, |
| 354 "The record may not be deleted inside a read-only transaction."); | 319 "The record may not be deleted inside a read-only transaction."); |
| 355 return nullptr; | 320 return nullptr; |
| 356 } | 321 } |
| 357 if (IsDeleted()) { | 322 if (IsDeleted()) { |
| 358 exception_state.ThrowDOMException(kInvalidStateError, | 323 exception_state.ThrowDOMException(kInvalidStateError, |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 case kWebIDBCursorDirectionPrevNoDuplicate: | 458 case kWebIDBCursorDirectionPrevNoDuplicate: |
| 494 return IndexedDBNames::prevunique; | 459 return IndexedDBNames::prevunique; |
| 495 | 460 |
| 496 default: | 461 default: |
| 497 NOTREACHED(); | 462 NOTREACHED(); |
| 498 return IndexedDBNames::next; | 463 return IndexedDBNames::next; |
| 499 } | 464 } |
| 500 } | 465 } |
| 501 | 466 |
| 502 } // namespace blink | 467 } // namespace blink |
| OLD | NEW |