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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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
(...skipping 15 matching lines...) Expand all
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #ifndef IDBMetadata_h 29 #ifndef IDBMetadata_h
30 #define IDBMetadata_h 30 #define IDBMetadata_h
31 31
32 #include "modules/indexeddb/IDBKeyPath.h" 32 #include "modules/indexeddb/IDBKeyPath.h"
33 #include "public/platform/modules/indexeddb/WebIDBMetadata.h" 33 #include "public/platform/modules/indexeddb/WebIDBMetadata.h"
34 #include "wtf/Allocator.h" 34 #include "wtf/Allocator.h"
35 #include "wtf/HashMap.h" 35 #include "wtf/HashMap.h"
36 #include "wtf/RefCounted.h"
37 #include "wtf/RefPtr.h"
36 #include "wtf/text/StringHash.h" 38 #include "wtf/text/StringHash.h"
37 #include "wtf/text/WTFString.h" 39 #include "wtf/text/WTFString.h"
38 40
39 namespace blink { 41 namespace blink {
40 42
41 struct IDBIndexMetadata { 43 class IDBIndexMetadata : public RefCounted<IDBIndexMetadata> {
42 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 44 USING_FAST_MALLOC(IDBIndexMetadata);
43 IDBIndexMetadata() { } 45
44 IDBIndexMetadata(const String& name, int64_t id, const IDBKeyPath& keyPath, bool unique, bool multiEntry) 46 public:
45 : name(name) 47 IDBIndexMetadata();
46 , id(id) 48 IDBIndexMetadata(const String& name, int64_t id, const IDBKeyPath&, bool uni que, bool multiEntry);
47 , keyPath(keyPath) 49
48 , unique(unique)
49 , multiEntry(multiEntry) { }
50 String name; 50 String name;
51 int64_t id; 51 int64_t id;
52 IDBKeyPath keyPath; 52 IDBKeyPath keyPath;
53 bool unique; 53 bool unique;
54 bool multiEntry; 54 bool multiEntry;
55 55
56 static const int64_t InvalidId = -1; 56 static const int64_t InvalidId = -1;
57 }; 57 };
58 58
59 struct IDBObjectStoreMetadata { 59 struct IDBObjectStoreOwnMetadata {
60 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 60 DISALLOW_NEW();
61 IDBObjectStoreMetadata() { } 61
62 IDBObjectStoreMetadata(const String& name, int64_t id, const IDBKeyPath& key Path, bool autoIncrement, int64_t maxIndexId) 62 IDBObjectStoreOwnMetadata();
63 : name(name) 63 IDBObjectStoreOwnMetadata(const String& name, int64_t id, const IDBKeyPath&, bool autoIncrement, int64_t maxIndexId);
64 , id(id) 64
65 , keyPath(keyPath) 65 IDBObjectStoreOwnMetadata(const IDBObjectStoreOwnMetadata&);
66 , autoIncrement(autoIncrement) 66 IDBObjectStoreOwnMetadata& operator =(const IDBObjectStoreOwnMetadata&);
jsbell 2016/09/16 18:17:28 nit: we usually write: operator=
pwnall 2016/09/17 01:34:21 Done.
67 , maxIndexId(maxIndexId) 67
68 {
69 }
70 String name; 68 String name;
71 int64_t id; 69 int64_t id;
72 IDBKeyPath keyPath; 70 IDBKeyPath keyPath;
73 bool autoIncrement; 71 bool autoIncrement;
74 int64_t maxIndexId; 72 int64_t maxIndexId;
73 };
75 74
75 class IDBObjectStoreMetadata : public RefCounted<IDBObjectStoreMetadata> {
76 USING_FAST_MALLOC(IDBObjectStoreMetadata);
77
78 public:
79 IDBObjectStoreMetadata();
80 IDBObjectStoreMetadata(const String& name, int64_t id, const IDBKeyPath&, bo ol autoIncrement, int64_t maxIndexId);
81
82 // Creates a deep copy of the object metadata, which includes copies of inde x metadata items.
83 RefPtr<IDBObjectStoreMetadata> createCopy() const;
84
85 IDBObjectStoreOwnMetadata own;
76 static const int64_t InvalidId = -1; 86 static const int64_t InvalidId = -1;
77 87
78 typedef HashMap<int64_t, IDBIndexMetadata> IndexMap; 88 using IndexMap = HashMap<int64_t, RefPtr<IDBIndexMetadata>>;
79 IndexMap indexes; 89 IndexMap indexes;
80 }; 90 };
81 91
82 struct IDBDatabaseMetadata { 92 struct IDBDatabaseOwnMetadata {
83 DISALLOW_NEW(); 93 DISALLOW_NEW();
94
95 IDBDatabaseOwnMetadata();
96 IDBDatabaseOwnMetadata(const String& name, int64_t id, int64_t version, int6 4_t maxObjectStoreId);
97
98 // Copying is used to backup and restore metadata in versionchange transacti ons.
99 IDBDatabaseOwnMetadata(const IDBDatabaseOwnMetadata&);
100 IDBDatabaseOwnMetadata& operator =(const IDBDatabaseOwnMetadata&);
101
102 String name;
103 int64_t id;
104 int64_t version;
105 int64_t maxObjectStoreId;
106 };
107
108 struct MODULES_EXPORT IDBDatabaseMetadata {
109 DISALLOW_NEW();
110
111 public:
84 // FIXME: These can probably be collapsed into 0. 112 // FIXME: These can probably be collapsed into 0.
85 enum { 113 enum {
86 NoVersion = -1, 114 NoVersion = -1,
87 DefaultVersion = 0 115 DefaultVersion = 0
88 }; 116 };
89 117
90 typedef HashMap<int64_t, IDBObjectStoreMetadata> ObjectStoreMap; 118 IDBDatabaseMetadata();
91 119 IDBDatabaseMetadata(const String& name, int64_t id, int64_t version, int64_t maxObjectStoreId);
92 IDBDatabaseMetadata()
93 : version(NoVersion)
94 {
95 }
96
97 IDBDatabaseMetadata(const String& name, int64_t id, int64_t version, int64_t maxObjectStoreId)
98 : name(name)
99 , id(id)
100 , version(version)
101 , maxObjectStoreId(maxObjectStoreId)
102 {
103 }
104 120
105 explicit IDBDatabaseMetadata(const WebIDBMetadata&); 121 explicit IDBDatabaseMetadata(const WebIDBMetadata&);
106 122
107 String name; 123 IDBDatabaseOwnMetadata own;
108 int64_t id; 124 using ObjectStoreMap = HashMap<int64_t, RefPtr<IDBObjectStoreMetadata>>;
109 int64_t version;
110 int64_t maxObjectStoreId;
111
112 ObjectStoreMap objectStores; 125 ObjectStoreMap objectStores;
113 }; 126 };
114 127
115 } // namespace blink 128 } // namespace blink
116 129
117 #endif // IDBMetadata_h 130 #endif // IDBMetadata_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698