Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / modules / indexeddb / IDBRequest.h
index f9594d7..6edb0e9 100644 (file)
@@ -29,7 +29,7 @@
 #ifndef IDBRequest_h
 #define IDBRequest_h
 
-#include "bindings/v8/DOMRequestState.h"
+#include "bindings/v8/ScriptState.h"
 #include "bindings/v8/ScriptValue.h"
 #include "bindings/v8/ScriptWrappable.h"
 #include "core/dom/ActiveDOMObject.h"
 #include "core/events/Event.h"
 #include "core/events/EventListener.h"
 #include "core/events/EventTarget.h"
-#include "heap/Handle.h"
 #include "modules/indexeddb/IDBAny.h"
 #include "modules/indexeddb/IDBTransaction.h"
 #include "modules/indexeddb/IndexedDB.h"
+#include "platform/heap/Handle.h"
+#include "public/platform/WebBlobInfo.h"
 #include "public/platform/WebIDBCursor.h"
 
 namespace WebCore {
@@ -51,6 +52,9 @@ class IDBCursor;
 struct IDBDatabaseMetadata;
 class SharedBuffer;
 
+#if ENABLE(OILPAN)
+typedef RefCountedGarbageCollected<IDBRequest> IDBRequestBase;
+#else
 // Base class to simplify usage of event target refcounting.
 class IDBRequestBase : public WTF::RefCountedBase {
 public:
@@ -59,21 +63,23 @@ public:
 protected:
     virtual ~IDBRequestBase() { }
 };
+#endif
 
 class IDBRequest : public IDBRequestBase, public ScriptWrappable, public EventTargetWithInlineData, public ActiveDOMObject {
     DEFINE_EVENT_TARGET_REFCOUNTING(IDBRequestBase);
 
 public:
-    static PassRefPtr<IDBRequest> create(ExecutionContext*, PassRefPtr<IDBAny> source, IDBTransaction*);
+    static PassRefPtrWillBeRawPtr<IDBRequest> create(ExecutionContext*, PassRefPtrWillBeRawPtr<IDBAny> source, IDBTransaction*);
     virtual ~IDBRequest();
+    virtual void trace(Visitor*);
 
     ScriptValue result(ExceptionState&);
     PassRefPtrWillBeRawPtr<DOMError> error(ExceptionState&) const;
-    ScriptValue source(ExecutionContext*) const;
-    PassRefPtr<IDBTransaction> transaction() const { return m_transaction; }
+    ScriptValue source() const;
+    IDBTransaction* transaction() const { return m_transaction.get(); }
 
     bool isResultDirty() const { return m_resultDirty; }
-    PassRefPtr<IDBAny> resultAsAny() const { return m_result; }
+    PassRefPtrWillBeRawPtr<IDBAny> resultAsAny() const { return m_result; }
 
     // Requests made during index population are implementation details and so
     // events should not be visible to script.
@@ -92,18 +98,18 @@ public:
     DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
 
     void setCursorDetails(IndexedDB::CursorType, blink::WebIDBCursor::Direction);
-    void setPendingCursor(PassRefPtr<IDBCursor>);
+    void setPendingCursor(PassRefPtrWillBeRawPtr<IDBCursor>);
     void abort();
 
     virtual void onError(PassRefPtrWillBeRawPtr<DOMError>);
     virtual void onSuccess(const Vector<String>&);
-    virtual void onSuccess(PassOwnPtr<blink::WebIDBCursor>, PassRefPtr<IDBKey>, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer>);
-    virtual void onSuccess(PassRefPtr<IDBKey>);
-    virtual void onSuccess(PassRefPtr<SharedBuffer>);
-    virtual void onSuccess(PassRefPtr<SharedBuffer>, PassRefPtr<IDBKey>, const IDBKeyPath&);
+    virtual void onSuccess(PassOwnPtr<blink::WebIDBCursor>, PassRefPtrWillBeRawPtr<IDBKey>, PassRefPtrWillBeRawPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer>, PassOwnPtr<Vector<blink::WebBlobInfo> >);
+    virtual void onSuccess(PassRefPtrWillBeRawPtr<IDBKey>);
+    virtual void onSuccess(PassRefPtr<SharedBuffer>, PassOwnPtr<Vector<blink::WebBlobInfo> >);
+    virtual void onSuccess(PassRefPtr<SharedBuffer>, PassOwnPtr<Vector<blink::WebBlobInfo> >, PassRefPtrWillBeRawPtr<IDBKey>, const IDBKeyPath&);
     virtual void onSuccess(int64_t);
     virtual void onSuccess();
-    virtual void onSuccess(PassRefPtr<IDBKey>, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer>);
+    virtual void onSuccess(PassRefPtrWillBeRawPtr<IDBKey>, PassRefPtrWillBeRawPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer>, PassOwnPtr<Vector<blink::WebBlobInfo> >);
 
     // Only IDBOpenDBRequest instances should receive these:
     virtual void onBlocked(int64_t oldVersion) { ASSERT_NOT_REACHED(); }
@@ -120,13 +126,14 @@ public:
     virtual void uncaughtExceptionInEventHandler() OVERRIDE FINAL;
 
     using EventTarget::dispatchEvent;
-    virtual bool dispatchEvent(PassRefPtr<Event>) OVERRIDE;
+    virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE;
 
     // Called by a version change transaction that has finished to set this
     // request back from DONE (following "upgradeneeded") back to PENDING (for
     // the upcoming "success" or "error").
     void transactionDidFinishAndDispatch();
 
+#if !ENABLE(OILPAN)
     virtual void deref() OVERRIDE FINAL
     {
         if (derefBase())
@@ -134,49 +141,52 @@ public:
         else if (hasOneRef())
             checkForReferenceCycle();
     }
+#endif
 
-    DOMRequestState* requestState() { return &m_requestState; }
     IDBCursor* getResultCursor() const;
 
 protected:
-    IDBRequest(ExecutionContext*, PassRefPtr<IDBAny> source, IDBTransaction*);
-    void enqueueEvent(PassRefPtr<Event>);
+    IDBRequest(ExecutionContext*, PassRefPtrWillBeRawPtr<IDBAny> source, IDBTransaction*);
+    void enqueueEvent(PassRefPtrWillBeRawPtr<Event>);
     void dequeueEvent(Event*);
     virtual bool shouldEnqueueEvent() const;
-    void onSuccessInternal(PassRefPtr<IDBAny>);
-    void setResult(PassRefPtr<IDBAny>);
+    void onSuccessInternal(PassRefPtrWillBeRawPtr<IDBAny>);
+    void setResult(PassRefPtrWillBeRawPtr<IDBAny>);
 
     bool m_contextStopped;
-    RefPtr<IDBTransaction> m_transaction;
+    RefPtrWillBeMember<IDBTransaction> m_transaction;
     ReadyState m_readyState;
     bool m_requestAborted; // May be aborted by transaction then receive async onsuccess; ignore vs. assert.
 
 private:
-    void setResultCursor(PassRefPtr<IDBCursor>, PassRefPtr<IDBKey>, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> value);
+    void setResultCursor(PassRefPtrWillBeRawPtr<IDBCursor>, PassRefPtrWillBeRawPtr<IDBKey>, PassRefPtrWillBeRawPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> value, PassOwnPtr<Vector<blink::WebBlobInfo> >);
+    void handleBlobAcks();
+#if !ENABLE(OILPAN)
     void checkForReferenceCycle();
+#endif
 
-    RefPtr<IDBAny> m_source;
-    RefPtr<IDBAny> m_result;
-    RefPtrWillBePersistent<DOMError> m_error;
+    RefPtr<ScriptState> m_scriptState;
+    RefPtrWillBeMember<IDBAny> m_source;
+    RefPtrWillBeMember<IDBAny> m_result;
+    RefPtrWillBeMember<DOMError> m_error;
 
     bool m_hasPendingActivity;
-    Vector<RefPtr<Event> > m_enqueuedEvents;
+    WillBeHeapVector<RefPtrWillBeMember<Event> > m_enqueuedEvents;
 
     // Only used if the result type will be a cursor.
     IndexedDB::CursorType m_cursorType;
     blink::WebIDBCursor::Direction m_cursorDirection;
     // When a cursor is continued/advanced, m_result is cleared and m_pendingCursor holds it.
-    RefPtr<IDBCursor> m_pendingCursor;
+    RefPtrWillBeMember<IDBCursor> m_pendingCursor;
     // New state is not applied to the cursor object until the event is dispatched.
-    RefPtr<IDBKey> m_cursorKey;
-    RefPtr<IDBKey> m_cursorPrimaryKey;
+    RefPtrWillBeMember<IDBKey> m_cursorKey;
+    RefPtrWillBeMember<IDBKey> m_cursorPrimaryKey;
     RefPtr<SharedBuffer> m_cursorValue;
+    OwnPtr<Vector<blink::WebBlobInfo> > m_blobInfo;
 
     bool m_didFireUpgradeNeededEvent;
     bool m_preventPropagation;
     bool m_resultDirty;
-
-    DOMRequestState m_requestState;
 };
 
 } // namespace WebCore