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

Unified Diff: third_party/WebKit/public/platform/modules/indexeddb/indexeddb_struct_traits.h

Issue 1963293002: Replacing Indexed DB Chromium IPC with Mojo Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some (incomplete) work on struct traits. Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698