OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/common/indexed_db/indexed_db_metadata.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBMetadata.h" |
| 9 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 using WebKit::WebIDBDatabaseMetadata; |
| 15 using WebKit::WebIDBIndexMetadata; |
| 16 using WebKit::WebIDBKeyPath; |
| 17 using WebKit::WebIDBObjectStoreMetadata; |
| 18 using WebKit::WebVector; |
| 19 |
| 20 IndexedDBDatabaseMetadata::IndexedDBDatabaseMetadata() |
| 21 { |
| 22 } |
| 23 |
| 24 IndexedDBDatabaseMetadata::IndexedDBDatabaseMetadata( |
| 25 const WebKit::WebIDBDatabaseMetadata metadata) |
| 26 : name_(metadata.name()) |
| 27 , version_(metadata.version()) { |
| 28 WebVector<WebIDBObjectStoreMetadata> object_stores = metadata.objectStores(); |
| 29 for (size_t i = 0; i < object_stores.size(); ++i) |
| 30 object_stores_.push_back(IndexedDBObjectStoreMetadata(object_stores[i])); |
| 31 } |
| 32 |
| 33 IndexedDBDatabaseMetadata::~IndexedDBDatabaseMetadata() |
| 34 { |
| 35 } |
| 36 |
| 37 void IndexedDBDatabaseMetadata::Set( |
| 38 const string16& name, |
| 39 const string16& version, |
| 40 const std::vector<IndexedDBObjectStoreMetadata>& object_stores) { |
| 41 name_ = name; |
| 42 version_ = version; |
| 43 object_stores_ = object_stores; |
| 44 } |
| 45 |
| 46 IndexedDBDatabaseMetadata::operator WebKit::WebIDBDatabaseMetadata() const { |
| 47 return WebKit::WebIDBDatabaseMetadata::create(name_, version_, |
| 48 object_stores_); |
| 49 } |
| 50 |
| 51 IndexedDBObjectStoreMetadata::IndexedDBObjectStoreMetadata() |
| 52 { |
| 53 } |
| 54 |
| 55 IndexedDBObjectStoreMetadata::IndexedDBObjectStoreMetadata( |
| 56 const WebKit::WebIDBObjectStoreMetadata metadata) |
| 57 : name_(metadata.name()) |
| 58 , key_path_(metadata.keyPath()) |
| 59 , auto_increment_(metadata.autoIncrement()) { |
| 60 WebVector<WebIDBIndexMetadata> indexes = metadata.indexes(); |
| 61 for (size_t i = 0; i < indexes.size(); ++i) |
| 62 indexes_.push_back(IndexedDBIndexMetadata(indexes[i])); |
| 63 } |
| 64 |
| 65 IndexedDBObjectStoreMetadata::~IndexedDBObjectStoreMetadata() |
| 66 { |
| 67 } |
| 68 |
| 69 void IndexedDBObjectStoreMetadata::Set( |
| 70 const string16& name, |
| 71 const IndexedDBKeyPath& key_path, |
| 72 bool auto_increment, |
| 73 const std::vector<IndexedDBIndexMetadata>& indexes) { |
| 74 name_ = name; |
| 75 key_path_ = key_path; |
| 76 auto_increment_ = auto_increment; |
| 77 indexes_ = indexes; |
| 78 } |
| 79 |
| 80 IndexedDBObjectStoreMetadata::operator |
| 81 WebKit::WebIDBObjectStoreMetadata() const { |
| 82 return WebKit::WebIDBObjectStoreMetadata::create(name_, key_path_, |
| 83 auto_increment_, indexes_); |
| 84 } |
| 85 |
| 86 IndexedDBIndexMetadata::IndexedDBIndexMetadata() |
| 87 { |
| 88 } |
| 89 |
| 90 IndexedDBIndexMetadata::IndexedDBIndexMetadata( |
| 91 const WebKit::WebIDBIndexMetadata metadata) |
| 92 : name_(metadata.name()) |
| 93 , key_path_(metadata.keyPath()) |
| 94 , unique_(metadata.unique()) |
| 95 , multi_entry_(metadata.multiEntry()) { |
| 96 } |
| 97 |
| 98 IndexedDBIndexMetadata::~IndexedDBIndexMetadata() |
| 99 { |
| 100 } |
| 101 |
| 102 void IndexedDBIndexMetadata::Set( |
| 103 const string16& name, |
| 104 const IndexedDBKeyPath& key_path, |
| 105 bool unique, |
| 106 bool multi_entry) { |
| 107 name_ = name; |
| 108 key_path_ = key_path; |
| 109 unique_ = unique; |
| 110 multi_entry_ = multi_entry; |
| 111 } |
| 112 |
| 113 IndexedDBIndexMetadata::operator WebKit::WebIDBIndexMetadata() const { |
| 114 return WebKit::WebIDBIndexMetadata::create(name_, key_path_, unique_, |
| 115 multi_entry_); |
| 116 } |
| 117 |
| 118 } // namespace content |
OLD | NEW |