Changeset 56713 in webkit


Ignore:
Timestamp:
Mar 29, 2010 2:26:16 AM (14 years ago)
Author:
jorlow@chromium.org
Message:

2010-03-24 Jeremy Orlow <jorlow@chromium.org>

Reviewed by Darin Fisher.

A few more steps towards IndexedDB
https://bugs.webkit.org/show_bug.cgi?id=36546

Add a callback interface to be used by all async methods.
Add the first fragments of IDBDatabase.
Clean up on IDBDatabaseError.
Flesh out IndexedDatabase further.

Not enough hooked up yet to test. Soon though...

  • WebCore.gypi:
  • storage/IDBCallbacks.h: Added. (WebCore::IDBCallbacks::~IDBCallbacks):
  • storage/IDBDatabase.cpp: Added.
  • storage/IDBDatabase.h: Added. (WebCore::IDBDatabase::~IDBDatabase):
  • storage/IDBDatabaseError.h: (WebCore::IDBDatabaseError::create): (WebCore::IDBDatabaseError::message): (WebCore::IDBDatabaseError::IDBDatabaseError):
  • storage/IndexedDatabase.h:
  • storage/IndexedDatabaseImpl.cpp: (WebCore::IndexedDatabaseImpl::IndexedDatabaseImpl): (WebCore::IndexedDatabaseImpl::~IndexedDatabaseImpl): (WebCore::IndexedDatabaseImpl::open):
  • storage/IndexedDatabaseImpl.h:
  • storage/IndexedDatabaseRequest.cpp: (WebCore::IndexedDatabaseRequest::open):

2010-03-24 Jeremy Orlow <jorlow@chromium.org>

Reviewed by Darin Fisher.

More IndexedDB plumbing
https://bugs.webkit.org/show_bug.cgi?id=36546

Plumbing work towards the goal of making IndexedDatabase::open work.

  • WebKit.gyp:
  • public/WebIDBCallbacks.h: Added. (WebKit::WebIDBCallbacks::~WebIDBCallbacks):
  • public/WebIDBDatabase.h: Added. (WebKit::WebIDBDatabase::~WebIDBDatabase):
  • public/WebIDBDatabaseError.h: Added. (WebKit::WebIDBDatabaseError::WebIDBDatabaseError): (WebKit::WebIDBDatabaseError::operator=):
  • public/WebIndexedDatabase.h:
  • public/WebKitClient.h: (WebKit::WebKitClient::indexedDatabase):
  • public/WebSerializedScriptValue.h:
  • src/IDBCallbacksProxy.h: Added. (WebCore::IDBCallbacksProxy::IDBCallbacksProxy): (WebCore::IDBCallbacksProxy::~IDBCallbacksProxy): (WebCore::IDBCallbacksProxy::onSuccess): (WebCore::IDBCallbacksProxy::onError):
  • src/IDBDatabaseProxy.cpp: Added. (WebCore::IDBDatabaseProxy::create): (WebCore::IDBDatabaseProxy::IDBDatabaseProxy): (WebCore::IDBDatabaseProxy::~IDBDatabaseProxy):
  • src/IDBDatabaseProxy.h: Added.
  • src/IndexedDatabaseProxy.cpp: (WebCore::IndexedDatabaseProxy::IndexedDatabaseProxy): (WebCore::IndexedDatabaseProxy::open):
  • src/IndexedDatabaseProxy.h:
  • src/WebIDBDatabaseError.cpp: Added. (WebKit::WebIDBDatabaseError::~WebIDBDatabaseError): (WebKit::WebIDBDatabaseError::WebIDBDatabaseError): (WebKit::WebIDBDatabaseError::assign): (WebKit::WebIDBDatabaseError::code): (WebKit::WebIDBDatabaseError::message): (WebKit::WebIDBDatabaseError::operator=): (WebKit::WebIDBDatabaseError::operator PassRefPtr<IDBDatabaseError>):
Location:
trunk
Files:
2 added
13 edited
8 copied

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r56711 r56713  
     12010-03-24  Jeremy Orlow  <jorlow@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        A few more steps towards IndexedDB
     6        https://bugs.webkit.org/show_bug.cgi?id=36546
     7
     8        Add a callback interface to be used by all async methods.
     9        Add the first fragments of IDBDatabase.
     10        Clean up on IDBDatabaseError.
     11        Flesh out IndexedDatabase further.
     12
     13        Not enough hooked up yet to test.  Soon though...
     14
     15        * WebCore.gypi:
     16        * storage/IDBCallbacks.h: Added.
     17        (WebCore::IDBCallbacks::~IDBCallbacks):
     18        * storage/IDBDatabase.cpp: Added.
     19        * storage/IDBDatabase.h: Added.
     20        (WebCore::IDBDatabase::~IDBDatabase):
     21        * storage/IDBDatabaseError.h:
     22        (WebCore::IDBDatabaseError::create):
     23        (WebCore::IDBDatabaseError::message):
     24        (WebCore::IDBDatabaseError::IDBDatabaseError):
     25        * storage/IndexedDatabase.h:
     26        * storage/IndexedDatabaseImpl.cpp:
     27        (WebCore::IndexedDatabaseImpl::IndexedDatabaseImpl):
     28        (WebCore::IndexedDatabaseImpl::~IndexedDatabaseImpl):
     29        (WebCore::IndexedDatabaseImpl::open):
     30        * storage/IndexedDatabaseImpl.h:
     31        * storage/IndexedDatabaseRequest.cpp:
     32        (WebCore::IndexedDatabaseRequest::open):
     33
    1342010-03-29  Mikhail Naganov  <mnaganov@chromium.org>
    235
  • trunk/WebCore/WebCore.gypi

    r56704 r56713  
    32683268            'storage/DatabaseTracker.h',
    32693269            'storage/DatabaseTrackerClient.h',
     3270            'storage/IDBCallbacks.h',
     3271            'storage/IDBDatabase.h',
     3272            'storage/IDBDatabase.cpp',
    32703273            'storage/IDBDatabaseError.h',
    32713274            'storage/IDBDatabaseException.h',
  • trunk/WebCore/storage/IDBCallbacks.h

    r56712 r56713  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 #include "config.h"
    29 #include "IndexedDatabaseRequest.h"
    3028
    31 #if ENABLE(INDEXED_DATABASE)
     29#ifndef IDBCallbacks_h
     30#define IDBCallbacks_h
    3231
    33 #include "ExceptionCode.h"
    34 #include "IDBRequest.h"
     32#include <wtf/PassRefPtr.h>
     33#include <wtf/RefCounted.h>
    3534
    3635namespace WebCore {
    3736
    38 IndexedDatabaseRequest::IndexedDatabaseRequest()
    39 {
    40 }
     37class IDBDatabaseError;
    4138
    42 IndexedDatabaseRequest::~IndexedDatabaseRequest()
    43 {
    44 }
     39template <typename ResultType>
     40class IDBCallbacks : public RefCounted<IDBCallbacks<ResultType> > {
     41public:
     42    virtual ~IDBCallbacks() { }
    4543
    46 void IndexedDatabaseRequest::open(const String& name, const String& description, bool modifyDatabase, ExceptionCode& exception)
    47 {
    48 }
     44    virtual void onSuccess(PassRefPtr<ResultType>) = 0;
     45    virtual void onError(PassRefPtr<IDBDatabaseError>) = 0;
     46};
    4947
    5048} // namespace WebCore
    5149
    52 #endif // ENABLE(INDEXED_DATABASE)
     50#endif // IDBCallbacks_h
    5351
  • trunk/WebCore/storage/IDBDatabase.h

    r56712 r56713  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 #ifndef IndexedDatabaseImpl_h
    29 #define IndexedDatabaseImpl_h
    3028
    31 #include "IndexedDatabase.h"
     29#ifndef IDBDatabase_h
     30#define IDBDatabase_h
     31
     32#include <wtf/Threading.h>
    3233
    3334#if ENABLE(INDEXED_DATABASE)
     
    3536namespace WebCore {
    3637
    37 class IndexedDatabaseImpl : public IndexedDatabase {
     38// This class is shared by IDBDatabaseRequest (async) and IDBDatabaseSync (sync).
     39// This is implemented by IDBDatabaseImpl and optionally others (in order to proxy
     40// calls across process barriers). All calls to these classes should be non-blocking and
     41// trigger work on a background thread if necessary.
     42class IDBDatabase : public ThreadSafeShared<IDBDatabase> {
    3843public:
    39     static PassRefPtr<IndexedDatabaseImpl> get();
    40     virtual ~IndexedDatabaseImpl();
    41 
    42     virtual void open(const String& name, const String& description, bool modifyDatabase, ExceptionCode&);
    43 
    44 private:
    45     IndexedDatabaseImpl();
    46 
    47     // We only create one instance of this class at a time.
    48     static IndexedDatabaseImpl* indexedDatabaseImpl;
     44    virtual ~IDBDatabase() { }
     45    // FIXME: Write.
    4946};
    5047
     
    5350#endif
    5451
    55 #endif // IndexedDatabaseImpl_h
     52#endif // IDBDatabase_h
    5653
  • trunk/WebCore/storage/IDBDatabaseError.h

    r54085 r56713  
    3939class IDBDatabaseError : public RefCounted<IDBDatabaseError> {
    4040public:
    41     static PassRefPtr<IDBDatabaseError> create()
     41    static PassRefPtr<IDBDatabaseError> create(unsigned short code, const String& message)
    4242    {
    43         return adoptRef(new IDBDatabaseError());
     43        return adoptRef(new IDBDatabaseError(code, message));
    4444    }
    4545    ~IDBDatabaseError() { }
     
    4747    unsigned short code() const { return m_code; }
    4848    void setCode(unsigned short value) { m_code = value; }
    49     String message() const { return m_message; }
     49    const String& message() const { return m_message; }
    5050    void setMessage(const String& value) { m_message = value; }
    5151
    5252private:
    53     IDBDatabaseError() { }
     53    IDBDatabaseError(unsigned short code, const String& message)
     54        : m_code(code), m_message(message) { }
    5455
    5556    unsigned short m_code;
  • trunk/WebCore/storage/IndexedDatabase.h

    r55784 r56713  
    3030
    3131#include "ExceptionCode.h"
     32#include "IDBCallbacks.h"
    3233#include "PlatformString.h"
    3334#include <wtf/Threading.h>
     
    3637
    3738namespace WebCore {
     39
     40class IDBDatabase;
     41
     42typedef IDBCallbacks<IDBDatabase> IDBDatabaseCallbacks;
    3843
    3944// This class is shared by IndexedDatabaseRequest (async) and IndexedDatabaseSync (sync).
     
    4651    virtual ~IndexedDatabase() { }
    4752
    48     virtual void open(const String& name, const String& description, bool modifyDatabase, ExceptionCode&) = 0;
     53    virtual void open(const String& name, const String& description, bool modifyDatabase, ExceptionCode&, PassRefPtr<IDBDatabaseCallbacks>) = 0;
    4954};
    5055
  • trunk/WebCore/storage/IndexedDatabaseImpl.cpp

    r55784 r56713  
    2929#include "IndexedDatabaseImpl.h"
    3030
     31#include "IDBDatabase.h"
     32#include "IDBDatabaseError.h"
    3133#include <wtf/Threading.h>
    3234
     
    4749IndexedDatabaseImpl::IndexedDatabaseImpl()
    4850{
    49     // FIXME: Make this thread safe.
     51    // FIXME: Make this thread safe before implementing a sync interface.
    5052    ASSERT(!indexedDatabaseImpl);
    5153    indexedDatabaseImpl = this;
     
    5456IndexedDatabaseImpl::~IndexedDatabaseImpl()
    5557{
    56     // FIXME: Make this thread safe.
     58    // FIXME: Make this thread safe before implementing a sync interface.
    5759    ASSERT(indexedDatabaseImpl == this);
    5860    indexedDatabaseImpl = 0;
    5961}
    6062
    61 void IndexedDatabaseImpl::open(const String& name, const String& description, bool modifyDatabase, ExceptionCode&)
     63void IndexedDatabaseImpl::open(const String& name, const String& description, bool modifyDatabase, ExceptionCode&, PassRefPtr<IDBDatabaseCallbacks>)
    6264{
    6365    // FIXME: Write.
     66    ASSERT_NOT_REACHED();
    6467}
    6568
  • trunk/WebCore/storage/IndexedDatabaseImpl.h

    r55784 r56713  
    4040    virtual ~IndexedDatabaseImpl();
    4141
    42     virtual void open(const String& name, const String& description, bool modifyDatabase, ExceptionCode&);
     42    virtual void open(const String& name, const String& description, bool modifyDatabase, ExceptionCode&, PassRefPtr<IDBCallbacks<IDBDatabase> >);
    4343
    4444private:
  • trunk/WebCore/storage/IndexedDatabaseRequest.cpp

    r54085 r56713  
    4646void IndexedDatabaseRequest::open(const String& name, const String& description, bool modifyDatabase, ExceptionCode& exception)
    4747{
     48    // FIXME: This should initiate a request.
    4849}
    4950
  • trunk/WebKit/chromium/ChangeLog

    r56711 r56713  
     12010-03-24  Jeremy Orlow  <jorlow@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        More IndexedDB plumbing
     6        https://bugs.webkit.org/show_bug.cgi?id=36546
     7
     8        Plumbing work towards the goal of making IndexedDatabase::open work.
     9
     10        * WebKit.gyp:
     11        * public/WebIDBCallbacks.h: Added.
     12        (WebKit::WebIDBCallbacks::~WebIDBCallbacks):
     13        * public/WebIDBDatabase.h: Added.
     14        (WebKit::WebIDBDatabase::~WebIDBDatabase):
     15        * public/WebIDBDatabaseError.h: Added.
     16        (WebKit::WebIDBDatabaseError::WebIDBDatabaseError):
     17        (WebKit::WebIDBDatabaseError::operator=):
     18        * public/WebIndexedDatabase.h:
     19        * public/WebKitClient.h:
     20        (WebKit::WebKitClient::indexedDatabase):
     21        * public/WebSerializedScriptValue.h:
     22        * src/IDBCallbacksProxy.h: Added.
     23        (WebCore::IDBCallbacksProxy::IDBCallbacksProxy):
     24        (WebCore::IDBCallbacksProxy::~IDBCallbacksProxy):
     25        (WebCore::IDBCallbacksProxy::onSuccess):
     26        (WebCore::IDBCallbacksProxy::onError):
     27        * src/IDBDatabaseProxy.cpp: Added.
     28        (WebCore::IDBDatabaseProxy::create):
     29        (WebCore::IDBDatabaseProxy::IDBDatabaseProxy):
     30        (WebCore::IDBDatabaseProxy::~IDBDatabaseProxy):
     31        * src/IDBDatabaseProxy.h: Added.
     32        * src/IndexedDatabaseProxy.cpp:
     33        (WebCore::IndexedDatabaseProxy::IndexedDatabaseProxy):
     34        (WebCore::IndexedDatabaseProxy::open):
     35        * src/IndexedDatabaseProxy.h:
     36        * src/WebIDBDatabaseError.cpp: Added.
     37        (WebKit::WebIDBDatabaseError::~WebIDBDatabaseError):
     38        (WebKit::WebIDBDatabaseError::WebIDBDatabaseError):
     39        (WebKit::WebIDBDatabaseError::assign):
     40        (WebKit::WebIDBDatabaseError::code):
     41        (WebKit::WebIDBDatabaseError::message):
     42        (WebKit::WebIDBDatabaseError::operator=):
     43        (WebKit::WebIDBDatabaseError::operator PassRefPtr<IDBDatabaseError>):
     44
    1452010-03-29  Mikhail Naganov  <mnaganov@chromium.org>
    246
  • trunk/WebKit/chromium/WebKit.gyp

    r56637 r56713  
    129129                'public/WebImage.h',
    130130                'public/WebImageDecoder.h',
     131                'public/WebIDBCallbacks.h',
     132                'public/WebIDBDatabase.h',
     133                'public/WebIDBDatabaseError.h',
    131134                'public/WebIndexedDatabase.h',
    132135                'public/WebInputElement.h',
     
    248251                'src/gtk/WebFontInfo.h',
    249252                'src/gtk/WebInputEventFactory.cpp',
     253                'src/IDBCallbacksProxy.h',
     254                'src/IDBDatabaseProxy.cpp',
     255                'src/IDBDatabaseProxy.h',
    250256                'src/IndexedDatabaseProxy.cpp',
    251257                'src/IndexedDatabaseProxy.h',
     
    324330                'src/WebHistoryItem.cpp',
    325331                'src/WebHTTPBody.cpp',
     332                'src/WebIDBDatabaseError.cpp',
    326333                'src/WebImageCG.cpp',
    327334                'src/WebImageDecoder.cpp',
  • trunk/WebKit/chromium/public/WebIDBCallbacks.h

    r56712 r56713  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 #ifndef WebIndexedDatabase_h
    29 #define WebIndexedDatabase_h
     28
     29#ifndef WebIDBCallbacks_h
     30#define WebIDBCallbacks_h
    3031
    3132#include "WebCommon.h"
     
    3334namespace WebKit {
    3435
    35 class WebString;
     36class WebIDBDatabaseError;
    3637
    37 // The entry point into the IndexedDatabase API.  These classes match their _____Request and
    38 // _____Sync counterparts in the spec, but operate only in an async manner.
    39 // http://dev.w3.org/2006/webapi/WebSimpleDB/
    40 class WebIndexedDatabase {
     38// Every IndexedDB method takes in a pair of callbacks for error/success which
     39// implement this class.  Either 0 or 1 of these methods will be called and the
     40// callback class may be deleted any time after the callback is called.
     41template <typename ResultType>
     42class WebIDBCallbacks {
    4143public:
    42     // FIXME: Implement entry back into WebKit for this API.
     44    virtual ~WebIDBCallbacks() { }
    4345
    44     virtual ~WebIndexedDatabase() { }
     46    // If the method was a success, this method is called with the result.  The
     47    // result is a pointer that the callback takes ownership of.
     48    virtual void onSuccess(ResultType*) = 0;
    4549
    46     // FIXME: This should return an AsyncReturn<> object.
    47     virtual void open(const WebString& name, const WebString& description, bool modifyDatabase, int& exceptionCode) = 0;
     50    // Called in the event of an error.
     51    virtual void onError(const WebIDBDatabaseError&) = 0;
    4852};
    4953
    5054} // namespace WebKit
    5155
    52 #endif // WebStorageNamespace_h
     56#endif // WebIDBCallbacks_h
  • trunk/WebKit/chromium/public/WebIDBDatabase.h

    r56712 r56713  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 #include "config.h"
    29 #include "IndexedDatabaseRequest.h"
    3028
    31 #if ENABLE(INDEXED_DATABASE)
     29#ifndef WebIDBDatabase_h
     30#define WebIDBDatabase_h
    3231
    33 #include "ExceptionCode.h"
    34 #include "IDBRequest.h"
     32#include "WebCommon.h"
    3533
    36 namespace WebCore {
     34namespace WebKit {
    3735
    38 IndexedDatabaseRequest::IndexedDatabaseRequest()
    39 {
    40 }
     36// See comment in WebIndexedDatabase for a high level overview these classes.
     37class WebIDBDatabase {
     38public:
     39    virtual ~WebIDBDatabase() { }
    4140
    42 IndexedDatabaseRequest::~IndexedDatabaseRequest()
    43 {
    44 }
     41    // FIXME: Implement.
     42};
    4543
    46 void IndexedDatabaseRequest::open(const String& name, const String& description, bool modifyDatabase, ExceptionCode& exception)
    47 {
    48 }
     44} // namespace WebKit
    4945
    50 } // namespace WebCore
    51 
    52 #endif // ENABLE(INDEXED_DATABASE)
    53 
     46#endif // WebIDBDatabase_h
  • trunk/WebKit/chromium/public/WebIDBDatabaseError.h

    r56712 r56713  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 #ifndef WebIndexedDatabase_h
    29 #define WebIndexedDatabase_h
     28
     29#ifndef WebIDBDatabaseError_h
     30#define WebIDBDatabaseError_h
    3031
    3132#include "WebCommon.h"
     33#include "WebPrivatePtr.h"
     34#include "WebString.h"
     35
     36namespace WebCore { class IDBDatabaseError; }
    3237
    3338namespace WebKit {
    3439
    35 class WebString;
     40// See comment in WebIndexedDatabase for a high level overview these classes.
     41class WebIDBDatabaseError {
     42public:
     43    ~WebIDBDatabaseError();
    3644
    37 // The entry point into the IndexedDatabase API.  These classes match their _____Request and
    38 // _____Sync counterparts in the spec, but operate only in an async manner.
    39 // http://dev.w3.org/2006/webapi/WebSimpleDB/
    40 class WebIndexedDatabase {
    41 public:
    42     // FIXME: Implement entry back into WebKit for this API.
     45    WebIDBDatabaseError(unsigned short code, const WebString& message) { assign(code, message); }
     46    WebIDBDatabaseError(const WebIDBDatabaseError& e) { assign(e); }
     47    WebIDBDatabaseError& operator=(const WebIDBDatabaseError& e)
     48    {
     49        assign(e);
     50        return *this;
     51    }
    4352
    44     virtual ~WebIndexedDatabase() { }
     53    WEBKIT_API void assign(const WebIDBDatabaseError&);
    4554
    46     // FIXME: This should return an AsyncReturn<> object.
    47     virtual void open(const WebString& name, const WebString& description, bool modifyDatabase, int& exceptionCode) = 0;
     55    WEBKIT_API unsigned short code() const;
     56    WEBKIT_API WebString message() const;
     57
     58#if WEBKIT_IMPLEMENTATION
     59    WebIDBDatabaseError(const WTF::PassRefPtr<WebCore::IDBDatabaseError>&);
     60    WebIDBDatabaseError& operator=(const WTF::PassRefPtr<WebCore::IDBDatabaseError>&);
     61    operator WTF::PassRefPtr<WebCore::IDBDatabaseError>() const;
     62#endif
     63
     64private:
     65    WEBKIT_API void assign(unsigned short code, const WebString& message);
     66
     67    WebPrivatePtr<WebCore::IDBDatabaseError> m_private;
    4868};
    4969
    5070} // namespace WebKit
    5171
    52 #endif // WebStorageNamespace_h
     72#endif // WebIDBDatabaseError_h
  • trunk/WebKit/chromium/public/WebIndexedDatabase.h

    r55784 r56713  
    3030
    3131#include "WebCommon.h"
     32#include "WebIDBCallbacks.h"
    3233
    3334namespace WebKit {
    3435
     36class WebIDBDatabase;
    3537class WebString;
    3638
     
    4446    virtual ~WebIndexedDatabase() { }
    4547
    46     // FIXME: This should return an AsyncReturn<> object.
    47     virtual void open(const WebString& name, const WebString& description, bool modifyDatabase, int& exceptionCode) = 0;
     48    virtual void open(const WebString& name, const WebString& description, bool modifyDatabase, int& exceptionCode, WebIDBCallbacks<WebIDBDatabase>* callbacks) = 0;
    4849};
    4950
    5051} // namespace WebKit
    5152
    52 #endif // WebStorageNamespace_h
     53#endif // WebIndexedDatabase_h
  • trunk/WebKit/chromium/public/WebKitClient.h

    r56381 r56713  
    155155    // Indexed Database ----------------------------------------------------
    156156
    157     virtual WebIndexedDatabase* getIndexedDatabase() { return 0; }
     157    virtual WebIndexedDatabase* indexedDatabase() { return 0; }
    158158
    159159
  • trunk/WebKit/chromium/src/IDBCallbacksProxy.h

    r56712 r56713  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 #ifndef IDBDatabaseError_h
    29 #define IDBDatabaseError_h
    3028
    31 #include "PlatformString.h"
     29#ifndef IDBCallbacksProxy_h
     30#define IDBCallbacksProxy_h
     31
     32#include "IDBCallbacks.h"
     33#include "IDBDatabaseError.h"
     34#include "WebIDBCallbacks.h"
     35#include "WebIDBDatabaseError.h"
    3236#include <wtf/PassRefPtr.h>
    33 #include <wtf/RefCounted.h>
     37#include <wtf/RefPtr.h>
    3438
    3539#if ENABLE(INDEXED_DATABASE)
     
    3741namespace WebCore {
    3842
    39 class IDBDatabaseError : public RefCounted<IDBDatabaseError> {
     43template <typename WebKitClass, typename WebCoreClass, typename WebCoreProxy>
     44class IDBCallbacksProxy : public WebKit::WebIDBCallbacks<WebKitClass> {
    4045public:
    41     static PassRefPtr<IDBDatabaseError> create()
     46    IDBCallbacksProxy(PassRefPtr<IDBCallbacks<WebCoreClass> > callbacks)
     47        : m_callbacks(callbacks) { }
     48
     49    virtual ~IDBCallbacksProxy() { }
     50
     51    virtual void onSuccess(WebKitClass* webKitInstance)
    4252    {
    43         return adoptRef(new IDBDatabaseError());
     53        RefPtr<WebCoreClass> proxy = WebCoreProxy::create(webKitInstance);
     54        m_callbacks->onSuccess(proxy);
     55        m_callbacks.clear();
    4456    }
    45     ~IDBDatabaseError() { }
    4657
    47     unsigned short code() const { return m_code; }
    48     void setCode(unsigned short value) { m_code = value; }
    49     String message() const { return m_message; }
    50     void setMessage(const String& value) { m_message = value; }
     58    virtual void onError(const WebKit::WebIDBDatabaseError& error)
     59    {
     60        m_callbacks->onError(error);
     61        m_callbacks.clear();
     62    }
    5163
    5264private:
    53     IDBDatabaseError() { }
     65    PassRefPtr<IDBCallbacks<WebCoreClass> > m_callbacks;
     66};
    5467
    55     unsigned short m_code;
    56     String m_message;
    57 };
    5868
    5969} // namespace WebCore
     
    6171#endif
    6272
    63 #endif // IDBDatabaseError_h
    64 
     73#endif // IDBCallbacksProxy_h
  • trunk/WebKit/chromium/src/IDBDatabaseProxy.cpp

    r56712 r56713  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829#include "config.h"
    29 #include "IndexedDatabaseRequest.h"
     30#include "IDBDatabaseProxy.h"
     31
     32#include "IDBDatabaseError.h"
     33#include "WebIDBDatabase.h"
     34#include "WebIDBDatabaseError.h"
    3035
    3136#if ENABLE(INDEXED_DATABASE)
    3237
    33 #include "ExceptionCode.h"
    34 #include "IDBRequest.h"
    35 
    3638namespace WebCore {
    3739
    38 IndexedDatabaseRequest::IndexedDatabaseRequest()
     40PassRefPtr<IDBDatabase> IDBDatabaseProxy::create(PassOwnPtr<WebKit::WebIDBDatabase> database)
     41{
     42    return adoptRef(new IDBDatabaseProxy(database));
     43}
     44
     45IDBDatabaseProxy::IDBDatabaseProxy(PassOwnPtr<WebKit::WebIDBDatabase> database)
     46    : m_webIDBDatabase(database)
    3947{
    4048}
    4149
    42 IndexedDatabaseRequest::~IndexedDatabaseRequest()
    43 {
    44 }
    45 
    46 void IndexedDatabaseRequest::open(const String& name, const String& description, bool modifyDatabase, ExceptionCode& exception)
     50IDBDatabaseProxy::~IDBDatabaseProxy()
    4751{
    4852}
  • trunk/WebKit/chromium/src/IDBDatabaseProxy.h

    r56712 r56713  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 #ifndef IndexedDatabaseProxy_h
    29 #define IndexedDatabaseProxy_h
    3028
    31 #include "IndexedDatabase.h"
     29#ifndef IDBDatabaseProxy_h
     30#define IDBDatabaseProxy_h
     31
     32#include "IDBDatabase.h"
     33#include <wtf/OwnPtr.h>
     34#include <wtf/PassOwnPtr.h>
     35#include <wtf/PassRefPtr.h>
    3236
    3337#if ENABLE(INDEXED_DATABASE)
    3438
    35 namespace WebKit { class WebIndexedDatabase; }
     39namespace WebKit { class WebIDBDatabase; }
    3640
    3741namespace WebCore {
    3842
    39 class IndexedDatabaseProxy : public IndexedDatabase {
     43class IDBDatabaseProxy : public IDBDatabase {
    4044public:
    41     static PassRefPtr<IndexedDatabase> create();
    42     virtual ~IndexedDatabaseProxy();
     45    static PassRefPtr<IDBDatabase> create(PassOwnPtr<WebKit::WebIDBDatabase>);
     46    virtual ~IDBDatabaseProxy();
    4347
    44     virtual void open(const String& name, const String& description, bool modifyDatabase, ExceptionCode&);
     48    // FIXME: Add other methods.
    4549
    4650private:
    47     IndexedDatabaseProxy();
     51    IDBDatabaseProxy(PassOwnPtr<WebKit::WebIDBDatabase>);
    4852
    49     // We don't own this pointer.
    50     WebKit::WebIndexedDatabase* m_webIndexedDatabase;
     53    OwnPtr<WebKit::WebIDBDatabase> m_webIDBDatabase;
    5154};
    5255
     
    5558#endif
    5659
    57 #endif // IndexedDatabaseProxy_h
     60#endif // IDBDatabaseProxy_h
    5861
  • trunk/WebKit/chromium/src/IndexedDatabaseProxy.cpp

    r55784 r56713  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829#include "config.h"
    2930#include "IndexedDatabaseProxy.h"
    3031
     32#include "IDBCallbacksProxy.h"
     33#include "IDBDatabaseError.h"
     34#include "IDBDatabaseProxy.h"
     35#include "WebIDBDatabase.h"
     36#include "WebIDBDatabaseError.h"
    3137#include "WebIndexedDatabase.h"
    3238#include "WebKit.h"
     
    4349
    4450IndexedDatabaseProxy::IndexedDatabaseProxy()
    45     : m_webIndexedDatabase(WebKit::webKitClient()->getIndexedDatabase())
     51    : m_webIndexedDatabase(WebKit::webKitClient()->indexedDatabase())
    4652{
    4753}
     
    5157}
    5258
    53 void IndexedDatabaseProxy::open(const String& name, const String& description, bool modifyDatabase, ExceptionCode& ec)
     59void IndexedDatabaseProxy::open(const String& name, const String& description, bool modifyDatabase, ExceptionCode& ec, PassRefPtr<IDBDatabaseCallbacks> callbacks)
    5460{
    55     m_webIndexedDatabase->open(name, description, modifyDatabase, ec);
     61    m_webIndexedDatabase->open(name, description, modifyDatabase, ec,
     62                               new IDBCallbacksProxy<WebKit::WebIDBDatabase, IDBDatabase, IDBDatabaseProxy>(callbacks));
    5663}
    5764
  • trunk/WebKit/chromium/src/IndexedDatabaseProxy.h

    r55784 r56713  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829#ifndef IndexedDatabaseProxy_h
    2930#define IndexedDatabaseProxy_h
     
    4243    virtual ~IndexedDatabaseProxy();
    4344
    44     virtual void open(const String& name, const String& description, bool modifyDatabase, ExceptionCode&);
     45    virtual void open(const String& name, const String& description, bool modifyDatabase, ExceptionCode&, PassRefPtr<IDBDatabaseCallbacks>);
    4546
    4647private:
    4748    IndexedDatabaseProxy();
    4849
    49     // We don't own this pointer.
     50    // We don't own this pointer (unlike all the other proxy classes which do).
    5051    WebKit::WebIndexedDatabase* m_webIndexedDatabase;
    5152};
Note: See TracChangeset for help on using the changeset viewer.