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

Unified Diff: third_party/WebKit/Source/modules/indexeddb/IDBMetadata.h

Issue 2314933005: Align IndexedDB metadata rollback on transaction abort to spec. (Closed)
Patch Set: Rebased. Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/indexeddb/IDBMetadata.h
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.h b/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.h
index 74f1bd80d1bc4b136e5344aa07771728eb826dd0..a88a1147f7fe5187434758441d3ecf3dda34eb1a 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.h
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.h
@@ -33,20 +33,25 @@
#include "public/platform/modules/indexeddb/WebIDBMetadata.h"
#include "wtf/Allocator.h"
#include "wtf/HashMap.h"
+#include "wtf/RefCounted.h"
+#include "wtf/RefPtr.h"
#include "wtf/text/StringHash.h"
#include "wtf/text/WTFString.h"
namespace blink {
-struct IDBIndexMetadata {
- DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
- IDBIndexMetadata() { }
- IDBIndexMetadata(const String& name, int64_t id, const IDBKeyPath& keyPath, bool unique, bool multiEntry)
- : name(name)
- , id(id)
- , keyPath(keyPath)
- , unique(unique)
- , multiEntry(multiEntry) { }
+// The lifecycle of the IndexedDB metadata objects defined below is managed by
+// reference counting (RefPtr). We don't have to worry about cycles because
+// these objects form a tree with the hierarch shown below.
+// IDBDatabaseMetadata -> IDBObjectStoreMetadata -> IDBIndexMetadata
+
+class IDBIndexMetadata : public RefCounted<IDBIndexMetadata> {
+ USING_FAST_MALLOC(IDBIndexMetadata);
+
+public:
+ IDBIndexMetadata();
+ IDBIndexMetadata(const String& name, int64_t id, const IDBKeyPath&, bool unique, bool multiEntry);
+
String name;
int64_t id;
IDBKeyPath keyPath;
@@ -56,17 +61,16 @@ struct IDBIndexMetadata {
static constexpr int64_t InvalidId = -1;
};
-struct IDBObjectStoreMetadata {
- DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
- IDBObjectStoreMetadata() { }
- IDBObjectStoreMetadata(const String& name, int64_t id, const IDBKeyPath& keyPath, bool autoIncrement, int64_t maxIndexId)
- : name(name)
- , id(id)
- , keyPath(keyPath)
- , autoIncrement(autoIncrement)
- , maxIndexId(maxIndexId)
- {
- }
+class IDBObjectStoreMetadata : public RefCounted<IDBObjectStoreMetadata> {
+ USING_FAST_MALLOC(IDBObjectStoreMetadata);
+
+public:
+ IDBObjectStoreMetadata();
+ IDBObjectStoreMetadata(const String& name, int64_t id, const IDBKeyPath&, bool autoIncrement, int64_t maxIndexId);
+
+ // Creates a deep copy of the object metadata, which includes copies of index metadata items.
+ RefPtr<IDBObjectStoreMetadata> createCopy() const;
+
String name;
int64_t id;
IDBKeyPath keyPath;
@@ -75,32 +79,22 @@ struct IDBObjectStoreMetadata {
static constexpr int64_t InvalidId = -1;
- typedef HashMap<int64_t, IDBIndexMetadata> IndexMap;
+ using IndexMap = HashMap<int64_t, RefPtr<IDBIndexMetadata>>;
IndexMap indexes;
};
-struct IDBDatabaseMetadata {
+struct MODULES_EXPORT IDBDatabaseMetadata {
DISALLOW_NEW();
+
+public:
// FIXME: These can probably be collapsed into 0.
enum {
NoVersion = -1,
DefaultVersion = 0
};
- typedef HashMap<int64_t, IDBObjectStoreMetadata> ObjectStoreMap;
-
- IDBDatabaseMetadata()
- : version(NoVersion)
- {
- }
-
- IDBDatabaseMetadata(const String& name, int64_t id, int64_t version, int64_t maxObjectStoreId)
- : name(name)
- , id(id)
- , version(version)
- , maxObjectStoreId(maxObjectStoreId)
- {
- }
+ IDBDatabaseMetadata();
+ IDBDatabaseMetadata(const String& name, int64_t id, int64_t version, int64_t maxObjectStoreId);
explicit IDBDatabaseMetadata(const WebIDBMetadata&);
@@ -109,6 +103,7 @@ struct IDBDatabaseMetadata {
int64_t version;
int64_t maxObjectStoreId;
+ using ObjectStoreMap = HashMap<int64_t, RefPtr<IDBObjectStoreMetadata>>;
jsbell 2016/09/26 22:23:40 Nit: Per style guide (google, not overridden by ch
pwnall 2016/09/27 00:12:19 Done. I also moved "using" in IDBObjectStore.h an
ObjectStoreMap objectStores;
};

Powered by Google App Engine
This is Rietveld 408576698