| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 #include "bindings/v8/DOMRequestState.h" | 32 #include "bindings/v8/DOMRequestState.h" |
| 33 #include "bindings/v8/ScriptWrappable.h" | 33 #include "bindings/v8/ScriptWrappable.h" |
| 34 #include "core/dom/ActiveDOMObject.h" | 34 #include "core/dom/ActiveDOMObject.h" |
| 35 #include "core/dom/DOMError.h" | 35 #include "core/dom/DOMError.h" |
| 36 #include "core/dom/DOMStringList.h" | 36 #include "core/dom/DOMStringList.h" |
| 37 #include "core/events/Event.h" | 37 #include "core/events/Event.h" |
| 38 #include "core/events/EventListener.h" | 38 #include "core/events/EventListener.h" |
| 39 #include "core/events/EventTarget.h" | 39 #include "core/events/EventTarget.h" |
| 40 #include "core/events/ThreadLocalEventNames.h" | 40 #include "core/events/ThreadLocalEventNames.h" |
| 41 #include "heap/Handle.h" |
| 41 #include "modules/indexeddb/IDBAny.h" | 42 #include "modules/indexeddb/IDBAny.h" |
| 42 #include "modules/indexeddb/IDBCursor.h" | 43 #include "modules/indexeddb/IDBCursor.h" |
| 43 #include "modules/indexeddb/IDBTransaction.h" | 44 #include "modules/indexeddb/IDBTransaction.h" |
| 44 #include "modules/indexeddb/IndexedDB.h" | 45 #include "modules/indexeddb/IndexedDB.h" |
| 45 #include "public/platform/WebIDBCursor.h" | 46 #include "public/platform/WebIDBCursor.h" |
| 46 | 47 |
| 47 namespace WebCore { | 48 namespace WebCore { |
| 48 | 49 |
| 49 class ExceptionState; | 50 class ExceptionState; |
| 50 struct IDBDatabaseMetadata; | 51 struct IDBDatabaseMetadata; |
| 51 class SharedBuffer; | 52 class SharedBuffer; |
| 52 | 53 |
| 53 // Base class to simplify usage of event target refcounting. | 54 // Base class to simplify usage of event target refcounting. |
| 54 class IDBRequestBase : public WTF::RefCountedBase { | 55 class IDBRequestBase : public WTF::RefCountedBase { |
| 55 public: | 56 public: |
| 56 virtual void deref() = 0; | 57 virtual void deref() = 0; |
| 57 | 58 |
| 58 protected: | 59 protected: |
| 59 virtual ~IDBRequestBase() { } | 60 virtual ~IDBRequestBase() { } |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 class IDBRequest : public IDBRequestBase, public ScriptWrappable, public EventTa
rgetWithInlineData, public ActiveDOMObject { | 63 class IDBRequest : public IDBRequestBase, public ScriptWrappable, public EventTa
rgetWithInlineData, public ActiveDOMObject { |
| 63 DEFINE_EVENT_TARGET_REFCOUNTING(IDBRequestBase); | 64 DEFINE_EVENT_TARGET_REFCOUNTING(IDBRequestBase); |
| 64 | 65 |
| 65 public: | 66 public: |
| 66 static PassRefPtr<IDBRequest> create(ExecutionContext*, PassRefPtr<IDBAny> s
ource, IDBTransaction*); | 67 static PassRefPtr<IDBRequest> create(ExecutionContext*, PassRefPtr<IDBAny> s
ource, IDBTransaction*); |
| 67 virtual ~IDBRequest(); | 68 virtual ~IDBRequest(); |
| 68 | 69 |
| 69 ScriptValue result(ExceptionState&); | 70 ScriptValue result(ExceptionState&); |
| 70 PassRefPtr<DOMError> error(ExceptionState&) const; | 71 PassRefPtrWillBeRawPtr<DOMError> error(ExceptionState&) const; |
| 71 ScriptValue source(ExecutionContext*) const; | 72 ScriptValue source(ExecutionContext*) const; |
| 72 PassRefPtr<IDBTransaction> transaction() const { return m_transaction; } | 73 PassRefPtr<IDBTransaction> transaction() const { return m_transaction; } |
| 73 | 74 |
| 74 bool isResultDirty() const { return m_resultDirty; } | 75 bool isResultDirty() const { return m_resultDirty; } |
| 75 PassRefPtr<IDBAny> resultAsAny() const { return m_result; } | 76 PassRefPtr<IDBAny> resultAsAny() const { return m_result; } |
| 76 | 77 |
| 77 // Requests made during index population are implementation details and so | 78 // Requests made during index population are implementation details and so |
| 78 // events should not be visible to script. | 79 // events should not be visible to script. |
| 79 void preventPropagation() { m_preventPropagation = true; } | 80 void preventPropagation() { m_preventPropagation = true; } |
| 80 | 81 |
| 81 // Defined in the IDL | 82 // Defined in the IDL |
| 82 enum ReadyState { | 83 enum ReadyState { |
| 83 PENDING = 1, | 84 PENDING = 1, |
| 84 DONE = 2, | 85 DONE = 2, |
| 85 EarlyDeath = 3 | 86 EarlyDeath = 3 |
| 86 }; | 87 }; |
| 87 | 88 |
| 88 const String& readyState() const; | 89 const String& readyState() const; |
| 89 | 90 |
| 90 DEFINE_ATTRIBUTE_EVENT_LISTENER(success); | 91 DEFINE_ATTRIBUTE_EVENT_LISTENER(success); |
| 91 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 92 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
| 92 | 93 |
| 93 void setCursorDetails(IndexedDB::CursorType, blink::WebIDBCursor::Direction)
; | 94 void setCursorDetails(IndexedDB::CursorType, blink::WebIDBCursor::Direction)
; |
| 94 void setPendingCursor(PassRefPtr<IDBCursor>); | 95 void setPendingCursor(PassRefPtr<IDBCursor>); |
| 95 void abort(); | 96 void abort(); |
| 96 | 97 |
| 97 virtual void onError(PassRefPtr<DOMError>); | 98 virtual void onError(PassRefPtrWillBeRawPtr<DOMError>); |
| 98 virtual void onSuccess(const Vector<String>&); | 99 virtual void onSuccess(const Vector<String>&); |
| 99 virtual void onSuccess(PassOwnPtr<blink::WebIDBCursor>, PassRefPtr<IDBKey>,
PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer>); | 100 virtual void onSuccess(PassOwnPtr<blink::WebIDBCursor>, PassRefPtr<IDBKey>,
PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer>); |
| 100 virtual void onSuccess(PassRefPtr<IDBKey>); | 101 virtual void onSuccess(PassRefPtr<IDBKey>); |
| 101 virtual void onSuccess(PassRefPtr<SharedBuffer>); | 102 virtual void onSuccess(PassRefPtr<SharedBuffer>); |
| 102 virtual void onSuccess(PassRefPtr<SharedBuffer>, PassRefPtr<IDBKey>, const I
DBKeyPath&); | 103 virtual void onSuccess(PassRefPtr<SharedBuffer>, PassRefPtr<IDBKey>, const I
DBKeyPath&); |
| 103 virtual void onSuccess(int64_t); | 104 virtual void onSuccess(int64_t); |
| 104 virtual void onSuccess(); | 105 virtual void onSuccess(); |
| 105 virtual void onSuccess(PassRefPtr<IDBKey>, PassRefPtr<IDBKey> primaryKey, Pa
ssRefPtr<SharedBuffer>); | 106 virtual void onSuccess(PassRefPtr<IDBKey>, PassRefPtr<IDBKey> primaryKey, Pa
ssRefPtr<SharedBuffer>); |
| 106 | 107 |
| 107 // Only IDBOpenDBRequest instances should receive these: | 108 // Only IDBOpenDBRequest instances should receive these: |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 RefPtr<IDBTransaction> m_transaction; | 150 RefPtr<IDBTransaction> m_transaction; |
| 150 ReadyState m_readyState; | 151 ReadyState m_readyState; |
| 151 bool m_requestAborted; // May be aborted by transaction then receive async o
nsuccess; ignore vs. assert. | 152 bool m_requestAborted; // May be aborted by transaction then receive async o
nsuccess; ignore vs. assert. |
| 152 | 153 |
| 153 private: | 154 private: |
| 154 void setResultCursor(PassRefPtr<IDBCursor>, PassRefPtr<IDBKey>, PassRefPtr<I
DBKey> primaryKey, PassRefPtr<SharedBuffer> value); | 155 void setResultCursor(PassRefPtr<IDBCursor>, PassRefPtr<IDBKey>, PassRefPtr<I
DBKey> primaryKey, PassRefPtr<SharedBuffer> value); |
| 155 void checkForReferenceCycle(); | 156 void checkForReferenceCycle(); |
| 156 | 157 |
| 157 RefPtr<IDBAny> m_source; | 158 RefPtr<IDBAny> m_source; |
| 158 RefPtr<IDBAny> m_result; | 159 RefPtr<IDBAny> m_result; |
| 159 RefPtr<DOMError> m_error; | 160 RefPtrWillBePersistent<DOMError> m_error; |
| 160 | 161 |
| 161 bool m_hasPendingActivity; | 162 bool m_hasPendingActivity; |
| 162 Vector<RefPtr<Event> > m_enqueuedEvents; | 163 Vector<RefPtr<Event> > m_enqueuedEvents; |
| 163 | 164 |
| 164 // Only used if the result type will be a cursor. | 165 // Only used if the result type will be a cursor. |
| 165 IndexedDB::CursorType m_cursorType; | 166 IndexedDB::CursorType m_cursorType; |
| 166 blink::WebIDBCursor::Direction m_cursorDirection; | 167 blink::WebIDBCursor::Direction m_cursorDirection; |
| 167 // When a cursor is continued/advanced, m_result is cleared and m_pendingCur
sor holds it. | 168 // When a cursor is continued/advanced, m_result is cleared and m_pendingCur
sor holds it. |
| 168 RefPtr<IDBCursor> m_pendingCursor; | 169 RefPtr<IDBCursor> m_pendingCursor; |
| 169 // New state is not applied to the cursor object until the event is dispatch
ed. | 170 // New state is not applied to the cursor object until the event is dispatch
ed. |
| 170 RefPtr<IDBKey> m_cursorKey; | 171 RefPtr<IDBKey> m_cursorKey; |
| 171 RefPtr<IDBKey> m_cursorPrimaryKey; | 172 RefPtr<IDBKey> m_cursorPrimaryKey; |
| 172 RefPtr<SharedBuffer> m_cursorValue; | 173 RefPtr<SharedBuffer> m_cursorValue; |
| 173 | 174 |
| 174 bool m_didFireUpgradeNeededEvent; | 175 bool m_didFireUpgradeNeededEvent; |
| 175 bool m_preventPropagation; | 176 bool m_preventPropagation; |
| 176 bool m_resultDirty; | 177 bool m_resultDirty; |
| 177 | 178 |
| 178 DOMRequestState m_requestState; | 179 DOMRequestState m_requestState; |
| 179 }; | 180 }; |
| 180 | 181 |
| 181 } // namespace WebCore | 182 } // namespace WebCore |
| 182 | 183 |
| 183 #endif // IDBRequest_h | 184 #endif // IDBRequest_h |
| OLD | NEW |