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

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

Issue 2314933005: Align IndexedDB metadata rollback on transaction abort to spec. (Closed)
Patch Set: Addressed feedback. Created 4 years, 2 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 7d4f8b0342e90ed0938004b983f36e4677784392..ab790cea1e654a742fa65111fa3b65fc839ca156 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.h
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.h
@@ -33,84 +33,86 @@
#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() {}
+// 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.
jsbell 2016/10/06 20:01:31 typo: hierarchy
pwnall 2016/10/06 22:15:22 Done. Gah... I swore I fixed this when addressing
+// IDBDatabaseMetadata -> IDBObjectStoreMetadata -> IDBIndexMetadata
+
+class IDBIndexMetadata : public RefCounted<IDBIndexMetadata> {
+ USING_FAST_MALLOC(IDBIndexMetadata);
+
+ public:
+ static constexpr int64_t InvalidId = -1;
+
+ IDBIndexMetadata();
IDBIndexMetadata(const String& name,
int64_t id,
- const IDBKeyPath& keyPath,
+ const IDBKeyPath&,
bool unique,
- bool multiEntry)
- : name(name),
- id(id),
- keyPath(keyPath),
- unique(unique),
- multiEntry(multiEntry) {}
+ bool multiEntry);
+
String name;
int64_t id;
IDBKeyPath keyPath;
bool unique;
bool multiEntry;
+};
+
+class IDBObjectStoreMetadata : public RefCounted<IDBObjectStoreMetadata> {
+ USING_FAST_MALLOC(IDBObjectStoreMetadata);
+ public:
static constexpr int64_t InvalidId = -1;
-};
-struct IDBObjectStoreMetadata {
- DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
- IDBObjectStoreMetadata() {}
+ IDBObjectStoreMetadata();
IDBObjectStoreMetadata(const String& name,
int64_t id,
- const IDBKeyPath& keyPath,
+ const IDBKeyPath&,
bool autoIncrement,
- int64_t maxIndexId)
- : name(name),
- id(id),
- keyPath(keyPath),
- autoIncrement(autoIncrement),
- maxIndexId(maxIndexId) {}
+ 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;
bool autoIncrement;
int64_t maxIndexId;
-
- static constexpr int64_t InvalidId = -1;
-
- typedef HashMap<int64_t, IDBIndexMetadata> IndexMap;
- IndexMap indexes;
+ HashMap<int64_t, RefPtr<IDBIndexMetadata>> indexes;
};
-struct IDBDatabaseMetadata {
+struct MODULES_EXPORT IDBDatabaseMetadata {
DISALLOW_NEW();
+
// FIXME: These can probably be collapsed into 0.
enum { NoVersion = -1, DefaultVersion = 0 };
- typedef HashMap<int64_t, IDBObjectStoreMetadata> ObjectStoreMap;
-
- IDBDatabaseMetadata() : version(NoVersion) {}
-
+ IDBDatabaseMetadata();
IDBDatabaseMetadata(const String& name,
int64_t id,
int64_t version,
- int64_t maxObjectStoreId)
- : name(name),
- id(id),
- version(version),
- maxObjectStoreId(maxObjectStoreId) {}
+ int64_t maxObjectStoreId);
explicit IDBDatabaseMetadata(const WebIDBMetadata&);
+ // Overwrites the database metadata, but does not change the object store and
+ // index metadata.
+ void copyDatabaseMetadataFrom(const IDBDatabaseMetadata&);
jsbell 2016/10/06 20:01:31 Simplify to just 'copyFrom' ?
pwnall 2016/10/06 22:15:22 Done. FWIW, I think that copyFrom is a bit of a li
+
String name;
int64_t id;
int64_t version;
int64_t maxObjectStoreId;
-
- ObjectStoreMap objectStores;
+ HashMap<int64_t, RefPtr<IDBObjectStoreMetadata>> objectStores;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698