Chromium Code Reviews| 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..6dfd946e8930f05843b78c155b7a981fc292951c 100644 |
| --- a/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.h |
| +++ b/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.h |
| @@ -33,75 +33,79 @@ |
| #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. |
|
cmumford
2016/10/05 21:15:27
typo
pwnall
2016/10/05 23:15:45
Done.
Thank you!
|
| +// 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: |
| + using IndexMap = HashMap<int64_t, RefPtr<IDBIndexMetadata>>; |
| 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 store's metadata, which includes copies |
| + // of the metadata for all indexes. |
| + 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; |
| }; |
| -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; |
| + public: |
|
cmumford
2016/10/05 21:15:26
public not needed - in a struct.
pwnall
2016/10/05 23:15:45
Done.
|
| + using ObjectStoreMap = HashMap<int64_t, RefPtr<IDBObjectStoreMetadata>>; |
|
cmumford
2016/10/05 21:15:26
My preference is to not declare ObjectStoreMap. Ju
pwnall
2016/10/05 23:15:45
Done.
Also removed IDBObjectStoreMetadata::IndexMa
|
| - IDBDatabaseMetadata() : version(NoVersion) {} |
| + // FIXME: These can probably be collapsed into 0. |
| + enum { NoVersion = -1, DefaultVersion = 0 }; |
| + 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&); |
| @@ -109,7 +113,6 @@ struct IDBDatabaseMetadata { |
| int64_t id; |
| int64_t version; |
| int64_t maxObjectStoreId; |
| - |
| ObjectStoreMap objectStores; |
| }; |