| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 DEFINE_TRACE(IDBRequest) { | 79 DEFINE_TRACE(IDBRequest) { |
| 80 visitor->Trace(transaction_); | 80 visitor->Trace(transaction_); |
| 81 visitor->Trace(source_); | 81 visitor->Trace(source_); |
| 82 visitor->Trace(result_); | 82 visitor->Trace(result_); |
| 83 visitor->Trace(error_); | 83 visitor->Trace(error_); |
| 84 visitor->Trace(enqueued_events_); | 84 visitor->Trace(enqueued_events_); |
| 85 visitor->Trace(pending_cursor_); | 85 visitor->Trace(pending_cursor_); |
| 86 visitor->Trace(cursor_key_); | 86 visitor->Trace(cursor_key_); |
| 87 visitor->Trace(cursor_primary_key_); | 87 visitor->Trace(cursor_primary_key_); |
| 88 visitor->Trace(loader_); |
| 88 EventTargetWithInlineData::Trace(visitor); | 89 EventTargetWithInlineData::Trace(visitor); |
| 89 SuspendableObject::Trace(visitor); | 90 SuspendableObject::Trace(visitor); |
| 90 } | 91 } |
| 91 | 92 |
| 92 ScriptValue IDBRequest::result(ScriptState* script_state, | 93 ScriptValue IDBRequest::result(ScriptState* script_state, |
| 93 ExceptionState& exception_state) { | 94 ExceptionState& exception_state) { |
| 94 if (ready_state_ != DONE) { | 95 if (ready_state_ != DONE) { |
| 95 // Must throw if returning an empty value. Message is arbitrary since it | 96 // Must throw if returning an empty value. Message is arbitrary since it |
| 96 // will never be seen. | 97 // will never be seen. |
| 97 exception_state.ThrowDOMException( | 98 exception_state.ThrowDOMException( |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 DOMStringList* dom_string_list = DOMStringList::Create(); | 259 DOMStringList* dom_string_list = DOMStringList::Create(); |
| 259 for (size_t i = 0; i < string_list.size(); ++i) | 260 for (size_t i = 0; i < string_list.size(); ++i) |
| 260 dom_string_list->Append(string_list[i]); | 261 dom_string_list->Append(string_list[i]); |
| 261 OnSuccessInternal(IDBAny::Create(dom_string_list)); | 262 OnSuccessInternal(IDBAny::Create(dom_string_list)); |
| 262 } | 263 } |
| 263 | 264 |
| 264 void IDBRequest::OnSuccess(std::unique_ptr<WebIDBCursor> backend, | 265 void IDBRequest::OnSuccess(std::unique_ptr<WebIDBCursor> backend, |
| 265 IDBKey* key, | 266 IDBKey* key, |
| 266 IDBKey* primary_key, | 267 IDBKey* primary_key, |
| 267 PassRefPtr<IDBValue> value) { | 268 PassRefPtr<IDBValue> value) { |
| 269 if (!loader_ && IDBRequestLoader::NeedsUnwrapping(value.Get())) { |
| 270 // TODO(pwnall): Tracing. |
| 271 loader_ = new IDBRequestLoader(this); |
| 272 loader_->Start(std::move(backend), key, primary_key, std::move(value)); |
| 273 return; |
| 274 } |
| 275 |
| 268 IDB_TRACE("IDBRequest::onSuccess(IDBCursor)"); | 276 IDB_TRACE("IDBRequest::onSuccess(IDBCursor)"); |
| 269 if (!ShouldEnqueueEvent()) | 277 if (!ShouldEnqueueEvent()) |
| 270 return; | 278 return; |
| 271 | 279 |
| 272 DCHECK(!pending_cursor_); | 280 DCHECK(!pending_cursor_); |
| 273 IDBCursor* cursor = nullptr; | 281 IDBCursor* cursor = nullptr; |
| 274 switch (cursor_type_) { | 282 switch (cursor_type_) { |
| 275 case IndexedDB::kCursorKeyOnly: | 283 case IndexedDB::kCursorKeyOnly: |
| 276 cursor = IDBCursor::Create(std::move(backend), cursor_direction_, this, | 284 cursor = IDBCursor::Create(std::move(backend), cursor_direction_, this, |
| 277 source_.Get(), transaction_.Get()); | 285 source_.Get(), transaction_.Get()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 292 if (!ShouldEnqueueEvent()) | 300 if (!ShouldEnqueueEvent()) |
| 293 return; | 301 return; |
| 294 | 302 |
| 295 if (idb_key && idb_key->IsValid()) | 303 if (idb_key && idb_key->IsValid()) |
| 296 OnSuccessInternal(IDBAny::Create(idb_key)); | 304 OnSuccessInternal(IDBAny::Create(idb_key)); |
| 297 else | 305 else |
| 298 OnSuccessInternal(IDBAny::CreateUndefined()); | 306 OnSuccessInternal(IDBAny::CreateUndefined()); |
| 299 } | 307 } |
| 300 | 308 |
| 301 void IDBRequest::OnSuccess(const Vector<RefPtr<IDBValue>>& values) { | 309 void IDBRequest::OnSuccess(const Vector<RefPtr<IDBValue>>& values) { |
| 310 if (!loader_ && IDBRequestLoader::NeedUnwrapping(values)) { |
| 311 // TODO(pwnall): Tracing. |
| 312 loader_ = new IDBRequestLoader(this); |
| 313 loader_->Start(values); |
| 314 return; |
| 315 } |
| 316 |
| 302 IDB_TRACE("IDBRequest::onSuccess([IDBValue])"); | 317 IDB_TRACE("IDBRequest::onSuccess([IDBValue])"); |
| 303 if (!ShouldEnqueueEvent()) | 318 if (!ShouldEnqueueEvent()) |
| 304 return; | 319 return; |
| 305 | 320 |
| 306 AckReceivedBlobs(values); | 321 AckReceivedBlobs(values); |
| 307 OnSuccessInternal(IDBAny::Create(values)); | 322 OnSuccessInternal(IDBAny::Create(values)); |
| 308 } | 323 } |
| 309 | 324 |
| 310 #if DCHECK_IS_ON() | 325 #if DCHECK_IS_ON() |
| 311 static IDBObjectStore* EffectiveObjectStore(IDBAny* source) { | 326 static IDBObjectStore* EffectiveObjectStore(IDBAny* source) { |
| 312 if (source->GetType() == IDBAny::kIDBObjectStoreType) | 327 if (source->GetType() == IDBAny::kIDBObjectStoreType) |
| 313 return source->IdbObjectStore(); | 328 return source->IdbObjectStore(); |
| 314 if (source->GetType() == IDBAny::kIDBIndexType) | 329 if (source->GetType() == IDBAny::kIDBIndexType) |
| 315 return source->IdbIndex()->objectStore(); | 330 return source->IdbIndex()->objectStore(); |
| 316 | 331 |
| 317 NOTREACHED(); | 332 NOTREACHED(); |
| 318 return nullptr; | 333 return nullptr; |
| 319 } | 334 } |
| 320 #endif // DCHECK_IS_ON() | 335 #endif // DCHECK_IS_ON() |
| 321 | 336 |
| 322 void IDBRequest::OnSuccess(PassRefPtr<IDBValue> prp_value) { | 337 void IDBRequest::OnSuccess(PassRefPtr<IDBValue> prp_value) { |
| 338 RefPtr<IDBValue> value(std::move(prp_value)); |
| 339 if (!loader_ && IDBRequestLoader::NeedsUnwrapping(value.Get())) { |
| 340 // TODO(pwnall): Tracing. |
| 341 loader_ = new IDBRequestLoader(this); |
| 342 loader_->Start(value.Release()); |
| 343 return; |
| 344 } |
| 345 |
| 323 IDB_TRACE("IDBRequest::onSuccess(IDBValue)"); | 346 IDB_TRACE("IDBRequest::onSuccess(IDBValue)"); |
| 324 if (!ShouldEnqueueEvent()) | 347 if (!ShouldEnqueueEvent()) |
| 325 return; | 348 return; |
| 326 | 349 |
| 327 RefPtr<IDBValue> value(std::move(prp_value)); | |
| 328 AckReceivedBlobs(value.Get()); | 350 AckReceivedBlobs(value.Get()); |
| 329 | 351 |
| 330 if (pending_cursor_) { | 352 if (pending_cursor_) { |
| 331 // Value should be null, signifying the end of the cursor's range. | 353 // Value should be null, signifying the end of the cursor's range. |
| 332 DCHECK(value->IsNull()); | 354 DCHECK(value->IsNull()); |
| 333 DCHECK(!value->BlobInfo()->size()); | 355 DCHECK(!value->BlobInfo()->size()); |
| 334 pending_cursor_->Close(); | 356 pending_cursor_->Close(); |
| 335 pending_cursor_.Clear(); | 357 pending_cursor_.Clear(); |
| 336 } | 358 } |
| 337 | 359 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 365 } | 387 } |
| 366 | 388 |
| 367 void IDBRequest::SetResult(IDBAny* result) { | 389 void IDBRequest::SetResult(IDBAny* result) { |
| 368 result_ = result; | 390 result_ = result; |
| 369 result_dirty_ = true; | 391 result_dirty_ = true; |
| 370 } | 392 } |
| 371 | 393 |
| 372 void IDBRequest::OnSuccess(IDBKey* key, | 394 void IDBRequest::OnSuccess(IDBKey* key, |
| 373 IDBKey* primary_key, | 395 IDBKey* primary_key, |
| 374 PassRefPtr<IDBValue> value) { | 396 PassRefPtr<IDBValue> value) { |
| 397 if (!loader_ && IDBRequestLoader::NeedsUnwrapping(value.Get())) { |
| 398 // TODO(pwnall): Tracing. |
| 399 loader_ = new IDBRequestLoader(this); |
| 400 loader_->Start(key, primary_key, std::move(value)); |
| 401 return; |
| 402 } |
| 403 |
| 375 IDB_TRACE("IDBRequest::onSuccess(key, primaryKey, value)"); | 404 IDB_TRACE("IDBRequest::onSuccess(key, primaryKey, value)"); |
| 376 if (!ShouldEnqueueEvent()) | 405 if (!ShouldEnqueueEvent()) |
| 377 return; | 406 return; |
| 378 | 407 |
| 379 DCHECK(pending_cursor_); | 408 DCHECK(pending_cursor_); |
| 380 SetResultCursor(pending_cursor_.Release(), key, primary_key, | 409 SetResultCursor(pending_cursor_.Release(), key, primary_key, |
| 381 std::move(value)); | 410 std::move(value)); |
| 382 } | 411 } |
| 383 | 412 |
| 384 bool IDBRequest::HasPendingActivity() const { | 413 bool IDBRequest::HasPendingActivity() const { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 } | 582 } |
| 554 | 583 |
| 555 void IDBRequest::DequeueEvent(Event* event) { | 584 void IDBRequest::DequeueEvent(Event* event) { |
| 556 for (size_t i = 0; i < enqueued_events_.size(); ++i) { | 585 for (size_t i = 0; i < enqueued_events_.size(); ++i) { |
| 557 if (enqueued_events_[i].Get() == event) | 586 if (enqueued_events_[i].Get() == event) |
| 558 enqueued_events_.erase(i); | 587 enqueued_events_.erase(i); |
| 559 } | 588 } |
| 560 } | 589 } |
| 561 | 590 |
| 562 } // namespace blink | 591 } // namespace blink |
| OLD | NEW |