OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/mdns/mdns_api.h" | 5 #include "chrome/browser/extensions/api/mdns/mdns_api.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 void MDnsAPI::UpdateMDnsListeners(const EventListenerInfo& details) { | 82 void MDnsAPI::UpdateMDnsListeners(const EventListenerInfo& details) { |
83 std::set<std::string> new_service_types; | 83 std::set<std::string> new_service_types; |
84 | 84 |
85 // Check all listeners for service type filers. | 85 // Check all listeners for service type filers. |
86 const EventListenerMap::ListenerList& listeners = | 86 const EventListenerMap::ListenerList& listeners = |
87 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 87 extensions::ExtensionSystem::Get(profile_)->event_router()-> |
88 listeners().GetEventListenersByName(details.event_name); | 88 listeners().GetEventListenersByName(details.event_name); |
89 for (EventListenerMap::ListenerList::const_iterator it = listeners.begin(); | 89 for (EventListenerMap::ListenerList::const_iterator it = listeners.begin(); |
90 it != listeners.end(); ++it) { | 90 it != listeners.end(); ++it) { |
91 base::DictionaryValue* filter = ((*it)->filter.get()); | 91 base::DictionaryValue* filter = ((*it)->filter.get()); |
92 // TODO(imcheng): Figure out what this is loop for, maybe remove it. | |
92 for (base::DictionaryValue::Iterator iter(*filter); | 93 for (base::DictionaryValue::Iterator iter(*filter); |
imcheng
2014/01/15 21:22:38
What this is for and can it be removed?
| |
93 !iter.IsAtEnd(); iter.Advance()) { | 94 !iter.IsAtEnd(); iter.Advance()) { |
94 } | 95 } |
95 | 96 |
96 std::string filter_value; | 97 std::string filter_value; |
97 filter->GetStringASCII(kEventFilterServiceTypeKey, &filter_value); | 98 filter->GetStringASCII(kEventFilterServiceTypeKey, &filter_value); |
98 if (filter_value.empty()) | 99 if (filter_value.empty()) |
99 continue; | 100 continue; |
100 new_service_types.insert(filter_value); | 101 new_service_types.insert(filter_value); |
101 } | 102 } |
102 | 103 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 mdns_service->service_data = (*it).service_data; | 140 mdns_service->service_data = (*it).service_data; |
140 args.push_back(mdns_service); | 141 args.push_back(mdns_service); |
141 } | 142 } |
142 | 143 |
143 scoped_ptr<base::ListValue> results = mdns::OnServiceList::Create(args); | 144 scoped_ptr<base::ListValue> results = mdns::OnServiceList::Create(args); |
144 scoped_ptr<Event> event( | 145 scoped_ptr<Event> event( |
145 new Event(mdns::OnServiceList::kEventName, results.Pass())); | 146 new Event(mdns::OnServiceList::kEventName, results.Pass())); |
146 event->restrict_to_browser_context = profile_; | 147 event->restrict_to_browser_context = profile_; |
147 event->filter_info.SetServiceType(service_type); | 148 event->filter_info.SetServiceType(service_type); |
148 | 149 |
150 VLOG(1) << "Broadcasting OnServiceList event: " << event.get(); | |
151 | |
149 // TODO(justinlin): To avoid having listeners without filters getting all | 152 // TODO(justinlin): To avoid having listeners without filters getting all |
150 // events, modify API to have this event require filters. | 153 // events, modify API to have this event require filters. |
151 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 154 extensions::ExtensionSystem::Get(profile_)->event_router()-> |
152 BroadcastEvent(event.Pass()); | 155 BroadcastEvent(event.Pass()); |
153 } | 156 } |
154 | 157 |
155 } // namespace extensions | 158 } // namespace extensions |
OLD | NEW |