Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 #include "chrome/browser/media/router/mojo/media_router_struct_traits.h" | |
| 6 | |
| 7 namespace mojo { | |
| 8 | |
| 9 // static | |
| 10 bool StructTraits<media_router::mojom::IssueDataView, media_router::IssueInfo>:: | |
| 11 Read(media_router::mojom::IssueDataView data, | |
| 12 media_router::IssueInfo* out) { | |
| 13 if (!data.ReadTitle(&out->title)) | |
| 14 return false; | |
| 15 | |
| 16 media_router::mojom::Issue::ActionType default_action; | |
|
dcheng
2016/12/12 20:59:56
I think you can avoid the manual calls to EnumTrai
imcheng
2016/12/12 22:40:01
I am not sure how we can set out->default_action w
dcheng
2016/12/13 00:46:38
I think it should Just Work if typemapped; my reco
imcheng
2016/12/13 00:51:45
Thanks -- using ReadX() worked.
| |
| 17 if (!data.ReadDefaultAction(&default_action)) | |
| 18 return false; | |
| 19 | |
| 20 if (!EnumTraits< | |
| 21 media_router::mojom::Issue::ActionType, | |
| 22 media_router::IssueInfo::Action>::FromMojom(default_action, | |
| 23 &out->default_action)) | |
| 24 return false; | |
| 25 | |
| 26 media_router::mojom::Issue::Severity severity; | |
| 27 if (!data.ReadSeverity(&severity)) | |
| 28 return false; | |
| 29 | |
| 30 if (!EnumTraits<media_router::mojom::Issue::Severity, | |
| 31 media_router::IssueInfo::Severity>::FromMojom(severity, | |
| 32 &out->severity)) | |
| 33 return false; | |
| 34 | |
| 35 base::Optional<std::string> message; | |
| 36 if (!data.ReadMessage(&message)) | |
| 37 return false; | |
| 38 | |
| 39 out->message = message.value_or(std::string()); | |
| 40 | |
| 41 base::Optional<std::vector<media_router::mojom::Issue::ActionType>> | |
| 42 secondary_actions; | |
| 43 if (!data.ReadSecondaryActions(&secondary_actions)) | |
| 44 return false; | |
| 45 | |
| 46 if (secondary_actions.has_value()) { | |
| 47 for (const auto action : secondary_actions.value()) { | |
| 48 media_router::IssueInfo::Action converted_action; | |
| 49 if (!EnumTraits< | |
| 50 media_router::mojom::Issue::ActionType, | |
| 51 media_router::IssueInfo::Action>::FromMojom(action, | |
| 52 &converted_action)) | |
| 53 return false; | |
| 54 out->secondary_actions.push_back(converted_action); | |
| 55 } | |
| 56 } | |
| 57 | |
| 58 base::Optional<std::string> route_id; | |
| 59 if (!data.ReadRouteId(&route_id)) | |
| 60 return false; | |
| 61 | |
| 62 out->route_id = route_id.value_or(std::string()); | |
| 63 | |
| 64 out->is_blocking = data.is_blocking(); | |
| 65 out->help_page_id = data.help_page_id(); | |
| 66 | |
| 67 return true; | |
| 68 } | |
| 69 | |
| 70 } // namespace mojo | |
| OLD | NEW |