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

Unified Diff: chrome/browser/media/router/mojo/media_router_struct_traits.cc

Issue 2176613003: [Media Router] Clean up issues related code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed dcheng's comments x2 Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/router/mojo/media_router_struct_traits.cc
diff --git a/chrome/browser/media/router/mojo/media_router_struct_traits.cc b/chrome/browser/media/router/mojo/media_router_struct_traits.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6acfd960d45a1623010245a8348dc2aae2d731a1
--- /dev/null
+++ b/chrome/browser/media/router/mojo/media_router_struct_traits.cc
@@ -0,0 +1,70 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/media/router/mojo/media_router_struct_traits.h"
+
+namespace mojo {
+
+// static
+bool StructTraits<media_router::mojom::IssueDataView, media_router::IssueInfo>::
+ Read(media_router::mojom::IssueDataView data,
+ media_router::IssueInfo* out) {
+ if (!data.ReadTitle(&out->title))
+ return false;
+
+ 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.
+ if (!data.ReadDefaultAction(&default_action))
+ return false;
+
+ if (!EnumTraits<
+ media_router::mojom::Issue::ActionType,
+ media_router::IssueInfo::Action>::FromMojom(default_action,
+ &out->default_action))
+ return false;
+
+ media_router::mojom::Issue::Severity severity;
+ if (!data.ReadSeverity(&severity))
+ return false;
+
+ if (!EnumTraits<media_router::mojom::Issue::Severity,
+ media_router::IssueInfo::Severity>::FromMojom(severity,
+ &out->severity))
+ return false;
+
+ base::Optional<std::string> message;
+ if (!data.ReadMessage(&message))
+ return false;
+
+ out->message = message.value_or(std::string());
+
+ base::Optional<std::vector<media_router::mojom::Issue::ActionType>>
+ secondary_actions;
+ if (!data.ReadSecondaryActions(&secondary_actions))
+ return false;
+
+ if (secondary_actions.has_value()) {
+ for (const auto action : secondary_actions.value()) {
+ media_router::IssueInfo::Action converted_action;
+ if (!EnumTraits<
+ media_router::mojom::Issue::ActionType,
+ media_router::IssueInfo::Action>::FromMojom(action,
+ &converted_action))
+ return false;
+ out->secondary_actions.push_back(converted_action);
+ }
+ }
+
+ base::Optional<std::string> route_id;
+ if (!data.ReadRouteId(&route_id))
+ return false;
+
+ out->route_id = route_id.value_or(std::string());
+
+ out->is_blocking = data.is_blocking();
+ out->help_page_id = data.help_page_id();
+
+ return true;
+}
+
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698