Changeset 57275 in webkit
- Timestamp:
- Apr 8, 2010 7:14:34 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r57274 r57275 1 2010-04-08 Jeremy Orlow <jorlow@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 IDB callbacks should fire asynchronously 6 https://bugs.webkit.org/show_bug.cgi?id=37265 7 8 Fix the firing behavior of the callbacks to not be synchronous. 9 10 There's still a major bug that I'm trying to track down that is keeping 11 us from testing this stuff. Promise lots of tests ASAP. 12 13 * bindings/v8/custom/V8CustomIDBCallbacks.h: 14 (WebCore::V8CustomIDBCallbacks::onSuccessAsync): 15 (WebCore::V8CustomIDBCallbacks::onErrorAsync): 16 * storage/IDBCallbacks.h: 17 (WebCore::IDBCallbacks::IDBCallbacks): 18 (WebCore::IDBCallbacks::onSuccess): 19 (WebCore::IDBCallbacks::onError): 20 (WebCore::IDBCallbacks::timerFired): 21 * storage/IndexedDatabaseRequest.cpp: 22 1 23 2010-04-08 Kent Tamura <tkent@chromium.org> 2 24 -
trunk/WebCore/bindings/v8/custom/V8CustomIDBCallbacks.h
r57203 r57275 62 62 } 63 63 64 virtual void onSuccess(PassRefPtr<ResultType> result)65 {66 onEvent(m_onSuccess, ResultWrapperType::create(result));67 }68 69 virtual void onError(PassRefPtr<IDBDatabaseError> error)70 {71 onEvent(m_onError, error);72 }73 74 64 // FIXME: Handle suspend/resume correctly. 75 65 … … 110 100 } 111 101 102 virtual void onSuccessAsync(PassRefPtr<ResultType> result) 103 { 104 onEvent(m_onSuccess, ResultWrapperType::create(result)); 105 } 106 107 virtual void onErrorAsync(PassRefPtr<IDBDatabaseError> error) 108 { 109 onEvent(m_onError, error); 110 } 111 112 112 // FIXME: Use OwnHandles. 113 113 v8::Persistent<v8::Object> m_onSuccess; -
trunk/WebCore/storage/IDBCallbacks.h
r57203 r57275 31 31 32 32 #include "ActiveDOMObject.h" 33 #include "IDBDatabaseError.h" 34 #include "Timer.h" 33 35 #include <wtf/PassRefPtr.h> 34 36 #include <wtf/RefCounted.h> 35 37 38 #if ENABLE(INDEXED_DATABASE) 39 36 40 namespace WebCore { 37 41 38 class IDBDatabaseError; 39 42 // All IndexedDB callbacks must implement this class. It handles the asynchronous firing of 43 // the callbacks. 40 44 template <typename ResultType> 41 45 class IDBCallbacks : public RefCounted<IDBCallbacks<ResultType> >, public ActiveDOMObject { 42 46 public: 43 47 IDBCallbacks(ScriptExecutionContext* scriptExecutionContext, void* upcastPointer) 44 : ActiveDOMObject(scriptExecutionContext, upcastPointer) { } 48 : ActiveDOMObject(scriptExecutionContext, upcastPointer) 49 , m_timer(this, &IDBCallbacks::timerFired) 50 { 51 } 52 45 53 virtual ~IDBCallbacks() { } 46 54 47 virtual void onSuccess(PassRefPtr<ResultType>) = 0; 48 virtual void onError(PassRefPtr<IDBDatabaseError>) = 0; 55 void onSuccess(PassRefPtr<ResultType> result) 56 { 57 ASSERT(!m_result); 58 ASSERT(!m_error); 59 m_result = result; 60 ASSERT(m_result); 61 62 ASSERT(!m_timer.isActive()); 63 m_selfRef = this; 64 m_timer.startOneShot(0); 65 } 66 67 void onError(PassRefPtr<IDBDatabaseError> error) 68 { 69 ASSERT(!m_result); 70 ASSERT(!m_error); 71 m_error = error; 72 ASSERT(m_error); 73 74 ASSERT(!m_timer.isActive()); 75 m_selfRef = this; 76 m_timer.startOneShot(0); 77 } 78 79 protected: 80 virtual void onSuccessAsync(PassRefPtr<ResultType>) = 0; 81 virtual void onErrorAsync(PassRefPtr<IDBDatabaseError>) = 0; 82 83 void timerFired(Timer<IDBCallbacks>*) 84 { 85 if (m_result) { 86 onSuccessAsync(m_result); 87 m_result = 0; 88 } else { 89 onErrorAsync(m_error); 90 m_error = 0; 91 } 92 m_selfRef = 0; // May trigger a delete immediately. 93 } 94 95 private: 96 Timer<IDBCallbacks> m_timer; 97 RefPtr<IDBCallbacks> m_selfRef; 98 RefPtr<ResultType> m_result; 99 RefPtr<IDBDatabaseError> m_error; 49 100 }; 50 101 51 102 } // namespace WebCore 52 103 104 #endif 105 53 106 #endif // IDBCallbacks_h 54 -
trunk/WebCore/storage/IndexedDatabaseRequest.cpp
r56907 r57275 31 31 32 32 #include "ExceptionCode.h" 33 #include "IDBDatabase.h" 33 34 #include "IndexedDatabase.h" 34 35
Note: See TracChangeset
for help on using the changeset viewer.