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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 struct IDBObjectStoreMetadata; | 49 struct IDBObjectStoreMetadata; |
50 | 50 |
51 class IDBTransaction : public RefCountedHeapAllocated<IDBTransaction>, public Sc
riptWrappable, public EventTarget, public ActiveDOMObject { | 51 class IDBTransaction : public RefCountedHeapAllocated<IDBTransaction>, public Sc
riptWrappable, public EventTarget, public ActiveDOMObject { |
52 DECLARE_GC_MAP | 52 DECLARE_GC_MAP |
53 DEFINE_SELF_HANDLE(IDBTransaction) | 53 DEFINE_SELF_HANDLE(IDBTransaction) |
54 public: | 54 public: |
55 static PassRefPtr<IDBTransaction> create(ScriptExecutionContext*, int64_t, c
onst Vector<String>& objectStoreNames, IndexedDB::TransactionMode, IDBDatabase*)
; | 55 static PassRefPtr<IDBTransaction> create(ScriptExecutionContext*, int64_t, c
onst Vector<String>& objectStoreNames, IndexedDB::TransactionMode, IDBDatabase*)
; |
56 static PassRefPtr<IDBTransaction> create(ScriptExecutionContext*, int64_t, I
DBDatabase*, IDBOpenDBRequest*, const IDBDatabaseMetadata& previousMetadata); | 56 static PassRefPtr<IDBTransaction> create(ScriptExecutionContext*, int64_t, I
DBDatabase*, IDBOpenDBRequest*, const IDBDatabaseMetadata& previousMetadata); |
57 virtual ~IDBTransaction(); | 57 virtual ~IDBTransaction(); |
58 | 58 |
59 virtual void trace(Visitor*) { } | 59 virtual void trace(Visitor*); |
60 | 60 |
61 virtual void visitWith(Visitor* visitor) const OVERRIDE | 61 virtual void visitWith(Visitor* visitor) const OVERRIDE |
62 { | 62 { |
63 visitor->visit(this); | 63 visitor->visit(this); |
64 } | 64 } |
65 | 65 |
66 static const AtomicString& modeReadOnly(); | 66 static const AtomicString& modeReadOnly(); |
67 static const AtomicString& modeReadWrite(); | 67 static const AtomicString& modeReadWrite(); |
68 static const AtomicString& modeVersionChange(); | 68 static const AtomicString& modeVersionChange(); |
69 static const AtomicString& modeReadOnlyLegacy(); | 69 static const AtomicString& modeReadOnlyLegacy(); |
70 static const AtomicString& modeReadWriteLegacy(); | 70 static const AtomicString& modeReadWriteLegacy(); |
71 | 71 |
72 static IndexedDB::TransactionMode stringToMode(const String&, ExceptionCode&
); | 72 static IndexedDB::TransactionMode stringToMode(const String&, ExceptionCode&
); |
73 static const AtomicString& modeToString(IndexedDB::TransactionMode); | 73 static const AtomicString& modeToString(IndexedDB::TransactionMode); |
74 | 74 |
75 IDBDatabaseBackendInterface* backendDB() const; | 75 IDBDatabaseBackendInterface* backendDB() const; |
76 | 76 |
77 int64_t id() const { return m_id; } | 77 int64_t id() const { return m_id; } |
78 bool isActive() const { return m_state == Active; } | 78 bool isActive() const { return m_state == Active; } |
79 bool isFinished() const { return m_state == Finished; } | 79 bool isFinished() const { return m_state == Finished; } |
80 bool isReadOnly() const { return m_mode == IndexedDB::TransactionReadOnly; } | 80 bool isReadOnly() const { return m_mode == IndexedDB::TransactionReadOnly; } |
81 bool isVersionChange() const { return m_mode == IndexedDB::TransactionVersio
nChange; } | 81 bool isVersionChange() const { return m_mode == IndexedDB::TransactionVersio
nChange; } |
82 | 82 |
83 // Implement the IDBTransaction IDL | 83 // Implement the IDBTransaction IDL |
84 const String& mode() const; | 84 const String& mode() const; |
85 IDBDatabase* db() const { return m_database.get(); } | 85 IDBDatabase* db() const { return m_database; } |
86 PassRefPtr<DOMError> error() const { return m_error; } | 86 PassRefPtr<DOMError> error() const { return m_error; } |
87 PassRefPtr<IDBObjectStore> objectStore(const String& name, ExceptionCode&); | 87 PassRefPtr<IDBObjectStore> objectStore(const String& name, ExceptionCode&); |
88 void abort(ExceptionCode&); | 88 void abort(ExceptionCode&); |
89 | 89 |
90 class OpenCursorNotifier { | 90 class OpenCursorNotifier { |
91 public: | 91 public: |
92 OpenCursorNotifier(PassRefPtr<IDBTransaction>, IDBCursor*); | 92 OpenCursorNotifier(PassRefPtr<IDBTransaction>, IDBCursor*); |
93 ~OpenCursorNotifier(); | 93 ~OpenCursorNotifier(); |
94 void cursorFinished(); | 94 void cursorFinished(); |
95 private: | 95 private: |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 virtual EventTargetData* ensureEventTargetData(); | 141 virtual EventTargetData* ensureEventTargetData(); |
142 | 142 |
143 enum State { | 143 enum State { |
144 Inactive, // Created or started, but not in an event callback | 144 Inactive, // Created or started, but not in an event callback |
145 Active, // Created or started, in creation scope or an event callback | 145 Active, // Created or started, in creation scope or an event callback |
146 Finishing, // In the process of aborting or completing. | 146 Finishing, // In the process of aborting or completing. |
147 Finished, // No more events will fire and no new requests may be filed. | 147 Finished, // No more events will fire and no new requests may be filed. |
148 }; | 148 }; |
149 | 149 |
150 int64_t m_id; | 150 int64_t m_id; |
151 RefPtr<IDBDatabase> m_database; | 151 Member<IDBDatabase> m_database; |
152 const Vector<String> m_objectStoreNames; | 152 const Vector<String> m_objectStoreNames; |
153 IDBOpenDBRequest* m_openDBRequest; | 153 IDBOpenDBRequest* m_openDBRequest; |
154 const IndexedDB::TransactionMode m_mode; | 154 const IndexedDB::TransactionMode m_mode; |
155 State m_state; | 155 State m_state; |
156 bool m_hasPendingActivity; | 156 bool m_hasPendingActivity; |
157 bool m_contextStopped; | 157 bool m_contextStopped; |
158 RefPtr<DOMError> m_error; | 158 RefPtr<DOMError> m_error; |
159 String m_errorMessage; | 159 String m_errorMessage; |
160 | 160 |
161 ListHashSet<RefPtr<IDBRequest> > m_requestList; | 161 ListHashSet<RefPtr<IDBRequest> > m_requestList; |
162 | 162 |
163 typedef HashMap<String, RefPtr<IDBObjectStore> > IDBObjectStoreMap; | 163 typedef HashMap<String, RefPtr<IDBObjectStore> > IDBObjectStoreMap; |
164 IDBObjectStoreMap m_objectStoreMap; | 164 IDBObjectStoreMap m_objectStoreMap; |
165 | 165 |
166 typedef HashSet<RefPtr<IDBObjectStore> > IDBObjectStoreSet; | 166 typedef HashSet<RefPtr<IDBObjectStore> > IDBObjectStoreSet; |
167 IDBObjectStoreSet m_deletedObjectStores; | 167 IDBObjectStoreSet m_deletedObjectStores; |
168 | 168 |
169 typedef HashMap<RefPtr<IDBObjectStore>, IDBObjectStoreMetadata> IDBObjectSto
reMetadataMap; | 169 typedef HashMap<RefPtr<IDBObjectStore>, IDBObjectStoreMetadata> IDBObjectSto
reMetadataMap; |
170 IDBObjectStoreMetadataMap m_objectStoreCleanupMap; | 170 IDBObjectStoreMetadataMap m_objectStoreCleanupMap; |
171 IDBDatabaseMetadata m_previousMetadata; | 171 IDBDatabaseMetadata m_previousMetadata; |
172 | 172 |
173 HashSet<IDBCursor*> m_openCursors; | 173 HashSet<IDBCursor*> m_openCursors; |
174 | 174 |
175 EventTargetData m_eventTargetData; | 175 EventTargetData m_eventTargetData; |
176 }; | 176 }; |
177 | 177 |
178 } // namespace WebCore | 178 } // namespace WebCore |
179 | 179 |
180 #endif // IDBTransaction_h | 180 #endif // IDBTransaction_h |
OLD | NEW |