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