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 "base/profiler/scoped_profile.h" | |
11 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
12 #include "chrome/common/extensions/api/mdns.h" | 11 #include "chrome/common/extensions/api/mdns.h" |
13 | 12 |
14 namespace extensions { | 13 namespace extensions { |
15 | 14 |
16 namespace mdns = api::mdns; | 15 namespace mdns = api::mdns; |
17 | 16 |
18 namespace { | 17 namespace { |
19 | 18 |
20 // Whitelisted mDNS service types. | 19 // Whitelisted mDNS service types. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 DnsSdRegistry* MDnsAPI::dns_sd_registry() { | 62 DnsSdRegistry* MDnsAPI::dns_sd_registry() { |
64 DCHECK(thread_checker_.CalledOnValidThread()); | 63 DCHECK(thread_checker_.CalledOnValidThread()); |
65 if (!dns_sd_registry_.get()) { | 64 if (!dns_sd_registry_.get()) { |
66 dns_sd_registry_.reset(new extensions::DnsSdRegistry()); | 65 dns_sd_registry_.reset(new extensions::DnsSdRegistry()); |
67 dns_sd_registry_->AddObserver(this); | 66 dns_sd_registry_->AddObserver(this); |
68 } | 67 } |
69 return dns_sd_registry_.get(); | 68 return dns_sd_registry_.get(); |
70 } | 69 } |
71 | 70 |
72 void MDnsAPI::OnListenerAdded(const EventListenerInfo& details) { | 71 void MDnsAPI::OnListenerAdded(const EventListenerInfo& details) { |
73 // TODO(vadimt): Remove ScopedProfile below once crbug.com/417106 is fixed. | |
74 tracked_objects::ScopedProfile tracking_profile( | |
75 FROM_HERE_WITH_EXPLICIT_FUNCTION("MDnsAPI::OnListenerAdded")); | |
76 | |
77 DCHECK(thread_checker_.CalledOnValidThread()); | 72 DCHECK(thread_checker_.CalledOnValidThread()); |
78 UpdateMDnsListeners(details); | 73 UpdateMDnsListeners(details); |
79 } | 74 } |
80 | 75 |
81 void MDnsAPI::OnListenerRemoved(const EventListenerInfo& details) { | 76 void MDnsAPI::OnListenerRemoved(const EventListenerInfo& details) { |
82 DCHECK(thread_checker_.CalledOnValidThread()); | 77 DCHECK(thread_checker_.CalledOnValidThread()); |
83 UpdateMDnsListeners(details); | 78 UpdateMDnsListeners(details); |
84 } | 79 } |
85 | 80 |
86 void MDnsAPI::UpdateMDnsListeners(const EventListenerInfo& details) { | 81 void MDnsAPI::UpdateMDnsListeners(const EventListenerInfo& details) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 event->filter_info.SetServiceType(service_type); | 144 event->filter_info.SetServiceType(service_type); |
150 | 145 |
151 VLOG(1) << "Broadcasting OnServiceList event: " << event.get(); | 146 VLOG(1) << "Broadcasting OnServiceList event: " << event.get(); |
152 | 147 |
153 // TODO(justinlin): To avoid having listeners without filters getting all | 148 // TODO(justinlin): To avoid having listeners without filters getting all |
154 // events, modify API to have this event require filters. | 149 // events, modify API to have this event require filters. |
155 extensions::EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); | 150 extensions::EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); |
156 } | 151 } |
157 | 152 |
158 } // namespace extensions | 153 } // namespace extensions |
OLD | NEW |