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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 #ifndef INDEXEDDB_STRUCT_TRAITS_H_
6 #define INDEXEDDB_STRUCT_TRAITS_H_
7
8 #include "third_party/WebKit/public/platform/modules/indexeddb/indexed_db.mojom- blink.h"
9 #include "third_party/WebKit/Source/modules/indexeddb/IDBKey.h"
10
11 namespace mojo {
12
13 template <>
14 struct StructTraits<indexed_db::mojom::blink::Key, blink::IDBKey> {
15 static indexed_db::mojom::blink::KeyType type(const blink::IDBKey& key)
16 {
17 switch (idbKey->getType()) {
18 case IDBKey::InvalidType:
19 case IDBKey::MinType:
20 ASSERT_NOT_REACHED();
21 return indexed_db::mojom::blink::KeyType::Invalid;
22 case IDBKey::ArrayType:
23 return indexed_db::mojom::blink::KeyType::Array;
24 case IDBKey::BinaryType:
25 return indexed_db::mojom::blink::KeyType::Binary;
26 case IDBKey::StringType:
27 return indexed_db::mojom::blink::KeyType::String;
28 case IDBKey::DateType:
29 return indexed_db::mojom::blink::KeyType::Date;
30 case IDBKey::NumberType:
31 return indexed_db::mojom::blink::KeyType::Number;
32 }
33 ASSERT_NOT_REACHED();
34 return indexed_db::mojom::blink::KeyType::Invalid;
35 }
36 static indexed_db::mojom::blink::KeyData data(const blink::IDBKey& key)
37 {
38 data = indexed_db::mojom::blink::KeyData::New();
39 switch (idbKey->getType()) {
40 case IDBKey::InvalidType:
41 case IDBKey::MinType:
42 ASSERT_NOT_REACHED();
43 break;
44 case IDBKey::ArrayType: {
45 Vector<KeyPtr> data(idbKey->array().size());
46 for (size_t i = 0; i < idbKey->array().size(); i++)
47 data[i] = createKey(idbKey->array()[i]);
48 data->set_array_data(std::move(data));
49 } break;
50 case IDBKey::BinaryType:
51 return indexed_db::mojom::blink::KeyType::Binary;
52 case IDBKey::StringType:
53 return indexed_db::mojom::blink::KeyType::String;
54 case IDBKey::DateType:
55 return indexed_db::mojom::blink::KeyType::Date;
56 case IDBKey::NumberType:
57 return indexed_db::mojom::blink::KeyType::Number;
58 }
59 return std::move(data);
60 }
61 };
62 }
63
64 #endif // INDEXEDDB_STRUCT_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698