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

Side by Side Diff: Source/WebCore/Modules/indexeddb/IDBRequest.cpp

Issue 11337028: Merge 132922 - Remove ensureAuxiliaryContext (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1312/
Patch Set: Created 8 years, 1 month 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
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 24 matching lines...) Expand all
35 #include "EventListener.h" 35 #include "EventListener.h"
36 #include "EventNames.h" 36 #include "EventNames.h"
37 #include "EventQueue.h" 37 #include "EventQueue.h"
38 #include "IDBBindingUtilities.h" 38 #include "IDBBindingUtilities.h"
39 #include "IDBCursorWithValue.h" 39 #include "IDBCursorWithValue.h"
40 #include "IDBDatabase.h" 40 #include "IDBDatabase.h"
41 #include "IDBEventDispatcher.h" 41 #include "IDBEventDispatcher.h"
42 #include "IDBTracing.h" 42 #include "IDBTracing.h"
43 #include "IDBTransaction.h" 43 #include "IDBTransaction.h"
44 #include "ScriptExecutionContext.h" 44 #include "ScriptExecutionContext.h"
45 #if USE(V8)
46 #include "V8Binding.h"
47 #endif
45 48
46 namespace WebCore { 49 namespace WebCore {
47 50
48 PassRefPtr<IDBRequest> IDBRequest::create(ScriptExecutionContext* context, PassR efPtr<IDBAny> source, IDBTransaction* transaction) 51 PassRefPtr<IDBRequest> IDBRequest::create(ScriptExecutionContext* context, PassR efPtr<IDBAny> source, IDBTransaction* transaction)
49 { 52 {
50 RefPtr<IDBRequest> request(adoptRef(new IDBRequest(context, source, IDBTrans actionBackendInterface::NormalTask, transaction))); 53 RefPtr<IDBRequest> request(adoptRef(new IDBRequest(context, source, IDBTrans actionBackendInterface::NormalTask, transaction)));
51 request->suspendIfNeeded(); 54 request->suspendIfNeeded();
52 return request.release(); 55 return request.release();
53 } 56 }
54 57
(...skipping 14 matching lines...) Expand all
69 , m_requestAborted(false) 72 , m_requestAborted(false)
70 , m_source(source) 73 , m_source(source)
71 , m_taskType(taskType) 74 , m_taskType(taskType)
72 , m_hasPendingActivity(true) 75 , m_hasPendingActivity(true)
73 , m_cursorType(IDBCursorBackendInterface::InvalidCursorType) 76 , m_cursorType(IDBCursorBackendInterface::InvalidCursorType)
74 , m_cursorDirection(IDBCursor::NEXT) 77 , m_cursorDirection(IDBCursor::NEXT)
75 , m_cursorFinished(false) 78 , m_cursorFinished(false)
76 , m_pendingCursor(0) 79 , m_pendingCursor(0)
77 , m_didFireUpgradeNeededEvent(false) 80 , m_didFireUpgradeNeededEvent(false)
78 , m_preventPropagation(false) 81 , m_preventPropagation(false)
82 #if USE(V8)
83 , m_worldContextHandle(UseCurrentWorld)
84 #endif
79 { 85 {
80 if (m_transaction) { 86 if (m_transaction) {
81 m_transaction->registerRequest(this); 87 m_transaction->registerRequest(this);
82 } 88 }
83 } 89 }
84 90
85 IDBRequest::~IDBRequest() 91 IDBRequest::~IDBRequest()
86 { 92 {
87 ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !scriptExecutio nContext()); 93 ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !scriptExecutio nContext());
88 } 94 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 m_result = IDBAny::create(domStringList); 283 m_result = IDBAny::create(domStringList);
278 enqueueEvent(createSuccessEvent()); 284 enqueueEvent(createSuccessEvent());
279 } 285 }
280 286
281 void IDBRequest::onSuccess(PassRefPtr<IDBCursorBackendInterface> backend, PassRe fPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SerializedScriptValu e> serializedValue) 287 void IDBRequest::onSuccess(PassRefPtr<IDBCursorBackendInterface> backend, PassRe fPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SerializedScriptValu e> serializedValue)
282 { 288 {
283 IDB_TRACE("IDBRequest::onSuccess(IDBCursor)"); 289 IDB_TRACE("IDBRequest::onSuccess(IDBCursor)");
284 if (!shouldEnqueueEvent()) 290 if (!shouldEnqueueEvent())
285 return; 291 return;
286 292
293 #if USE(V8)
294 v8::HandleScope handleScope;
295 v8::Local<v8::Context> context = toV8Context(scriptExecutionContext(), m_wor ldContextHandle);
296 if (context.IsEmpty())
297 CRASH();
298 v8::Context::Scope contextScope(context);
299 #endif
300
287 ScriptValue value = deserializeIDBValue(scriptExecutionContext(), serialized Value); 301 ScriptValue value = deserializeIDBValue(scriptExecutionContext(), serialized Value);
288 ASSERT(m_cursorType != IDBCursorBackendInterface::InvalidCursorType); 302 ASSERT(m_cursorType != IDBCursorBackendInterface::InvalidCursorType);
289 RefPtr<IDBCursor> cursor; 303 RefPtr<IDBCursor> cursor;
290 if (m_cursorType == IDBCursorBackendInterface::IndexKeyCursor) 304 if (m_cursorType == IDBCursorBackendInterface::IndexKeyCursor)
291 cursor = IDBCursor::create(backend, m_cursorDirection, this, m_source.ge t(), m_transaction.get()); 305 cursor = IDBCursor::create(backend, m_cursorDirection, this, m_source.ge t(), m_transaction.get());
292 else 306 else
293 cursor = IDBCursorWithValue::create(backend, m_cursorDirection, this, m_ source.get(), m_transaction.get()); 307 cursor = IDBCursorWithValue::create(backend, m_cursorDirection, this, m_ source.get(), m_transaction.get());
294 setResultCursor(cursor, key, primaryKey, value); 308 setResultCursor(cursor, key, primaryKey, value);
295 309
296 enqueueEvent(createSuccessEvent()); 310 enqueueEvent(createSuccessEvent());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 m_result = IDBAny::create(frontend.release()); 347 m_result = IDBAny::create(frontend.release());
334 enqueueEvent(createSuccessEvent()); 348 enqueueEvent(createSuccessEvent());
335 } 349 }
336 350
337 void IDBRequest::onSuccess(PassRefPtr<SerializedScriptValue> serializedScriptVal ue) 351 void IDBRequest::onSuccess(PassRefPtr<SerializedScriptValue> serializedScriptVal ue)
338 { 352 {
339 IDB_TRACE("IDBRequest::onSuccess(SerializedScriptValue)"); 353 IDB_TRACE("IDBRequest::onSuccess(SerializedScriptValue)");
340 if (!shouldEnqueueEvent()) 354 if (!shouldEnqueueEvent())
341 return; 355 return;
342 356
357 #if USE(V8)
358 v8::HandleScope handleScope;
359 v8::Local<v8::Context> context = toV8Context(scriptExecutionContext(), m_wor ldContextHandle);
360 if (context.IsEmpty())
361 CRASH();
362 v8::Context::Scope contextScope(context);
363 #endif
364
343 ScriptValue value = deserializeIDBValue(scriptExecutionContext(), serialized ScriptValue); 365 ScriptValue value = deserializeIDBValue(scriptExecutionContext(), serialized ScriptValue);
344 onSuccessInternal(value); 366 onSuccessInternal(value);
345 } 367 }
346 368
347 #ifndef NDEBUG 369 #ifndef NDEBUG
348 static PassRefPtr<IDBObjectStore> effectiveObjectStore(PassRefPtr<IDBAny> source ) 370 static PassRefPtr<IDBObjectStore> effectiveObjectStore(PassRefPtr<IDBAny> source )
349 { 371 {
350 if (source->type() == IDBAny::IDBObjectStoreType) 372 if (source->type() == IDBAny::IDBObjectStoreType)
351 return source->idbObjectStore(); 373 return source->idbObjectStore();
352 if (source->type() == IDBAny::IDBIndexType) 374 if (source->type() == IDBAny::IDBIndexType)
353 return source->idbIndex()->objectStore(); 375 return source->idbIndex()->objectStore();
354 376
355 ASSERT_NOT_REACHED(); 377 ASSERT_NOT_REACHED();
356 return 0; 378 return 0;
357 } 379 }
358 #endif 380 #endif
359 381
360 void IDBRequest::onSuccess(PassRefPtr<SerializedScriptValue> prpSerializedScript Value, PassRefPtr<IDBKey> prpPrimaryKey, const IDBKeyPath& keyPath) 382 void IDBRequest::onSuccess(PassRefPtr<SerializedScriptValue> prpSerializedScript Value, PassRefPtr<IDBKey> prpPrimaryKey, const IDBKeyPath& keyPath)
361 { 383 {
362 IDB_TRACE("IDBRequest::onSuccess(SerializedScriptValue, IDBKey, IDBKeyPath)" ); 384 IDB_TRACE("IDBRequest::onSuccess(SerializedScriptValue, IDBKey, IDBKeyPath)" );
363 if (!shouldEnqueueEvent()) 385 if (!shouldEnqueueEvent())
364 return; 386 return;
365 387
388 #if USE(V8)
389 v8::HandleScope handleScope;
390 v8::Local<v8::Context> context = toV8Context(scriptExecutionContext(), m_wor ldContextHandle);
391 if (context.IsEmpty())
392 CRASH();
393 v8::Context::Scope contextScope(context);
394 #endif
395
366 #ifndef NDEBUG 396 #ifndef NDEBUG
367 ASSERT(keyPath == effectiveObjectStore(m_source)->keyPath()); 397 ASSERT(keyPath == effectiveObjectStore(m_source)->keyPath());
368 #endif 398 #endif
369 ScriptValue value = deserializeIDBValue(scriptExecutionContext(), prpSeriali zedScriptValue); 399 ScriptValue value = deserializeIDBValue(scriptExecutionContext(), prpSeriali zedScriptValue);
370 400
371 RefPtr<IDBKey> primaryKey = prpPrimaryKey; 401 RefPtr<IDBKey> primaryKey = prpPrimaryKey;
372 #ifndef NDEBUG 402 #ifndef NDEBUG
373 RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(value, ke yPath); 403 RefPtr<IDBKey> expectedKey = createIDBKeyFromScriptValueAndKeyPath(value, ke yPath);
374 ASSERT(!expectedKey || expectedKey->isEqual(primaryKey.get())); 404 ASSERT(!expectedKey || expectedKey->isEqual(primaryKey.get()));
375 #endif 405 #endif
(...skipping 21 matching lines...) Expand all
397 } 427 }
398 enqueueEvent(createSuccessEvent()); 428 enqueueEvent(createSuccessEvent());
399 } 429 }
400 430
401 void IDBRequest::onSuccess(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey , PassRefPtr<SerializedScriptValue> serializedValue) 431 void IDBRequest::onSuccess(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey , PassRefPtr<SerializedScriptValue> serializedValue)
402 { 432 {
403 IDB_TRACE("IDBRequest::onSuccess(key, primaryKey, value)"); 433 IDB_TRACE("IDBRequest::onSuccess(key, primaryKey, value)");
404 if (!shouldEnqueueEvent()) 434 if (!shouldEnqueueEvent())
405 return; 435 return;
406 436
437 #if USE(V8)
438 v8::HandleScope handleScope;
439 v8::Local<v8::Context> context = toV8Context(scriptExecutionContext(), m_wor ldContextHandle);
440 if (context.IsEmpty())
441 CRASH();
442 v8::Context::Scope contextScope(context);
443 #endif
444
407 ScriptValue value = deserializeIDBValue(scriptExecutionContext(), serialized Value); 445 ScriptValue value = deserializeIDBValue(scriptExecutionContext(), serialized Value);
408 ASSERT(m_pendingCursor); 446 ASSERT(m_pendingCursor);
409 setResultCursor(m_pendingCursor.release(), key, primaryKey, value); 447 setResultCursor(m_pendingCursor.release(), key, primaryKey, value);
410 enqueueEvent(createSuccessEvent()); 448 enqueueEvent(createSuccessEvent());
411 } 449 }
412 450
413 bool IDBRequest::hasPendingActivity() const 451 bool IDBRequest::hasPendingActivity() const
414 { 452 {
415 // FIXME: In an ideal world, we should return true as long as anyone has a o r can 453 // FIXME: In an ideal world, we should return true as long as anyone has a o r can
416 // get a handle to us and we have event listeners. This is order to h andle 454 // get a handle to us and we have event listeners. This is order to h andle
(...skipping 25 matching lines...) Expand all
442 bool IDBRequest::dispatchEvent(PassRefPtr<Event> event) 480 bool IDBRequest::dispatchEvent(PassRefPtr<Event> event)
443 { 481 {
444 IDB_TRACE("IDBRequest::dispatchEvent"); 482 IDB_TRACE("IDBRequest::dispatchEvent");
445 ASSERT(m_readyState == PENDING); 483 ASSERT(m_readyState == PENDING);
446 ASSERT(!m_contextStopped); 484 ASSERT(!m_contextStopped);
447 ASSERT(m_hasPendingActivity); 485 ASSERT(m_hasPendingActivity);
448 ASSERT(m_enqueuedEvents.size()); 486 ASSERT(m_enqueuedEvents.size());
449 ASSERT(scriptExecutionContext()); 487 ASSERT(scriptExecutionContext());
450 ASSERT(event->target() == this); 488 ASSERT(event->target() == this);
451 ASSERT_WITH_MESSAGE(m_readyState < DONE, "When dispatching event %s, m_ready State < DONE(%d), was %d", event->type().string().utf8().data(), DONE, m_readySt ate); 489 ASSERT_WITH_MESSAGE(m_readyState < DONE, "When dispatching event %s, m_ready State < DONE(%d), was %d", event->type().string().utf8().data(), DONE, m_readySt ate);
490
491 #if USE(V8)
492 v8::HandleScope handleScope;
493 v8::Local<v8::Context> context = toV8Context(scriptExecutionContext(), m_wor ldContextHandle);
494 if (context.IsEmpty())
495 CRASH();
496 v8::Context::Scope contextScope(context);
497 #endif
498
452 if (event->type() != eventNames().blockedEvent) 499 if (event->type() != eventNames().blockedEvent)
453 m_readyState = DONE; 500 m_readyState = DONE;
454 501
455 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) { 502 for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) {
456 if (m_enqueuedEvents[i].get() == event.get()) 503 if (m_enqueuedEvents[i].get() == event.get())
457 m_enqueuedEvents.remove(i); 504 m_enqueuedEvents.remove(i);
458 } 505 }
459 506
460 Vector<RefPtr<EventTarget> > targets; 507 Vector<RefPtr<EventTarget> > targets;
461 targets.append(this); 508 targets.append(this);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } 605 }
559 606
560 EventTargetData* IDBRequest::ensureEventTargetData() 607 EventTargetData* IDBRequest::ensureEventTargetData()
561 { 608 {
562 return &m_eventTargetData; 609 return &m_eventTargetData;
563 } 610 }
564 611
565 } // namespace WebCore 612 } // namespace WebCore
566 613
567 #endif 614 #endif
OLDNEW
« no previous file with comments | « Source/WebCore/Modules/indexeddb/IDBRequest.h ('k') | Source/WebCore/bindings/v8/IDBBindingUtilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698