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

Unified Diff: components/arc/intent_helper/intent_filter_struct_traits.cc

Issue 2556463003: Use mojo typemaps to simplify arc::IntentFilter::IntentFilter() (reland) (Closed)
Patch Set: Rebased 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: components/arc/intent_helper/intent_filter_struct_traits.cc
diff --git a/components/arc/intent_helper/intent_filter_struct_traits.cc b/components/arc/intent_helper/intent_filter_struct_traits.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2ef34534c7f0f78bae9294916e5cd1b08abe6518
--- /dev/null
+++ b/components/arc/intent_helper/intent_filter_struct_traits.cc
@@ -0,0 +1,55 @@
+// 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 "components/arc/intent_helper/intent_filter_struct_traits.h"
+
+#include "base/strings/string_util.h"
+
+namespace mojo {
+
+bool StructTraits<arc::mojom::IntentFilterDataView, arc::IntentFilter>::
+ Read(arc::mojom::IntentFilterDataView data,
+ arc::IntentFilter* out) {
+ std::vector<arc::IntentFilter::AuthorityEntry> authorities;
+ if (!data.ReadDataAuthorities(&authorities))
+ return false;
+
+ std::vector<arc::IntentFilter::PatternMatcher> paths;
+ if (!data.ReadDataPaths(&paths))
+ return false;
+
+ *out = arc::IntentFilter(std::move(authorities), std::move(paths));
+ return true;
+}
+
+bool StructTraits<arc::mojom::AuthorityEntryDataView,
+ arc::IntentFilter::AuthorityEntry>::
+ Read(arc::mojom::AuthorityEntryDataView data,
+ arc::IntentFilter::AuthorityEntry* out) {
+ std::string host;
+ bool result = data.ReadHost(&host);
+ if (!result)
+ return false;
+
+ *out = arc::IntentFilter::AuthorityEntry(std::move(host), data.port());
+ return true;
+}
+
+bool StructTraits<arc::mojom::PatternMatcherDataView,
+ arc::IntentFilter::PatternMatcher>::
+ Read(arc::mojom::PatternMatcherDataView data,
+ arc::IntentFilter::PatternMatcher* out) {
+ std::string pattern;
+ if (!data.ReadPattern(&pattern))
+ return false;
+
+ arc::mojom::PatternType type;
+ if (!data.ReadType(&type))
+ return false;
+
+ *out = arc::IntentFilter::PatternMatcher(std::move(pattern), type);
+ return true;
+}
+
+} // namespace mojo
« no previous file with comments | « components/arc/intent_helper/intent_filter_struct_traits.h ('k') | components/arc/intent_helper/intent_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698