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 18 matching lines...) Expand all Loading... |
29 #include "bindings/v8/ScriptWrappable.h" | 29 #include "bindings/v8/ScriptWrappable.h" |
30 #include "core/dom/ActiveDOMObject.h" | 30 #include "core/dom/ActiveDOMObject.h" |
31 #include "core/dom/DOMError.h" | 31 #include "core/dom/DOMError.h" |
32 #include "core/events/EventListener.h" | 32 #include "core/events/EventListener.h" |
33 #include "modules/EventModules.h" | 33 #include "modules/EventModules.h" |
34 #include "modules/EventTargetModules.h" | 34 #include "modules/EventTargetModules.h" |
35 #include "modules/indexeddb/IDBMetadata.h" | 35 #include "modules/indexeddb/IDBMetadata.h" |
36 #include "modules/indexeddb/IndexedDB.h" | 36 #include "modules/indexeddb/IndexedDB.h" |
37 #include "platform/heap/Handle.h" | 37 #include "platform/heap/Handle.h" |
38 #include "public/platform/WebIDBDatabase.h" | 38 #include "public/platform/WebIDBDatabase.h" |
| 39 #include "public/platform/WebIDBTypes.h" |
39 #include "wtf/HashSet.h" | 40 #include "wtf/HashSet.h" |
40 | 41 |
41 namespace WebCore { | 42 namespace WebCore { |
42 | 43 |
43 class DOMError; | 44 class DOMError; |
44 class ExceptionState; | 45 class ExceptionState; |
45 class IDBCursor; | 46 class IDBCursor; |
46 class IDBDatabase; | 47 class IDBDatabase; |
47 class IDBObjectStore; | 48 class IDBObjectStore; |
48 class IDBOpenDBRequest; | 49 class IDBOpenDBRequest; |
49 struct IDBObjectStoreMetadata; | 50 struct IDBObjectStoreMetadata; |
50 | 51 |
51 class IDBTransaction FINAL | 52 class IDBTransaction FINAL |
52 : public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<IDBTransa
ction> | 53 : public RefCountedGarbageCollectedWillBeGarbageCollectedFinalized<IDBTransa
ction> |
53 , public ScriptWrappable | 54 , public ScriptWrappable |
54 , public EventTargetWithInlineData | 55 , public EventTargetWithInlineData |
55 , public ActiveDOMObject { | 56 , public ActiveDOMObject { |
56 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<I
DBTransaction>); | 57 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<I
DBTransaction>); |
57 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(IDBTransaction); | 58 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(IDBTransaction); |
58 public: | 59 public: |
59 static IDBTransaction* create(ExecutionContext*, int64_t, const Vector<Strin
g>& objectStoreNames, blink::WebIDBDatabase::TransactionMode, IDBDatabase*); | 60 static IDBTransaction* create(ExecutionContext*, int64_t, const Vector<Strin
g>& objectStoreNames, blink::WebIDBTransactionMode, IDBDatabase*); |
60 static IDBTransaction* create(ExecutionContext*, int64_t, IDBDatabase*, IDBO
penDBRequest*, const IDBDatabaseMetadata& previousMetadata); | 61 static IDBTransaction* create(ExecutionContext*, int64_t, IDBDatabase*, IDBO
penDBRequest*, const IDBDatabaseMetadata& previousMetadata); |
61 virtual ~IDBTransaction(); | 62 virtual ~IDBTransaction(); |
62 virtual void trace(Visitor*) OVERRIDE; | 63 virtual void trace(Visitor*) OVERRIDE; |
63 | 64 |
64 static const AtomicString& modeReadOnly(); | 65 static const AtomicString& modeReadOnly(); |
65 static const AtomicString& modeReadWrite(); | 66 static const AtomicString& modeReadWrite(); |
66 static const AtomicString& modeVersionChange(); | 67 static const AtomicString& modeVersionChange(); |
67 | 68 |
68 static blink::WebIDBDatabase::TransactionMode stringToMode(const String&, Ex
ceptionState&); | 69 static blink::WebIDBTransactionMode stringToMode(const String&, ExceptionSta
te&); |
69 static const AtomicString& modeToString(blink::WebIDBDatabase::TransactionMo
de); | 70 static const AtomicString& modeToString(blink::WebIDBTransactionMode); |
70 | 71 |
71 // When the connection is closed backend will be 0. | 72 // When the connection is closed backend will be 0. |
72 blink::WebIDBDatabase* backendDB() const; | 73 blink::WebIDBDatabase* backendDB() const; |
73 | 74 |
74 int64_t id() const { return m_id; } | 75 int64_t id() const { return m_id; } |
75 bool isActive() const { return m_state == Active; } | 76 bool isActive() const { return m_state == Active; } |
76 bool isFinished() const { return m_state == Finished; } | 77 bool isFinished() const { return m_state == Finished; } |
77 bool isFinishing() const { return m_state == Finishing; } | 78 bool isFinishing() const { return m_state == Finishing; } |
78 bool isReadOnly() const { return m_mode == blink::WebIDBDatabase::Transactio
nReadOnly; } | 79 bool isReadOnly() const { return m_mode == blink::WebIDBTransactionModeReadO
nly; } |
79 bool isVersionChange() const { return m_mode == blink::WebIDBDatabase::Trans
actionVersionChange; } | 80 bool isVersionChange() const { return m_mode == blink::WebIDBTransactionMode
VersionChange; } |
80 | 81 |
81 // Implement the IDBTransaction IDL | 82 // Implement the IDBTransaction IDL |
82 const String& mode() const; | 83 const String& mode() const; |
83 IDBDatabase* db() const { return m_database.get(); } | 84 IDBDatabase* db() const { return m_database.get(); } |
84 PassRefPtrWillBeRawPtr<DOMError> error() const { return m_error; } | 85 PassRefPtrWillBeRawPtr<DOMError> error() const { return m_error; } |
85 IDBObjectStore* objectStore(const String& name, ExceptionState&); | 86 IDBObjectStore* objectStore(const String& name, ExceptionState&); |
86 void abort(ExceptionState&); | 87 void abort(ExceptionState&); |
87 | 88 |
88 void registerRequest(IDBRequest*); | 89 void registerRequest(IDBRequest*); |
89 void unregisterRequest(IDBRequest*); | 90 void unregisterRequest(IDBRequest*); |
(...skipping 14 matching lines...) Expand all Loading... |
104 virtual ExecutionContext* executionContext() const OVERRIDE; | 105 virtual ExecutionContext* executionContext() const OVERRIDE; |
105 | 106 |
106 using EventTarget::dispatchEvent; | 107 using EventTarget::dispatchEvent; |
107 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE; | 108 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) OVERRIDE; |
108 | 109 |
109 // ActiveDOMObject | 110 // ActiveDOMObject |
110 virtual bool hasPendingActivity() const OVERRIDE; | 111 virtual bool hasPendingActivity() const OVERRIDE; |
111 virtual void stop() OVERRIDE; | 112 virtual void stop() OVERRIDE; |
112 | 113 |
113 private: | 114 private: |
114 IDBTransaction(ExecutionContext*, int64_t, const Vector<String>&, blink::Web
IDBDatabase::TransactionMode, IDBDatabase*, IDBOpenDBRequest*, const IDBDatabase
Metadata&); | 115 IDBTransaction(ExecutionContext*, int64_t, const Vector<String>&, blink::Web
IDBTransactionMode, IDBDatabase*, IDBOpenDBRequest*, const IDBDatabaseMetadata&)
; |
115 | 116 |
116 void enqueueEvent(PassRefPtrWillBeRawPtr<Event>); | 117 void enqueueEvent(PassRefPtrWillBeRawPtr<Event>); |
117 | 118 |
118 enum State { | 119 enum State { |
119 Inactive, // Created or started, but not in an event callback | 120 Inactive, // Created or started, but not in an event callback |
120 Active, // Created or started, in creation scope or an event callback | 121 Active, // Created or started, in creation scope or an event callback |
121 Finishing, // In the process of aborting or completing. | 122 Finishing, // In the process of aborting or completing. |
122 Finished, // No more events will fire and no new requests may be filed. | 123 Finished, // No more events will fire and no new requests may be filed. |
123 }; | 124 }; |
124 | 125 |
125 int64_t m_id; | 126 int64_t m_id; |
126 Member<IDBDatabase> m_database; | 127 Member<IDBDatabase> m_database; |
127 const Vector<String> m_objectStoreNames; | 128 const Vector<String> m_objectStoreNames; |
128 Member<IDBOpenDBRequest> m_openDBRequest; | 129 Member<IDBOpenDBRequest> m_openDBRequest; |
129 const blink::WebIDBDatabase::TransactionMode m_mode; | 130 const blink::WebIDBTransactionMode m_mode; |
130 State m_state; | 131 State m_state; |
131 bool m_hasPendingActivity; | 132 bool m_hasPendingActivity; |
132 bool m_contextStopped; | 133 bool m_contextStopped; |
133 RefPtrWillBeMember<DOMError> m_error; | 134 RefPtrWillBeMember<DOMError> m_error; |
134 | 135 |
135 HeapListHashSet<Member<IDBRequest> > m_requestList; | 136 HeapListHashSet<Member<IDBRequest> > m_requestList; |
136 | 137 |
137 typedef HeapHashMap<String, Member<IDBObjectStore> > IDBObjectStoreMap; | 138 typedef HeapHashMap<String, Member<IDBObjectStore> > IDBObjectStoreMap; |
138 IDBObjectStoreMap m_objectStoreMap; | 139 IDBObjectStoreMap m_objectStoreMap; |
139 | 140 |
140 typedef HeapHashSet<Member<IDBObjectStore> > IDBObjectStoreSet; | 141 typedef HeapHashSet<Member<IDBObjectStore> > IDBObjectStoreSet; |
141 IDBObjectStoreSet m_deletedObjectStores; | 142 IDBObjectStoreSet m_deletedObjectStores; |
142 | 143 |
143 typedef HeapHashMap<Member<IDBObjectStore>, IDBObjectStoreMetadata> IDBObjec
tStoreMetadataMap; | 144 typedef HeapHashMap<Member<IDBObjectStore>, IDBObjectStoreMetadata> IDBObjec
tStoreMetadataMap; |
144 IDBObjectStoreMetadataMap m_objectStoreCleanupMap; | 145 IDBObjectStoreMetadataMap m_objectStoreCleanupMap; |
145 IDBDatabaseMetadata m_previousMetadata; | 146 IDBDatabaseMetadata m_previousMetadata; |
146 }; | 147 }; |
147 | 148 |
148 } // namespace WebCore | 149 } // namespace WebCore |
149 | 150 |
150 #endif // IDBTransaction_h | 151 #endif // IDBTransaction_h |
OLD | NEW |