OLD | NEW |
---|---|
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 #include "chrome/browser/media/router/mojo/media_router_struct_traits.h" | 5 #include "chrome/browser/media/router/mojo/media_router_struct_traits.h" |
6 | 6 |
7 #include "chrome/browser/media/router/media_source.h" | |
8 | |
7 namespace mojo { | 9 namespace mojo { |
8 | 10 |
9 // static | 11 // static |
10 bool StructTraits<media_router::mojom::IssueDataView, media_router::IssueInfo>:: | 12 bool StructTraits<media_router::mojom::IssueDataView, media_router::IssueInfo>:: |
11 Read(media_router::mojom::IssueDataView data, | 13 Read(media_router::mojom::IssueDataView data, |
12 media_router::IssueInfo* out) { | 14 media_router::IssueInfo* out) { |
13 if (!data.ReadTitle(&out->title)) | 15 if (!data.ReadTitle(&out->title)) |
14 return false; | 16 return false; |
15 | 17 |
16 if (!data.ReadDefaultAction(&out->default_action)) | 18 if (!data.ReadDefaultAction(&out->default_action)) |
(...skipping 16 matching lines...) Expand all Loading... | |
33 return false; | 35 return false; |
34 | 36 |
35 out->route_id = route_id.value_or(std::string()); | 37 out->route_id = route_id.value_or(std::string()); |
36 | 38 |
37 out->is_blocking = data.is_blocking(); | 39 out->is_blocking = data.is_blocking(); |
38 out->help_page_id = data.help_page_id(); | 40 out->help_page_id = data.help_page_id(); |
39 | 41 |
40 return true; | 42 return true; |
41 } | 43 } |
42 | 44 |
45 // static | |
46 bool StructTraits< | |
47 media_router::mojom::MediaSinkDataView, | |
48 media_router::MediaSink>::Read(media_router::mojom::MediaSinkDataView data, | |
49 media_router::MediaSink* out) { | |
50 media_router::MediaSink::Id id; | |
51 if (!data.ReadSinkId(&id)) | |
52 return false; | |
53 | |
54 out->set_sink_id(id); | |
55 | |
56 std::string name; | |
57 if (!data.ReadName(&name)) | |
58 return false; | |
59 | |
60 out->set_name(name); | |
61 | |
62 base::Optional<std::string> description; | |
63 if (!data.ReadDescription(&description)) | |
64 return false; | |
65 | |
66 out->set_description(description.value_or(std::string())); | |
67 | |
68 base::Optional<std::string> domain; | |
69 if (!data.ReadDomain(&domain)) | |
70 return false; | |
71 | |
72 if (domain) | |
dcheng
2017/02/01 22:51:08
Why do we null check here but not for |description
imcheng
2017/02/02 21:20:37
Done.
| |
73 out->set_domain(*domain); | |
74 | |
75 media_router::MediaSink::IconType icon_type; | |
76 if (!data.ReadIconType(&icon_type)) | |
77 return false; | |
78 | |
79 out->set_icon_type(icon_type); | |
80 | |
81 return true; | |
82 } | |
83 | |
84 // static | |
85 bool StructTraits<media_router::mojom::MediaRouteDataView, | |
86 media_router::MediaRoute>:: | |
87 Read(media_router::mojom::MediaRouteDataView data, | |
88 media_router::MediaRoute* out) { | |
89 media_router::MediaRoute::Id media_route_id; | |
90 if (!data.ReadMediaRouteId(&media_route_id)) | |
91 return false; | |
92 | |
93 out->set_media_route_id(media_route_id); | |
94 | |
95 base::Optional<media_router::MediaSource::Id> media_source_id; | |
96 if (!data.ReadMediaSource(&media_source_id)) | |
97 return false; | |
98 | |
99 if (media_source_id) | |
100 out->set_media_source(media_router::MediaSource(*media_source_id)); | |
101 | |
102 media_router::MediaSink::Id media_sink_id; | |
103 if (!data.ReadMediaSinkId(&media_sink_id)) | |
104 return false; | |
105 | |
106 out->set_media_sink_id(media_sink_id); | |
107 | |
108 std::string description; | |
109 if (!data.ReadDescription(&description)) | |
110 return false; | |
111 | |
112 out->set_description(description); | |
113 | |
114 base::Optional<std::string> custom_controller_path; | |
115 if (!data.ReadCustomControllerPath(&custom_controller_path)) | |
116 return false; | |
117 | |
118 if (custom_controller_path) | |
dcheng
2017/02/01 22:51:08
Ditto: why do we only sometimes check this?
imcheng
2017/02/02 21:20:37
Done. Converted all to do null check.
| |
119 out->set_custom_controller_path(*custom_controller_path); | |
120 | |
121 out->set_local(data.is_local()); | |
122 out->set_for_display(data.for_display()); | |
123 out->set_incognito(data.is_incognito()); | |
124 out->set_offscreen_presentation(data.is_offscreen_presentation()); | |
125 | |
126 return true; | |
127 } | |
128 | |
43 } // namespace mojo | 129 } // namespace mojo |
OLD | NEW |