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

Side by Side Diff: mojo/public/cpp/bindings/union_traits.h

Issue 2253293002: Mojo C++ bindings: change the first template parameter of StructTraits and UnionTraits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@91_extra
Patch Set: rebase Created 4 years, 3 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_PUBLIC_CPP_BINDINGS_UNION_TRAITS_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_UNION_TRAITS_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_UNION_TRAITS_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_UNION_TRAITS_H_
7 7
8 namespace mojo { 8 namespace mojo {
9 9
10 // This must be specialized for any type |T| to be serialized/deserialized as 10 // This must be specialized for any type |T| to be serialized/deserialized as
11 // a mojom union of type |MojomType|. 11 // a mojom union. |DataViewType| is the corresponding data view type of the
12 // mojom union. For example, if the mojom union is example.Foo, |DataViewType|
13 // will be example::FooDataView, which can also be referred to by
14 // example::Foo::DataView (in chromium) and example::blink::Foo::DataView (in
15 // blink).
12 // 16 //
13 // Similar to StructTraits, each specialization of UnionTraits implements the 17 // Similar to StructTraits, each specialization of UnionTraits implements the
14 // following methods: 18 // following methods:
15 // 1. Getters for each field in the Mojom type. 19 // 1. Getters for each field in the Mojom type.
16 // 2. Read() method. 20 // 2. Read() method.
17 // 3. [Optional] IsNull() and SetToNull(). 21 // 3. [Optional] IsNull() and SetToNull().
18 // 4. [Optional] SetUpContext() and TearDownContext(). 22 // 4. [Optional] SetUpContext() and TearDownContext().
19 // Please see the documentation of StructTraits for details of these methods. 23 // Please see the documentation of StructTraits for details of these methods.
20 // 24 //
21 // Unlike StructTraits, there is one more method to implement: 25 // Unlike StructTraits, there is one more method to implement:
22 // 5. A static GetTag() method indicating which field is the current active 26 // 5. A static GetTag() method indicating which field is the current active
23 // field for serialization: 27 // field for serialization:
24 // 28 //
25 // static |MojomType|DataView::Tag GetTag(const T& input); 29 // static DataViewType::Tag GetTag(const T& input);
26 // 30 //
27 // During serialization, only the field getter corresponding to this tag 31 // During serialization, only the field getter corresponding to this tag
28 // will be called. 32 // will be called.
29 // 33 //
30 template <typename MojomType, typename T> 34 template <typename DataViewType, typename T>
31 struct UnionTraits; 35 struct UnionTraits;
32 36
33 } // namespace mojo 37 } // namespace mojo
34 38
35 #endif // MOJO_PUBLIC_CPP_BINDINGS_UNION_TRAITS_H_ 39 #endif // MOJO_PUBLIC_CPP_BINDINGS_UNION_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698