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

Side by Side Diff: third_party/WebKit/Source/modules/indexeddb/IDBMetadata.cpp

Issue 2314933005: Align IndexedDB metadata rollback on transaction abort to spec. (Closed)
Patch Set: Rebased past the big reformat. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/indexeddb/IDBMetadata.h" 5 #include "modules/indexeddb/IDBMetadata.h"
6 6
7 #include "public/platform/modules/indexeddb/WebIDBMetadata.h" 7 #include "public/platform/modules/indexeddb/WebIDBMetadata.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 constexpr int64_t IDBIndexMetadata::InvalidId; 11 constexpr int64_t IDBIndexMetadata::InvalidId;
12 12
13 constexpr int64_t IDBObjectStoreMetadata::InvalidId; 13 constexpr int64_t IDBObjectStoreMetadata::InvalidId;
14 14
15 IDBIndexMetadata::IDBIndexMetadata() = default;
16
17 IDBIndexMetadata::IDBIndexMetadata(const String& name,
18 int64_t id,
19 const IDBKeyPath& keyPath,
20 bool unique,
21 bool multiEntry)
22 : name(name),
23 id(id),
24 keyPath(keyPath),
25 unique(unique),
26 multiEntry(multiEntry) {}
27
28 IDBObjectStoreMetadata::IDBObjectStoreMetadata() = default;
29
30 IDBObjectStoreMetadata::IDBObjectStoreMetadata(const String& name,
31 int64_t id,
32 const IDBKeyPath& keyPath,
33 bool autoIncrement,
34 int64_t maxIndexId)
35 : name(name),
36 id(id),
37 keyPath(keyPath),
38 autoIncrement(autoIncrement),
39 maxIndexId(maxIndexId) {}
40
41 RefPtr<IDBObjectStoreMetadata> IDBObjectStoreMetadata::createCopy() const {
42 RefPtr<IDBObjectStoreMetadata> copy = adoptRef(
43 new IDBObjectStoreMetadata(name, id, keyPath, autoIncrement, maxIndexId));
44
45 for (const auto& it : indexes) {
46 IDBIndexMetadata* index = it.value.get();
47 RefPtr<IDBIndexMetadata> indexCopy =
48 adoptRef(new IDBIndexMetadata(index->name, index->id, index->keyPath,
49 index->unique, index->multiEntry));
50 copy->indexes.add(it.key, std::move(indexCopy));
51 }
52 return copy;
53 }
54
55 IDBDatabaseMetadata::IDBDatabaseMetadata()
56 : version(IDBDatabaseMetadata::NoVersion) {}
57
58 IDBDatabaseMetadata::IDBDatabaseMetadata(const String& name,
59 int64_t id,
60 int64_t version,
61 int64_t maxObjectStoreId)
62 : name(name),
63 id(id),
64 version(version),
65 maxObjectStoreId(maxObjectStoreId) {}
66
15 IDBDatabaseMetadata::IDBDatabaseMetadata(const WebIDBMetadata& webMetadata) 67 IDBDatabaseMetadata::IDBDatabaseMetadata(const WebIDBMetadata& webMetadata)
16 : name(webMetadata.name), 68 : name(webMetadata.name),
17 id(webMetadata.id), 69 id(webMetadata.id),
18 version(webMetadata.version), 70 version(webMetadata.version),
19 maxObjectStoreId(webMetadata.maxObjectStoreId) { 71 maxObjectStoreId(webMetadata.maxObjectStoreId) {
20 for (size_t i = 0; i < webMetadata.objectStores.size(); ++i) { 72 for (size_t i = 0; i < webMetadata.objectStores.size(); ++i) {
21 const WebIDBMetadata::ObjectStore webObjectStore = 73 const WebIDBMetadata::ObjectStore& webObjectStore =
22 webMetadata.objectStores[i]; 74 webMetadata.objectStores[i];
23 IDBObjectStoreMetadata objectStore(webObjectStore.name, webObjectStore.id, 75 RefPtr<IDBObjectStoreMetadata> objectStore =
24 IDBKeyPath(webObjectStore.keyPath), 76 adoptRef(new IDBObjectStoreMetadata(
25 webObjectStore.autoIncrement, 77 webObjectStore.name, webObjectStore.id,
26 webObjectStore.maxIndexId); 78 IDBKeyPath(webObjectStore.keyPath), webObjectStore.autoIncrement,
79 webObjectStore.maxIndexId));
27 80
28 for (size_t j = 0; j < webObjectStore.indexes.size(); ++j) { 81 for (size_t j = 0; j < webObjectStore.indexes.size(); ++j) {
29 const WebIDBMetadata::Index webIndex = webObjectStore.indexes[j]; 82 const WebIDBMetadata::Index& webIndex = webObjectStore.indexes[j];
30 IDBIndexMetadata index(webIndex.name, webIndex.id, 83 RefPtr<IDBIndexMetadata> index = adoptRef(new IDBIndexMetadata(
31 IDBKeyPath(webIndex.keyPath), webIndex.unique, 84 webIndex.name, webIndex.id, IDBKeyPath(webIndex.keyPath),
32 webIndex.multiEntry); 85 webIndex.unique, webIndex.multiEntry));
33 objectStore.indexes.set(index.id, index); 86 objectStore->indexes.set(webIndex.id, std::move(index));
34 } 87 }
35 objectStores.set(objectStore.id, objectStore); 88 objectStores.set(webObjectStore.id, std::move(objectStore));
36 } 89 }
37 } 90 }
38 91
39 } // namespace blink 92 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698