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

Side by Side Diff: mojo/common/common_custom_types_struct_traits.h

Issue 2379993003: Mojo C++ bindings: make String16 and gfx::Size available in Blink (Closed)
Patch Set: addressed esprehn and rockot's comments Created 4 years, 2 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ 5 #ifndef MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_
6 #define MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ 6 #define MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_
7 7
8 #include "base/strings/utf_string_conversions.h"
8 #include "base/unguessable_token.h" 9 #include "base/unguessable_token.h"
9 #include "base/version.h" 10 #include "base/version.h"
10 #include "mojo/common/common_custom_types.mojom-shared.h" 11 #include "mojo/common/common_custom_types.mojom-shared.h"
11 #include "mojo/common/mojo_common_export.h" 12 #include "mojo/common/mojo_common_export.h"
12 13
13 namespace mojo { 14 namespace mojo {
14 15
15 template <> 16 template <>
17 struct StructTraits<mojo::common::mojom::String16DataView, base::string16> {
18 static std::vector<uint16_t> data(const base::string16& str);
19 static bool Read(mojo::common::mojom::String16DataView data,
20 base::string16* out);
21 };
22
23 template <>
16 struct StructTraits<mojo::common::mojom::VersionDataView, base::Version> { 24 struct StructTraits<mojo::common::mojom::VersionDataView, base::Version> {
17 static bool IsNull(const base::Version& version) { 25 static bool IsNull(const base::Version& version) {
18 return !version.IsValid(); 26 return !version.IsValid();
19 } 27 }
20 static void SetToNull(base::Version* out) { 28 static void SetToNull(base::Version* out) {
21 *out = base::Version(std::string()); 29 *out = base::Version(std::string());
22 } 30 }
23 static const std::vector<uint32_t>& components(const base::Version& version); 31 static const std::vector<uint32_t>& components(const base::Version& version);
24 static bool Read(mojo::common::mojom::VersionDataView data, 32 static bool Read(mojo::common::mojom::VersionDataView data,
25 base::Version* out); 33 base::Version* out);
(...skipping 28 matching lines...) Expand all
54 static bool Read(mojo::common::mojom::TimeDeltaDataView data, 62 static bool Read(mojo::common::mojom::TimeDeltaDataView data,
55 base::TimeDelta* delta) { 63 base::TimeDelta* delta) {
56 *delta = base::TimeDelta::FromMicroseconds(data.microseconds()); 64 *delta = base::TimeDelta::FromMicroseconds(data.microseconds());
57 return true; 65 return true;
58 } 66 }
59 }; 67 };
60 68
61 } // namespace mojo 69 } // namespace mojo
62 70
63 #endif // MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_ 71 #endif // MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698