| OLD | NEW | 
|---|
| 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 <vector> | 7 #include <vector> | 
| 8 | 8 | 
| 9 #include "base/location.h" | 9 #include "base/location.h" | 
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" | 
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" | 
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" | 
| 13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" | 
| 14 #include "chrome/common/local_discovery/service_discovery_client_impl.h" | 14 #include "chrome/common/local_discovery/service_discovery_client_impl.h" | 
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" | 
|  | 16 #include "net/base/ip_address.h" | 
| 16 #include "net/dns/mdns_client.h" | 17 #include "net/dns/mdns_client.h" | 
| 17 #include "net/udp/datagram_server_socket.h" | 18 #include "net/udp/datagram_server_socket.h" | 
| 18 | 19 | 
| 19 namespace local_discovery { | 20 namespace local_discovery { | 
| 20 | 21 | 
| 21 using content::BrowserThread; | 22 using content::BrowserThread; | 
| 22 | 23 | 
| 23 // Base class for objects returned by ServiceDiscoveryClient implementation. | 24 // Base class for objects returned by ServiceDiscoveryClient implementation. | 
| 24 // Handles interaction of client code on UI thread end net code on mdns thread. | 25 // Handles interaction of client code on UI thread end net code on mdns thread. | 
| 25 class ServiceDiscoveryClientMdns::Proxy { | 26 class ServiceDiscoveryClientMdns::Proxy { | 
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 298     if (implementation()) { | 299     if (implementation()) { | 
| 299       PostToMdnsThread(base::Bind(&LocalDomainResolver::Start, | 300       PostToMdnsThread(base::Bind(&LocalDomainResolver::Start, | 
| 300                                   base::Unretained(implementation()))); | 301                                   base::Unretained(implementation()))); | 
| 301     } | 302     } | 
| 302   }; | 303   }; | 
| 303 | 304 | 
| 304  private: | 305  private: | 
| 305   static void OnCallback(const WeakPtr& proxy, | 306   static void OnCallback(const WeakPtr& proxy, | 
| 306                          const LocalDomainResolver::IPAddressCallback& callback, | 307                          const LocalDomainResolver::IPAddressCallback& callback, | 
| 307                          bool a1, | 308                          bool a1, | 
| 308                          const net::IPAddressNumber& a2, | 309                          const net::IPAddress& a2, | 
| 309                          const net::IPAddressNumber& a3) { | 310                          const net::IPAddress& a3) { | 
| 310     DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 311     DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 
| 311     PostToUIThread(base::Bind(&Base::RunCallback, proxy, | 312     PostToUIThread(base::Bind(&Base::RunCallback, proxy, | 
| 312                               base::Bind(callback, a1, a2, a3))); | 313                               base::Bind(callback, a1, a2, a3))); | 
| 313   } | 314   } | 
| 314 | 315 | 
| 315   DISALLOW_COPY_AND_ASSIGN(LocalDomainResolverProxy); | 316   DISALLOW_COPY_AND_ASSIGN(LocalDomainResolverProxy); | 
| 316 }; | 317 }; | 
| 317 | 318 | 
| 318 }  // namespace | 319 }  // namespace | 
| 319 | 320 | 
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 436   OnBeforeMdnsDestroy(); | 437   OnBeforeMdnsDestroy(); | 
| 437   // After calling |Proxy::OnMdnsDestroy| all references to client_ and mdns_ | 438   // After calling |Proxy::OnMdnsDestroy| all references to client_ and mdns_ | 
| 438   // should be destroyed. | 439   // should be destroyed. | 
| 439   if (client_) | 440   if (client_) | 
| 440     mdns_runner_->DeleteSoon(FROM_HERE, client_.release()); | 441     mdns_runner_->DeleteSoon(FROM_HERE, client_.release()); | 
| 441   if (mdns_) | 442   if (mdns_) | 
| 442     mdns_runner_->DeleteSoon(FROM_HERE, mdns_.release()); | 443     mdns_runner_->DeleteSoon(FROM_HERE, mdns_.release()); | 
| 443 } | 444 } | 
| 444 | 445 | 
| 445 }  // namespace local_discovery | 446 }  // namespace local_discovery | 
| OLD | NEW | 
|---|