| 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 "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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 template<class T> | 85 template<class T> |
| 86 void DeleteOnMdnsThread(T* t) { | 86 void DeleteOnMdnsThread(T* t) { |
| 87 if (!t) | 87 if (!t) |
| 88 return; | 88 return; |
| 89 if (!client_->mdns_runner_->DeleteSoon(FROM_HERE, t)) | 89 if (!client_->mdns_runner_->DeleteSoon(FROM_HERE, t)) |
| 90 delete t; | 90 delete t; |
| 91 } | 91 } |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 scoped_refptr<ServiceDiscoveryClientMdns> client_; | 94 scoped_refptr<ServiceDiscoveryClientMdns> client_; |
| 95 base::WeakPtrFactory<Proxy> weak_ptr_factory_; | |
| 96 // Delayed |mdns_runner_| tasks. | 95 // Delayed |mdns_runner_| tasks. |
| 97 std::vector<base::Closure> delayed_tasks_; | 96 std::vector<base::Closure> delayed_tasks_; |
| 97 base::WeakPtrFactory<Proxy> weak_ptr_factory_; |
| 98 DISALLOW_COPY_AND_ASSIGN(Proxy); | 98 DISALLOW_COPY_AND_ASSIGN(Proxy); |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 namespace { | 101 namespace { |
| 102 | 102 |
| 103 const int kMaxRestartAttempts = 10; | 103 const int kMaxRestartAttempts = 10; |
| 104 const int kRestartDelayOnNetworkChangeSeconds = 3; | 104 const int kRestartDelayOnNetworkChangeSeconds = 3; |
| 105 | 105 |
| 106 typedef base::Callback<void(bool)> MdnsInitCallback; | 106 typedef base::Callback<void(bool)> MdnsInitCallback; |
| 107 | 107 |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 OnBeforeMdnsDestroy(); | 432 OnBeforeMdnsDestroy(); |
| 433 // After calling |Proxy::OnMdnsDestroy| all references to client_ and mdns_ | 433 // After calling |Proxy::OnMdnsDestroy| all references to client_ and mdns_ |
| 434 // should be destroyed. | 434 // should be destroyed. |
| 435 if (client_) | 435 if (client_) |
| 436 mdns_runner_->DeleteSoon(FROM_HERE, client_.release()); | 436 mdns_runner_->DeleteSoon(FROM_HERE, client_.release()); |
| 437 if (mdns_) | 437 if (mdns_) |
| 438 mdns_runner_->DeleteSoon(FROM_HERE, mdns_.release()); | 438 mdns_runner_->DeleteSoon(FROM_HERE, mdns_.release()); |
| 439 } | 439 } |
| 440 | 440 |
| 441 } // namespace local_discovery | 441 } // namespace local_discovery |
| OLD | NEW |