| Index: third_party/WebKit/public/platform/modules/indexeddb/indexeddb_struct_traits.h
|
| diff --git a/third_party/WebKit/public/platform/modules/indexeddb/indexeddb_struct_traits.h b/third_party/WebKit/public/platform/modules/indexeddb/indexeddb_struct_traits.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..04771e87609dbdbf46871393a78c8700a4806358
|
| --- /dev/null
|
| +++ b/third_party/WebKit/public/platform/modules/indexeddb/indexeddb_struct_traits.h
|
| @@ -0,0 +1,64 @@
|
| +// Copyright 2016 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.
|
| +
|
| +#ifndef INDEXEDDB_STRUCT_TRAITS_H_
|
| +#define INDEXEDDB_STRUCT_TRAITS_H_
|
| +
|
| +#include "third_party/WebKit/public/platform/modules/indexeddb/indexed_db.mojom-blink.h"
|
| +#include "third_party/WebKit/Source/modules/indexeddb/IDBKey.h"
|
| +
|
| +namespace mojo {
|
| +
|
| +template <>
|
| +struct StructTraits<indexed_db::mojom::blink::Key, blink::IDBKey> {
|
| + static indexed_db::mojom::blink::KeyType type(const blink::IDBKey& key)
|
| + {
|
| + switch (idbKey->getType()) {
|
| + case IDBKey::InvalidType:
|
| + case IDBKey::MinType:
|
| + ASSERT_NOT_REACHED();
|
| + return indexed_db::mojom::blink::KeyType::Invalid;
|
| + case IDBKey::ArrayType:
|
| + return indexed_db::mojom::blink::KeyType::Array;
|
| + case IDBKey::BinaryType:
|
| + return indexed_db::mojom::blink::KeyType::Binary;
|
| + case IDBKey::StringType:
|
| + return indexed_db::mojom::blink::KeyType::String;
|
| + case IDBKey::DateType:
|
| + return indexed_db::mojom::blink::KeyType::Date;
|
| + case IDBKey::NumberType:
|
| + return indexed_db::mojom::blink::KeyType::Number;
|
| + }
|
| + ASSERT_NOT_REACHED();
|
| + return indexed_db::mojom::blink::KeyType::Invalid;
|
| + }
|
| + static indexed_db::mojom::blink::KeyData data(const blink::IDBKey& key)
|
| + {
|
| + data = indexed_db::mojom::blink::KeyData::New();
|
| + switch (idbKey->getType()) {
|
| + case IDBKey::InvalidType:
|
| + case IDBKey::MinType:
|
| + ASSERT_NOT_REACHED();
|
| + break;
|
| + case IDBKey::ArrayType: {
|
| + Vector<KeyPtr> data(idbKey->array().size());
|
| + for (size_t i = 0; i < idbKey->array().size(); i++)
|
| + data[i] = createKey(idbKey->array()[i]);
|
| + data->set_array_data(std::move(data));
|
| + } break;
|
| + case IDBKey::BinaryType:
|
| + return indexed_db::mojom::blink::KeyType::Binary;
|
| + case IDBKey::StringType:
|
| + return indexed_db::mojom::blink::KeyType::String;
|
| + case IDBKey::DateType:
|
| + return indexed_db::mojom::blink::KeyType::Date;
|
| + case IDBKey::NumberType:
|
| + return indexed_db::mojom::blink::KeyType::Number;
|
| + }
|
| + return std::move(data);
|
| + }
|
| +};
|
| +}
|
| +
|
| +#endif // INDEXEDDB_STRUCT_TRAITS_H_
|
|
|