Changeset 57203 in webkit
- Timestamp:
- Apr 7, 2010 4:39:31 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r57201 r57203 1 2010-04-06 Jeremy Orlow <jorlow@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 V8CustomIDBCallbacks<> should not hold a reference to the frame 6 https://bugs.webkit.org/show_bug.cgi?id=37154 7 8 Don't hold on to a Frame reference. 9 Instead, be an ActiveDOMObject and use scriptExecutionContext() 10 to get the v8 context. 11 Factor the guts of onSuccess and onError out. 12 13 Doesn't work enough to test yet. 14 15 * bindings/v8/custom/V8CustomIDBCallbacks.h: 16 (WebCore::V8CustomIDBCallbacks::create): 17 (WebCore::V8CustomIDBCallbacks::onSuccess): 18 (WebCore::V8CustomIDBCallbacks::onError): 19 (WebCore::V8CustomIDBCallbacks::V8CustomIDBCallbacks): 20 (WebCore::V8CustomIDBCallbacks::onEvent): 21 * bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp: 22 (WebCore::V8IndexedDatabaseRequest::openCallback): 23 * storage/IDBCallbacks.h: 24 (WebCore::IDBCallbacks::IDBCallbacks): 25 1 26 2010-04-07 Sheriff Bot <webkit.review.bot@gmail.com> 2 27 -
trunk/WebCore/bindings/v8/custom/V8CustomIDBCallbacks.h
r56907 r57203 32 32 #define V8CustomIDBCallbacks_h 33 33 34 #include "Document.h" 34 35 #include "Frame.h" 35 36 #include "IDBDatabaseError.h" 36 37 #include "V8CustomVoidCallback.h" 37 38 #include "V8IDBDatabaseError.h" 39 #include "WorldContextHandle.h" 38 40 #include <v8.h> 39 41 #include <wtf/PassRefPtr.h> … … 49 51 class V8CustomIDBCallbacks : public IDBCallbacks<ResultType> { 50 52 public: 51 static PassRefPtr<V8CustomIDBCallbacks> create(v8::Local<v8::Value> onSuccess, v8::Local<v8::Value> onError, Frame* frame)53 static PassRefPtr<V8CustomIDBCallbacks> create(v8::Local<v8::Value> onSuccess, v8::Local<v8::Value> onError, ScriptExecutionContext* scriptExecutionContext) 52 54 { 53 return adoptRef(new V8CustomIDBCallbacks(onSuccess, onError, frame));55 return adoptRef(new V8CustomIDBCallbacks(onSuccess, onError, scriptExecutionContext)); 54 56 } 55 57 … … 62 64 virtual void onSuccess(PassRefPtr<ResultType> result) 63 65 { 64 if (m_onSuccess.IsEmpty()) 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 // FIXME: Handle suspend/resume correctly. 75 76 private: 77 V8CustomIDBCallbacks(v8::Local<v8::Value> onSuccess, v8::Local<v8::Value> onError, ScriptExecutionContext* scriptExecutionContext) 78 : IDBCallbacks<ResultType>(scriptExecutionContext, this) 79 , m_onSuccess(onSuccess->IsObject() ? v8::Persistent<v8::Object>::New(onSuccess->ToObject()) : v8::Persistent<v8::Object>()) 80 , m_onError(onError->IsObject() ? v8::Persistent<v8::Object>::New(onError->ToObject()) : v8::Persistent<v8::Object>()) 81 , m_worldContext(UseCurrentWorld) 82 { 83 } 84 85 template <typename Type> 86 void onEvent(v8::Persistent<v8::Object> callback, PassRefPtr<Type> value) 87 { 88 if (!ActiveDOMObject::scriptExecutionContext()) 65 89 return; 90 if (callback.IsEmpty()) 91 return; 92 66 93 v8::HandleScope handleScope; 67 v8::Handle<v8::Context> context = V8Proxy::context(m_frame.get());94 v8::Handle<v8::Context> context = toV8Context(ActiveDOMObject::scriptExecutionContext(), m_worldContext); 68 95 if (context.IsEmpty()) 69 96 return; … … 71 98 v8::Context::Scope scope(context); 72 99 v8::Handle<v8::Value> argv[] = { 73 toV8( ResultWrapperType::create(result))100 toV8(value) 74 101 }; 75 RefPtr<Frame> protector(m_frame); 102 103 // FIXME: Make this work for workers. 104 ASSERT(ActiveDOMObject::scriptExecutionContext()->isDocument()); 105 RefPtr<Frame> protector(static_cast<Document*>(ActiveDOMObject::scriptExecutionContext())->frame()); 106 76 107 bool callbackReturnValue = false; 77 108 // FIXME: Do we care if this thing returns true (i.e. it raised an exception)? 78 invokeCallback( m_onSuccess, 1, argv, callbackReturnValue);109 invokeCallback(callback, 1, argv, callbackReturnValue); 79 110 } 80 111 81 virtual void onError(PassRefPtr<IDBDatabaseError> error) 82 { 83 if (m_onError.IsEmpty()) 84 return; 85 v8::HandleScope handleScope; 86 v8::Handle<v8::Context> context = V8Proxy::context(m_frame.get()); 87 if (context.IsEmpty()) 88 return; 89 90 v8::Context::Scope scope(context); 91 v8::Handle<v8::Value> argv[] = { 92 toV8(error) 93 }; 94 RefPtr<Frame> protector(m_frame); 95 bool callbackReturnValue = false; 96 // FIXME: Do we care if this thing returns true (i.e. it raised an exception)? 97 invokeCallback(m_onError, 1, argv, callbackReturnValue); 98 } 99 100 private: 101 V8CustomIDBCallbacks(v8::Local<v8::Value> onSuccess, v8::Local<v8::Value> onError, Frame* frame) 102 : m_onSuccess(onSuccess->IsObject() ? v8::Persistent<v8::Object>::New(onSuccess->ToObject()) : v8::Persistent<v8::Object>()) 103 , m_onError(onError->IsObject() ? v8::Persistent<v8::Object>::New(onError->ToObject()) : v8::Persistent<v8::Object>()) 104 , m_frame(frame) 105 { 106 } 107 108 // FIXME: Should these be v8::Functions? For some reason, VoidCallback (which this copied) uses v8::Objects. 112 // FIXME: Use OwnHandles. 109 113 v8::Persistent<v8::Object> m_onSuccess; 110 114 v8::Persistent<v8::Object> m_onError; 111 RefPtr<Frame> m_frame; 115 116 WorldContextHandle m_worldContext; 112 117 }; 113 118 -
trunk/WebCore/bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp
r56834 r57203 73 73 Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); 74 74 RefPtr<V8CustomIDBCallbacks<IDBDatabase, IDBDatabaseRequest> > callbacks = 75 V8CustomIDBCallbacks<IDBDatabase, IDBDatabaseRequest>::create(onSuccess, onError, frame );75 V8CustomIDBCallbacks<IDBDatabase, IDBDatabaseRequest>::create(onSuccess, onError, frame->document()); 76 76 77 77 ExceptionCode ec = 0; -
trunk/WebCore/storage/IDBCallbacks.h
r56713 r57203 30 30 #define IDBCallbacks_h 31 31 32 #include "ActiveDOMObject.h" 32 33 #include <wtf/PassRefPtr.h> 33 34 #include <wtf/RefCounted.h> … … 38 39 39 40 template <typename ResultType> 40 class IDBCallbacks : public RefCounted<IDBCallbacks<ResultType> > {41 class IDBCallbacks : public RefCounted<IDBCallbacks<ResultType> >, public ActiveDOMObject { 41 42 public: 43 IDBCallbacks(ScriptExecutionContext* scriptExecutionContext, void* upcastPointer) 44 : ActiveDOMObject(scriptExecutionContext, upcastPointer) { } 42 45 virtual ~IDBCallbacks() { } 43 46
Note: See TracChangeset
for help on using the changeset viewer.