Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBTransaction.h

Issue 1963293002: Replacing Indexed DB Chromium IPC with Mojo Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactoring after Passing URLRequestContextGetter. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef IDBTransaction_h 26 #ifndef IDBTransaction_h
27 #define IDBTransaction_h 27 #define IDBTransaction_h
28 28
29 #include "Source/modules/indexeddb/indexed_db.mojom-blink.h"
29 #include "bindings/core/v8/ActiveScriptWrappable.h" 30 #include "bindings/core/v8/ActiveScriptWrappable.h"
30 #include "bindings/core/v8/ScriptState.h" 31 #include "bindings/core/v8/ScriptState.h"
31 #include "core/dom/ActiveDOMObject.h" 32 #include "core/dom/ActiveDOMObject.h"
32 #include "core/dom/DOMStringList.h" 33 #include "core/dom/DOMStringList.h"
33 #include "core/events/EventListener.h" 34 #include "core/events/EventListener.h"
34 #include "modules/EventModules.h" 35 #include "modules/EventModules.h"
35 #include "modules/EventTargetModules.h" 36 #include "modules/EventTargetModules.h"
36 #include "modules/ModulesExport.h" 37 #include "modules/ModulesExport.h"
37 #include "modules/indexeddb/IDBMetadata.h" 38 #include "modules/indexeddb/IDBMetadata.h"
38 #include "modules/indexeddb/IndexedDB.h" 39 #include "modules/indexeddb/IndexedDB.h"
39 #include "platform/heap/Handle.h" 40 #include "platform/heap/Handle.h"
40 #include "public/platform/modules/indexeddb/WebIDBDatabase.h"
41 #include "public/platform/modules/indexeddb/WebIDBTypes.h" 41 #include "public/platform/modules/indexeddb/WebIDBTypes.h"
42 #include "wtf/HashSet.h" 42 #include "wtf/HashSet.h"
43 43
44 namespace blink { 44 namespace blink {
45 45
46 class DOMException; 46 class DOMException;
47 class ExceptionState; 47 class ExceptionState;
48 class IDBDatabase; 48 class IDBDatabase;
49 class IDBDatabaseProxy;
49 class IDBObjectStore; 50 class IDBObjectStore;
50 class IDBOpenDBRequest; 51 class IDBOpenDBRequest;
51 struct IDBObjectStoreMetadata; 52 struct IDBObjectStoreMetadata;
52 53
53 class MODULES_EXPORT IDBTransaction final 54 class MODULES_EXPORT IDBTransaction final
54 : public EventTargetWithInlineData 55 : public EventTargetWithInlineData
55 , public ActiveScriptWrappable 56 , public ActiveScriptWrappable
56 , public ActiveDOMObject { 57 , public ActiveDOMObject {
57 USING_GARBAGE_COLLECTED_MIXIN(IDBTransaction); 58 USING_GARBAGE_COLLECTED_MIXIN(IDBTransaction);
58 DEFINE_WRAPPERTYPEINFO(); 59 DEFINE_WRAPPERTYPEINFO();
59 public: 60 public:
60 static IDBTransaction* create(ScriptState*, int64_t, const HashSet<String>& objectStoreNames, WebIDBTransactionMode, IDBDatabase*); 61 static IDBTransaction* create(ScriptState*, int64_t, const HashSet<String>& objectStoreNames, indexed_db::mojom::blink::TransactionMode, IDBDatabase*);
61 static IDBTransaction* create(ScriptState*, int64_t, IDBDatabase*, IDBOpenDB Request*, const IDBDatabaseMetadata& previousMetadata); 62 static IDBTransaction* create(ScriptState*, int64_t, IDBDatabase*, IDBOpenDB Request*, const IDBDatabaseMetadata& previousMetadata);
62 ~IDBTransaction() override; 63 ~IDBTransaction() override;
63 DECLARE_VIRTUAL_TRACE(); 64 DECLARE_VIRTUAL_TRACE();
64 65
65 static WebIDBTransactionMode stringToMode(const String&); 66 static indexed_db::mojom::blink::TransactionMode stringToMode(const String&) ;
66 67
67 // When the connection is closed backend will be 0. 68 // When the connection is closed backend will be 0.
68 WebIDBDatabase* backendDB() const; 69 IDBDatabaseProxy* backendDB() const;
69 70
70 int64_t id() const { return m_id; } 71 int64_t id() const { return m_id; }
71 bool isActive() const { return m_state == Active; } 72 bool isActive() const { return m_state == Active; }
72 bool isFinished() const { return m_state == Finished; } 73 bool isFinished() const { return m_state == Finished; }
73 bool isFinishing() const { return m_state == Finishing; } 74 bool isFinishing() const { return m_state == Finishing; }
74 bool isReadOnly() const { return m_mode == WebIDBTransactionModeReadOnly; } 75 bool isReadOnly() const { return m_mode == indexed_db::mojom::blink::Transac tionMode::ReadOnly; }
75 bool isVersionChange() const { return m_mode == WebIDBTransactionModeVersion Change; } 76 bool isVersionChange() const { return m_mode == indexed_db::mojom::blink::Tr ansactionMode::VersionChange; }
76 77
77 // Implement the IDBTransaction IDL 78 // Implement the IDBTransaction IDL
78 const String& mode() const; 79 const String& mode() const;
79 DOMStringList* objectStoreNames() const; 80 DOMStringList* objectStoreNames() const;
80 IDBDatabase* db() const { return m_database.get(); } 81 IDBDatabase* db() const { return m_database.get(); }
81 DOMException* error() const { return m_error; } 82 DOMException* error() const { return m_error; }
82 IDBObjectStore* objectStore(const String& name, ExceptionState&); 83 IDBObjectStore* objectStore(const String& name, ExceptionState&);
83 void abort(ExceptionState&); 84 void abort(ExceptionState&);
84 85
85 void registerRequest(IDBRequest*); 86 void registerRequest(IDBRequest*);
(...skipping 18 matching lines...) Expand all
104 bool hasPendingActivity() const final; 105 bool hasPendingActivity() const final;
105 106
106 // ActiveDOMObject 107 // ActiveDOMObject
107 void stop() override; 108 void stop() override;
108 109
109 protected: 110 protected:
110 // EventTarget 111 // EventTarget
111 DispatchEventResult dispatchEventInternal(Event*) override; 112 DispatchEventResult dispatchEventInternal(Event*) override;
112 113
113 private: 114 private:
114 IDBTransaction(ScriptState*, int64_t, const HashSet<String>&, WebIDBTransact ionMode, IDBDatabase*, IDBOpenDBRequest*, const IDBDatabaseMetadata&); 115 IDBTransaction(ScriptState*, int64_t, const HashSet<String>&, indexed_db::mo jom::blink::TransactionMode, IDBDatabase*, IDBOpenDBRequest*, const IDBDatabaseM etadata&);
115 116
116 void enqueueEvent(Event*); 117 void enqueueEvent(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 const int64_t m_id; 126 const int64_t m_id;
126 Member<IDBDatabase> m_database; 127 Member<IDBDatabase> m_database;
127 const HashSet<String> m_objectStoreNames; 128 const HashSet<String> m_objectStoreNames;
128 Member<IDBOpenDBRequest> m_openDBRequest; 129 Member<IDBOpenDBRequest> m_openDBRequest;
129 const WebIDBTransactionMode m_mode; 130 const indexed_db::mojom::blink::TransactionMode m_mode;
130 State m_state = Active; 131 State m_state = Active;
131 bool m_hasPendingActivity = true; 132 bool m_hasPendingActivity = true;
132 bool m_contextStopped = false; 133 bool m_contextStopped = false;
133 Member<DOMException> m_error; 134 Member<DOMException> 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 // Used to mark stores created in an aborted upgrade transaction as 141 // Used to mark stores created in an aborted upgrade transaction as
141 // deleted. 142 // deleted.
142 HeapHashSet<Member<IDBObjectStore>> m_createdObjectStores; 143 HeapHashSet<Member<IDBObjectStore>> m_createdObjectStores;
143 144
144 // Used to notify object stores (which are no longer in m_objectStoreMap) 145 // Used to notify object stores (which are no longer in m_objectStoreMap)
145 // when the transaction is finished. 146 // when the transaction is finished.
146 HeapHashSet<Member<IDBObjectStore>> m_deletedObjectStores; 147 HeapHashSet<Member<IDBObjectStore>> m_deletedObjectStores;
147 148
148 // Holds stores created, deleted, or used during upgrade transactions to 149 // Holds stores created, deleted, or used during upgrade transactions to
149 // reset metadata in case of abort. 150 // reset metadata in case of abort.
150 HeapHashMap<Member<IDBObjectStore>, IDBObjectStoreMetadata> m_objectStoreCle anupMap; 151 HeapHashMap<Member<IDBObjectStore>, IDBObjectStoreMetadata> m_objectStoreCle anupMap;
151 IDBDatabaseMetadata m_previousMetadata; 152 IDBDatabaseMetadata m_previousMetadata;
152 }; 153 };
153 154
154 } // namespace blink 155 } // namespace blink
155 156
156 #endif // IDBTransaction_h 157 #endif // IDBTransaction_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698