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

Unified Diff: components/arc/intent_helper/intent_filter_unittest.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_unittest.cc
diff --git a/components/arc/intent_helper/intent_filter_unittest.cc b/components/arc/intent_helper/intent_filter_unittest.cc
index 1e0113f1a8e97fef941585fda871d86ceaa25b4d..1205c2e529ccc0f812673ad478a5d0ecd65c8da9 100644
--- a/components/arc/intent_helper/intent_filter_unittest.cc
+++ b/components/arc/intent_helper/intent_filter_unittest.cc
@@ -20,41 +20,32 @@ namespace {
class IntentFilterBuilder {
public:
- IntentFilterBuilder():
- filter_spec_(mojom::IntentFilter::New()) {
- }
+ IntentFilterBuilder() = default;
IntentFilterBuilder& authority(const std::string& host) {
return authority(host, -1);
}
IntentFilterBuilder& authority(const std::string& host, int port) {
- mojom::AuthorityEntryPtr ae = mojom::AuthorityEntry::New();
- ae->host = host;
- ae->port = port;
- if (!filter_spec_->data_authorities.has_value())
- filter_spec_->data_authorities = std::vector<mojom::AuthorityEntryPtr>();
- filter_spec_->data_authorities->push_back(std::move(ae));
+ authorities_.emplace_back(host, port);
return *this;
}
IntentFilterBuilder& path(const std::string& path,
const mojom::PatternType& type) {
- mojom::PatternMatcherPtr p = mojom::PatternMatcher::New();
- p->pattern = path;
- p->type = type;
- if (!filter_spec_->data_paths.has_value())
- filter_spec_->data_paths = std::vector<mojom::PatternMatcherPtr>();
- filter_spec_->data_paths->push_back(std::move(p));
+ paths_.emplace_back(path, type);
return *this;
}
- operator IntentFilter() const {
- return std::move(IntentFilter(filter_spec_));
+ operator IntentFilter() {
+ return IntentFilter(std::move(authorities_), std::move(paths_));
}
private:
- mojom::IntentFilterPtr filter_spec_;
+ std::vector<IntentFilter::AuthorityEntry> authorities_;
+ std::vector<IntentFilter::PatternMatcher> paths_;
+
+ DISALLOW_COPY_AND_ASSIGN(IntentFilterBuilder);
};
} // namespace
« no previous file with comments | « components/arc/intent_helper/intent_filter_struct_traits.cc ('k') | components/arc/intent_helper/local_activity_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698