| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 138 |
| 139 template<class T> | 139 template<class T> |
| 140 class ProxyBase : public ServiceDiscoveryClientMdns::Proxy, public T { | 140 class ProxyBase : public ServiceDiscoveryClientMdns::Proxy, public T { |
| 141 public: | 141 public: |
| 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 ~ProxyBase() override { |
| 149 DeleteOnMdnsThread(implementation_.release()); | 149 DeleteOnMdnsThread(implementation_.release()); |
| 150 } | 150 } |
| 151 | 151 |
| 152 virtual bool IsValid() override { | 152 bool IsValid() override { |
| 153 return !!implementation(); | 153 return !!implementation(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 virtual void OnMdnsDestroy() override { | 156 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 265 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 |