summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/Source/modules/indexeddb/IDBMetadata.cpp
blob: e2b28eae4389b401287565c39ae6c90b2904903c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "modules/indexeddb/IDBMetadata.h"

#include "public/platform/modules/indexeddb/WebIDBMetadata.h"

namespace blink {

IDBDatabaseMetadata::IDBDatabaseMetadata(const WebIDBMetadata& webMetadata)
    : name(webMetadata.name)
    , id(webMetadata.id)
    , version(webMetadata.version)
    , maxObjectStoreId(webMetadata.maxObjectStoreId)
{
    for (size_t i = 0; i < webMetadata.objectStores.size(); ++i) {
        const WebIDBMetadata::ObjectStore webObjectStore = webMetadata.objectStores[i];
        IDBObjectStoreMetadata objectStore(webObjectStore.name, webObjectStore.id, IDBKeyPath(webObjectStore.keyPath), webObjectStore.autoIncrement, webObjectStore.maxIndexId);

        for (size_t j = 0; j < webObjectStore.indexes.size(); ++j) {
            const WebIDBMetadata::Index webIndex = webObjectStore.indexes[j];
            IDBIndexMetadata index(webIndex.name, webIndex.id, IDBKeyPath(webIndex.keyPath), webIndex.unique, webIndex.multiEntry);
            objectStore.indexes.set(index.id, index);
        }
        objectStores.set(objectStore.id, objectStore);
    }
}

} // namespace blink