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

Unified Diff: extensions/common/event_matcher.cc

Issue 23437015: Initial chrome.mdns API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable test for WinDbg Created 7 years, 3 months 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
« no previous file with comments | « extensions/common/event_matcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/event_matcher.cc
diff --git a/extensions/common/event_matcher.cc b/extensions/common/event_matcher.cc
index ad76c89f4db848d1063900fd9f71a01c3badf9c2..8ae022a00e8845bcb749813c3e973bf847932649 100644
--- a/extensions/common/event_matcher.cc
+++ b/extensions/common/event_matcher.cc
@@ -12,6 +12,8 @@ const char kUrlFiltersKey[] = "url";
namespace extensions {
+const char kEventFilterServiceTypeKey[] = "serviceType";
+
EventMatcher::EventMatcher(scoped_ptr<base::DictionaryValue> filter,
int routing_id)
: filter_(filter.Pass()),
@@ -23,10 +25,13 @@ EventMatcher::~EventMatcher() {
bool EventMatcher::MatchNonURLCriteria(
const EventFilteringInfo& event_info) const {
- if (!event_info.has_instance_id())
- return true;
+ if (event_info.has_instance_id()) {
+ return event_info.instance_id() == GetInstanceID();
+ }
- return event_info.instance_id() == GetInstanceID();
+ const std::string& service_type_filter = GetServiceTypeFilter();
+ return service_type_filter.empty() ||
+ service_type_filter == event_info.service_type();
}
int EventMatcher::GetURLFilterCount() const {
@@ -48,6 +53,12 @@ int EventMatcher::HasURLFilters() const {
return GetURLFilterCount() != 0;
}
+std::string EventMatcher::GetServiceTypeFilter() const {
+ std::string service_type_filter;
+ filter_->GetStringASCII(kEventFilterServiceTypeKey, &service_type_filter);
+ return service_type_filter;
+}
+
int EventMatcher::GetInstanceID() const {
int instance_id = 0;
filter_->GetInteger("instanceId", &instance_id);
« no previous file with comments | « extensions/common/event_matcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698