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 e293d3ac55b2edd84e169144f52439e1c1b129aa..64f69ed109414068582df6f1d771f8d20ba3d23f 100644 |
| --- a/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.h |
| +++ b/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.h |
| @@ -33,20 +33,20 @@ |
| #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) { } |
| +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,59 +56,72 @@ struct IDBIndexMetadata { |
| static const 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) |
| - { |
| - } |
| +struct IDBObjectStoreOwnMetadata { |
| + DISALLOW_NEW(); |
| + |
| + IDBObjectStoreOwnMetadata(); |
| + IDBObjectStoreOwnMetadata(const String& name, int64_t id, const IDBKeyPath&, bool autoIncrement, int64_t maxIndexId); |
| + |
| + IDBObjectStoreOwnMetadata(const IDBObjectStoreOwnMetadata&); |
| + IDBObjectStoreOwnMetadata& operator =(const IDBObjectStoreOwnMetadata&); |
|
jsbell
2016/09/16 18:17:28
nit: we usually write: operator=
pwnall
2016/09/17 01:34:21
Done.
|
| + |
| String name; |
| int64_t id; |
| IDBKeyPath keyPath; |
| bool autoIncrement; |
| int64_t 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; |
| + |
| + IDBObjectStoreOwnMetadata own; |
| static const int64_t InvalidId = -1; |
| - typedef HashMap<int64_t, IDBIndexMetadata> IndexMap; |
| + using IndexMap = HashMap<int64_t, RefPtr<IDBIndexMetadata>>; |
| IndexMap indexes; |
| }; |
| -struct IDBDatabaseMetadata { |
| +struct IDBDatabaseOwnMetadata { |
| + DISALLOW_NEW(); |
| + |
| + IDBDatabaseOwnMetadata(); |
| + IDBDatabaseOwnMetadata(const String& name, int64_t id, int64_t version, int64_t maxObjectStoreId); |
| + |
| + // Copying is used to backup and restore metadata in versionchange transactions. |
| + IDBDatabaseOwnMetadata(const IDBDatabaseOwnMetadata&); |
| + IDBDatabaseOwnMetadata& operator =(const IDBDatabaseOwnMetadata&); |
| + |
| + String name; |
| + int64_t id; |
| + int64_t version; |
| + int64_t maxObjectStoreId; |
| +}; |
| + |
| +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&); |
| - String name; |
| - int64_t id; |
| - int64_t version; |
| - int64_t maxObjectStoreId; |
| - |
| + IDBDatabaseOwnMetadata own; |
| + using ObjectStoreMap = HashMap<int64_t, RefPtr<IDBObjectStoreMetadata>>; |
| ObjectStoreMap objectStores; |
| }; |