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

Side by Side Diff: chrome/browser/local_discovery/service_discovery_client_mdns.cc

Issue 624173002: replace OVERRIDE and FINAL with override and final in chrome/browser/[j-q]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/local_discovery/service_discovery_client_mdns.h" 5 #include "chrome/browser/local_discovery/service_discovery_client_mdns.h"
6 6
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "chrome/common/local_discovery/service_discovery_client_impl.h" 9 #include "chrome/common/local_discovery/service_discovery_client_impl.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 typedef base::Callback<void(bool)> MdnsInitCallback; 106 typedef base::Callback<void(bool)> MdnsInitCallback;
107 107
108 class SocketFactory : public net::MDnsSocketFactory { 108 class SocketFactory : public net::MDnsSocketFactory {
109 public: 109 public:
110 explicit SocketFactory(const net::InterfaceIndexFamilyList& interfaces) 110 explicit SocketFactory(const net::InterfaceIndexFamilyList& interfaces)
111 : interfaces_(interfaces) {} 111 : interfaces_(interfaces) {}
112 112
113 // net::MDnsSocketFactory implementation: 113 // net::MDnsSocketFactory implementation:
114 virtual void CreateSockets( 114 virtual void CreateSockets(
115 ScopedVector<net::DatagramServerSocket>* sockets) OVERRIDE { 115 ScopedVector<net::DatagramServerSocket>* sockets) override {
116 for (size_t i = 0; i < interfaces_.size(); ++i) { 116 for (size_t i = 0; i < interfaces_.size(); ++i) {
117 DCHECK(interfaces_[i].second == net::ADDRESS_FAMILY_IPV4 || 117 DCHECK(interfaces_[i].second == net::ADDRESS_FAMILY_IPV4 ||
118 interfaces_[i].second == net::ADDRESS_FAMILY_IPV6); 118 interfaces_[i].second == net::ADDRESS_FAMILY_IPV6);
119 scoped_ptr<net::DatagramServerSocket> socket( 119 scoped_ptr<net::DatagramServerSocket> socket(
120 CreateAndBindMDnsSocket(interfaces_[i].second, interfaces_[i].first)); 120 CreateAndBindMDnsSocket(interfaces_[i].second, interfaces_[i].first));
121 if (socket) 121 if (socket)
122 sockets->push_back(socket.release()); 122 sockets->push_back(socket.release());
123 } 123 }
124 } 124 }
125 125
(...skipping 16 matching lines...) Expand all
142 typedef ProxyBase<T> Base; 142 typedef ProxyBase<T> Base;
143 143
144 explicit ProxyBase(ServiceDiscoveryClientMdns* client) 144 explicit ProxyBase(ServiceDiscoveryClientMdns* client)
145 : Proxy(client) { 145 : Proxy(client) {
146 } 146 }
147 147
148 virtual ~ProxyBase() { 148 virtual ~ProxyBase() {
149 DeleteOnMdnsThread(implementation_.release()); 149 DeleteOnMdnsThread(implementation_.release());
150 } 150 }
151 151
152 virtual bool IsValid() OVERRIDE { 152 virtual bool IsValid() override {
153 return !!implementation(); 153 return !!implementation();
154 } 154 }
155 155
156 virtual void OnMdnsDestroy() OVERRIDE { 156 virtual void OnMdnsDestroy() override {
157 DeleteOnMdnsThread(implementation_.release()); 157 DeleteOnMdnsThread(implementation_.release());
158 }; 158 };
159 159
160 protected: 160 protected:
161 void set_implementation(scoped_ptr<T> implementation) { 161 void set_implementation(scoped_ptr<T> implementation) {
162 implementation_ = implementation.Pass(); 162 implementation_ = implementation.Pass();
163 } 163 }
164 164
165 T* implementation() const { 165 T* implementation() const {
166 return implementation_.get(); 166 return implementation_.get();
(...skipping 13 matching lines...) Expand all
180 service_type_(service_type), 180 service_type_(service_type),
181 callback_(callback) { 181 callback_(callback) {
182 // It's safe to call |CreateServiceWatcher| on UI thread, because 182 // It's safe to call |CreateServiceWatcher| on UI thread, because
183 // |MDnsClient| is not used there. It's simplify implementation. 183 // |MDnsClient| is not used there. It's simplify implementation.
184 set_implementation(client()->CreateServiceWatcher( 184 set_implementation(client()->CreateServiceWatcher(
185 service_type, 185 service_type,
186 base::Bind(&ServiceWatcherProxy::OnCallback, GetWeakPtr(), callback))); 186 base::Bind(&ServiceWatcherProxy::OnCallback, GetWeakPtr(), callback)));
187 } 187 }
188 188
189 // ServiceWatcher methods. 189 // ServiceWatcher methods.
190 virtual void Start() OVERRIDE { 190 virtual void Start() override {
191 if (implementation()) { 191 if (implementation()) {
192 PostToMdnsThread(base::Bind(&ServiceWatcher::Start, 192 PostToMdnsThread(base::Bind(&ServiceWatcher::Start,
193 base::Unretained(implementation()))); 193 base::Unretained(implementation())));
194 } 194 }
195 } 195 }
196 196
197 virtual void DiscoverNewServices(bool force_update) OVERRIDE { 197 virtual void DiscoverNewServices(bool force_update) override {
198 if (implementation()) { 198 if (implementation()) {
199 PostToMdnsThread(base::Bind(&ServiceWatcher::DiscoverNewServices, 199 PostToMdnsThread(base::Bind(&ServiceWatcher::DiscoverNewServices,
200 base::Unretained(implementation()), 200 base::Unretained(implementation()),
201 force_update)); 201 force_update));
202 } 202 }
203 } 203 }
204 204
205 virtual void SetActivelyRefreshServices( 205 virtual void SetActivelyRefreshServices(
206 bool actively_refresh_services) OVERRIDE { 206 bool actively_refresh_services) override {
207 if (implementation()) { 207 if (implementation()) {
208 PostToMdnsThread(base::Bind(&ServiceWatcher::SetActivelyRefreshServices, 208 PostToMdnsThread(base::Bind(&ServiceWatcher::SetActivelyRefreshServices,
209 base::Unretained(implementation()), 209 base::Unretained(implementation()),
210 actively_refresh_services)); 210 actively_refresh_services));
211 } 211 }
212 } 212 }
213 213
214 virtual std::string GetServiceType() const OVERRIDE { 214 virtual std::string GetServiceType() const override {
215 return service_type_; 215 return service_type_;
216 } 216 }
217 217
218 virtual void OnNewMdnsReady() OVERRIDE { 218 virtual void OnNewMdnsReady() override {
219 ProxyBase<ServiceWatcher>::OnNewMdnsReady(); 219 ProxyBase<ServiceWatcher>::OnNewMdnsReady();
220 if (!implementation()) 220 if (!implementation())
221 callback_.Run(ServiceWatcher::UPDATE_INVALIDATED, ""); 221 callback_.Run(ServiceWatcher::UPDATE_INVALIDATED, "");
222 } 222 }
223 223
224 private: 224 private:
225 static void OnCallback(const WeakPtr& proxy, 225 static void OnCallback(const WeakPtr& proxy,
226 const ServiceWatcher::UpdatedCallback& callback, 226 const ServiceWatcher::UpdatedCallback& callback,
227 UpdateType a1, 227 UpdateType a1,
228 const std::string& a2) { 228 const std::string& a2) {
(...skipping 14 matching lines...) Expand all
243 : ProxyBase(client_mdns), 243 : ProxyBase(client_mdns),
244 service_name_(service_name) { 244 service_name_(service_name) {
245 // It's safe to call |CreateServiceResolver| on UI thread, because 245 // It's safe to call |CreateServiceResolver| on UI thread, because
246 // |MDnsClient| is not used there. It's simplify implementation. 246 // |MDnsClient| is not used there. It's simplify implementation.
247 set_implementation(client()->CreateServiceResolver( 247 set_implementation(client()->CreateServiceResolver(
248 service_name, 248 service_name,
249 base::Bind(&ServiceResolverProxy::OnCallback, GetWeakPtr(), callback))); 249 base::Bind(&ServiceResolverProxy::OnCallback, GetWeakPtr(), callback)));
250 } 250 }
251 251
252 // ServiceResolver methods. 252 // ServiceResolver methods.
253 virtual void StartResolving() OVERRIDE { 253 virtual void StartResolving() override {
254 if (implementation()) { 254 if (implementation()) {
255 PostToMdnsThread(base::Bind(&ServiceResolver::StartResolving, 255 PostToMdnsThread(base::Bind(&ServiceResolver::StartResolving,
256 base::Unretained(implementation()))); 256 base::Unretained(implementation())));
257 } 257 }
258 }; 258 };
259 259
260 virtual std::string GetName() const OVERRIDE { 260 virtual std::string GetName() const override {
261 return service_name_; 261 return service_name_;
262 } 262 }
263 263
264 private: 264 private:
265 static void OnCallback( 265 static void OnCallback(
266 const WeakPtr& proxy, 266 const WeakPtr& proxy,
267 const ServiceResolver::ResolveCompleteCallback& callback, 267 const ServiceResolver::ResolveCompleteCallback& callback,
268 RequestStatus a1, 268 RequestStatus a1,
269 const ServiceDescription& a2) { 269 const ServiceDescription& a2) {
270 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); 270 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 16 matching lines...) Expand all
287 // It's safe to call |CreateLocalDomainResolver| on UI thread, because 287 // It's safe to call |CreateLocalDomainResolver| on UI thread, because
288 // |MDnsClient| is not used there. It's simplify implementation. 288 // |MDnsClient| is not used there. It's simplify implementation.
289 set_implementation(client()->CreateLocalDomainResolver( 289 set_implementation(client()->CreateLocalDomainResolver(
290 domain, 290 domain,
291 address_family, 291 address_family,
292 base::Bind( 292 base::Bind(
293 &LocalDomainResolverProxy::OnCallback, GetWeakPtr(), callback))); 293 &LocalDomainResolverProxy::OnCallback, GetWeakPtr(), callback)));
294 } 294 }
295 295
296 // LocalDomainResolver methods. 296 // LocalDomainResolver methods.
297 virtual void Start() OVERRIDE { 297 virtual void Start() override {
298 if (implementation()) { 298 if (implementation()) {
299 PostToMdnsThread(base::Bind(&LocalDomainResolver::Start, 299 PostToMdnsThread(base::Bind(&LocalDomainResolver::Start,
300 base::Unretained(implementation()))); 300 base::Unretained(implementation())));
301 } 301 }
302 }; 302 };
303 303
304 private: 304 private:
305 static void OnCallback(const WeakPtr& proxy, 305 static void OnCallback(const WeakPtr& proxy,
306 const LocalDomainResolver::IPAddressCallback& callback, 306 const LocalDomainResolver::IPAddressCallback& callback,
307 bool a1, 307 bool a1,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 OnBeforeMdnsDestroy(); 437 OnBeforeMdnsDestroy();
438 // After calling |Proxy::OnMdnsDestroy| all references to client_ and mdns_ 438 // After calling |Proxy::OnMdnsDestroy| all references to client_ and mdns_
439 // should be destroyed. 439 // should be destroyed.
440 if (client_) 440 if (client_)
441 mdns_runner_->DeleteSoon(FROM_HERE, client_.release()); 441 mdns_runner_->DeleteSoon(FROM_HERE, client_.release());
442 if (mdns_) 442 if (mdns_)
443 mdns_runner_->DeleteSoon(FROM_HERE, mdns_.release()); 443 mdns_runner_->DeleteSoon(FROM_HERE, mdns_.release());
444 } 444 }
445 445
446 } // namespace local_discovery 446 } // namespace local_discovery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698