Changeset 56834 in webkit
- Timestamp:
- Mar 31, 2010 3:35:32 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 6 edited
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r56833 r56834 1 2010-03-30 Jeremy Orlow <jorlow@chromium.org> 2 3 Reviewed by Nate Chapin. 4 5 IndexedDB: Finish hooking up bindings for IndexedDatabaseRequest 6 https://bugs.webkit.org/show_bug.cgi?id=36830 7 8 Still not enough hooked up to test. Soon! 9 10 * WebCore.gypi: 11 * bindings/v8/custom/V8CustomIDBCallback.h: Removed. 12 * bindings/v8/custom/V8CustomIDBCallbacks.h: Added. 13 (WebCore::V8CustomIDBCallbacks::create): 14 (WebCore::V8CustomIDBCallbacks::~V8CustomIDBCallbacks): 15 (WebCore::V8CustomIDBCallbacks::onSuccess): 16 (WebCore::V8CustomIDBCallbacks::onError): 17 (WebCore::V8CustomIDBCallbacks::V8CustomIDBCallbacks): 18 * bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp: 19 (WebCore::V8IndexedDatabaseRequest::openCallback): 20 * storage/IDBDatabaseRequest.cpp: Added. 21 (WebCore::IDBDatabaseRequest::IDBDatabaseRequest): 22 (WebCore::IDBDatabaseRequest::~IDBDatabaseRequest): 23 * storage/IDBDatabaseRequest.h: 24 (WebCore::IDBDatabaseRequest::create): 25 * storage/IndexedDatabaseRequest.cpp: 26 (WebCore::IndexedDatabaseRequest::open): 27 * storage/IndexedDatabaseRequest.h: 28 1 29 2010-03-31 Zhenyao Mo <zmo@google.com> 2 30 -
trunk/WebCore/WebCore.gypi
r56825 r56834 697 697 'bindings/v8/custom/V8CSSStyleSheetCustom.cpp', 698 698 'bindings/v8/custom/V8CSSValueCustom.cpp', 699 'bindings/v8/custom/V8Custom Callback.h',699 'bindings/v8/custom/V8CustomIDBCallbacks.h', 700 700 'bindings/v8/custom/V8CustomEventListener.cpp', 701 701 'bindings/v8/custom/V8CustomEventListener.h', … … 3269 3269 'storage/IDBDatabaseError.h', 3270 3270 'storage/IDBDatabaseException.h', 3271 'storage/IDBDatabaseRequest.cpp', 3271 3272 'storage/IDBDatabaseRequest.h', 3272 3273 'storage/IndexedDatabase.cpp', -
trunk/WebCore/bindings/v8/custom/V8CustomIDBCallbacks.h
r56833 r56834 29 29 */ 30 30 31 #ifndef V8CustomIDBCallback _h32 #define V8CustomIDBCallback _h31 #ifndef V8CustomIDBCallbacks_h 32 #define V8CustomIDBCallbacks_h 33 33 34 34 #include "Frame.h" 35 #include "IDBDatabaseError.h" 35 36 #include "V8CustomVoidCallback.h" 37 #include "V8IDBDatabaseError.h" 36 38 #include <v8.h> 37 39 #include <wtf/PassRefPtr.h> … … 44 46 45 47 // FIXME: Maybe split common parts into a base class. 46 template <typename CallbackType>47 class V8CustomIDBCallback : public RefCounted<V8CustomIDBCallback<CallbackType>> {48 template <typename ResultType, typename ResultWrapperType> 49 class V8CustomIDBCallbacks : public IDBCallbacks<ResultType> { 48 50 public: 49 static PassRefPtr<V8CustomIDBCallback > create(v8::Local<v8::Value> value, Frame* frame)51 static PassRefPtr<V8CustomIDBCallbacks> create(v8::Local<v8::Value> onSuccess, v8::Local<v8::Value> onError, Frame* frame) 50 52 { 51 ASSERT(value->IsObject()); 52 return adoptRef(new V8CustomIDBCallback(value->ToObject(), frame)); 53 return adoptRef(new V8CustomIDBCallbacks(onSuccess, onError, frame)); 53 54 } 54 55 55 virtual ~V8CustomIDBCallback ()56 virtual ~V8CustomIDBCallbacks() 56 57 { 57 m_callback.Dispose(); 58 m_onSuccess.Dispose(); 59 m_onError.Dispose(); 58 60 } 59 61 60 virtual void handleEvent(CallbackType*result)62 virtual void onSuccess(PassRefPtr<ResultType> result) 61 63 { 64 if (m_onSuccessNull) 65 return; 62 66 v8::HandleScope handleScope; 63 67 v8::Handle<v8::Context> context = V8Proxy::context(m_frame.get()); … … 67 71 v8::Context::Scope scope(context); 68 72 v8::Handle<v8::Value> argv[] = { 69 toV8( result)73 toV8(ResultWrapperType::create(result)) 70 74 }; 71 75 RefPtr<Frame> protector(m_frame); 72 76 bool callbackReturnValue = false; 73 77 // FIXME: Do we care if this thing returns true (i.e. it raised an exception)? 74 invokeCallback(m_callback, 1, argv, callbackReturnValue); 78 invokeCallback(m_onSuccess, 1, argv, callbackReturnValue); 79 } 80 81 virtual void onError(PassRefPtr<IDBDatabaseError> error) 82 { 83 if (m_onErrorNull) 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); 75 98 } 76 99 77 100 private: 78 V8CustomIDBCallback(v8::Local<v8::Object>callback, Frame* frame) 79 : m_callback(v8::Persistent<v8::Object>::New(callback)), 80 m_frame(frame) 101 V8CustomIDBCallbacks(v8::Local<v8::Value> onSuccess, v8::Local<v8::Value> onError, Frame* frame) 102 : m_onSuccessNull(!onSuccess->IsObject()) 103 , m_onSuccess(v8::Persistent<v8::Object>::New(onSuccess->ToObject())) 104 , m_onErrorNull(!onError->IsObject()) 105 , m_onError(v8::Persistent<v8::Object>::New(onError->ToObject())) 106 , m_frame(frame) 81 107 { 82 108 } 83 109 84 v8::Persistent<v8::Object> m_callback; 110 // FIXME: Should these be v8::Functions? For some reason, VoidCallback (which this copied) uses v8::Objects. 111 bool m_onSuccessNull; 112 v8::Persistent<v8::Object> m_onSuccess; 113 bool m_onErrorNull; 114 v8::Persistent<v8::Object> m_onError; 85 115 RefPtr<Frame> m_frame; 86 116 }; … … 90 120 #endif 91 121 92 #endif // V8CustomIDBCallback _h122 #endif // V8CustomIDBCallbacks_h -
trunk/WebCore/bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp
r55778 r56834 37 37 #include "IDBDatabaseRequest.h" 38 38 #include "V8Binding.h" 39 #include "V8CustomIDBCallback .h"39 #include "V8CustomIDBCallbacks.h" 40 40 #include "V8IDBDatabaseError.h" 41 41 #include "V8IDBDatabaseRequest.h" … … 56 56 modifyDatabase = args[2]->BooleanValue(); 57 57 58 Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); 59 60 RefPtr<V8CustomIDBCallback<IDBDatabaseError> > onerror; 58 v8::Local<v8::Value> onError; 59 v8::Local<v8::Value> onSuccess; 61 60 if (args.Length() > 3 && !args[3]->IsUndefined() && !args[3]->IsNull()) { 62 61 if (!args[3]->IsObject()) 63 62 return throwError("onerror callback was not the proper type"); 64 if (frame) 65 onerror = V8CustomIDBCallback<IDBDatabaseError>::create(args[3], frame); 63 onError = args[3]; 66 64 } 67 68 RefPtr<V8CustomIDBCallback<IDBDatabaseRequest> > onsuccess;69 65 if (args.Length() > 4 && !args[4]->IsUndefined() && !args[4]->IsNull()) { 70 66 if (!args[4]->IsObject()) 71 67 return throwError("onsuccess callback was not the proper type"); 72 if (frame) 73 onsuccess = V8CustomIDBCallback<IDBDatabaseRequest>::create(args[4], frame); 68 onSuccess = args[4]; 74 69 } 75 76 if (!onerror && !onsuccess) 70 if (!onError->IsObject() && !onSuccess->IsObject()) 77 71 return throwError("Neither the onerror nor the onsuccess callbacks were set."); 78 72 73 Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); 74 RefPtr<V8CustomIDBCallbacks<IDBDatabase, IDBDatabaseRequest> > callbacks = 75 V8CustomIDBCallbacks<IDBDatabase, IDBDatabaseRequest>::create(onSuccess, onError, frame); 76 79 77 ExceptionCode ec = 0; 80 imp->open(name, description, modifyDatabase, ec );78 imp->open(name, description, modifyDatabase, ec, callbacks); 81 79 if (ec) 82 80 return throwError(ec); -
trunk/WebCore/storage/IDBDatabaseRequest.cpp
r56833 r56834 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 #ifndef IDBDatabaseRequest_h29 #define IDBDatabaseRequest_h30 28 31 #include <wtf/RefCounted.h> 29 #include "config.h" 30 #include "IDBDatabaseRequest.h" 31 32 #include "IndexedDatabase.h" 32 33 33 34 #if ENABLE(INDEXED_DATABASE) … … 35 36 namespace WebCore { 36 37 37 class IDBRequest; 38 IDBDatabaseRequest::IDBDatabaseRequest(PassRefPtr<IDBDatabase> idbDatabase) 39 : m_idbDatabase(idbDatabase) 40 { 41 } 38 42 39 class IDBDatabaseRequest : public RefCounted<IDBDatabaseRequest> { 40 public: 41 // FIXME: Write. 42 IDBRequest* request() const { return 0; } 43 void createObjectStore(const String& name, const String& keyPath, bool autoIncrement) { } 44 }; 43 IDBDatabaseRequest::~IDBDatabaseRequest() 44 { 45 } 45 46 46 47 } // namespace WebCore 47 48 48 #endif 49 #endif // ENABLE(INDEXED_DATABASE) 49 50 50 #endif // IDBDatabaseRequest_h51 -
trunk/WebCore/storage/IDBDatabaseRequest.h
r56777 r56834 29 29 #define IDBDatabaseRequest_h 30 30 31 #include "IDBDatabase.h" 32 #include "PlatformString.h" 33 #include <wtf/PassRefPtr.h> 31 34 #include <wtf/RefCounted.h> 35 #include <wtf/RefPtr.h> 32 36 33 37 #if ENABLE(INDEXED_DATABASE) … … 35 39 namespace WebCore { 36 40 37 class IDBRequest;38 39 41 class IDBDatabaseRequest : public RefCounted<IDBDatabaseRequest> { 40 42 public: 43 static PassRefPtr<IDBDatabaseRequest> create(PassRefPtr<IDBDatabase> idbDatabase) 44 { 45 return adoptRef(new IDBDatabaseRequest(idbDatabase)); 46 } 47 ~IDBDatabaseRequest(); 48 41 49 // FIXME: Write. 42 IDBRequest* request() const { return 0; }43 50 void createObjectStore(const String& name, const String& keyPath, bool autoIncrement) { } 51 52 private: 53 IDBDatabaseRequest(PassRefPtr<IDBDatabase>); 54 55 RefPtr<IDBDatabase> m_idbDatabase; 44 56 }; 45 57 -
trunk/WebCore/storage/IndexedDatabaseRequest.cpp
r56777 r56834 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 #include "config.h" 29 30 #include "IndexedDatabaseRequest.h" … … 46 47 } 47 48 48 void IndexedDatabaseRequest::open(const String& name, const String& description, bool modifyDatabase, ExceptionCode& exception )49 void IndexedDatabaseRequest::open(const String& name, const String& description, bool modifyDatabase, ExceptionCode& exception, PassRefPtr<IDBDatabaseCallbacks> callbacks) 49 50 { 50 // FIXME: This should initiate a request.51 m_indexedDatabase->open(name, description, modifyDatabase, exception, callbacks); 51 52 } 52 53 -
trunk/WebCore/storage/IndexedDatabaseRequest.h
r56777 r56834 30 30 31 31 #include "ExceptionCode.h" 32 #include "IndexedDatabase.h" 32 33 #include "PlatformString.h" 33 34 #include <wtf/PassRefPtr.h> … … 50 51 ~IndexedDatabaseRequest(); 51 52 52 void open(const String& name, const String& description, bool modifyDatabase, ExceptionCode& );53 void open(const String& name, const String& description, bool modifyDatabase, ExceptionCode&, PassRefPtr<IDBDatabaseCallbacks> callbacks); 53 54 54 55 void disconnectFrame() { m_frame = 0; }
Note: See TracChangeset
for help on using the changeset viewer.