OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_host_client.h" | 5 #include "chrome/browser/local_discovery/service_discovery_host_client.h" |
6 | 6 |
7 #include "chrome/common/local_discovery/local_discovery_messages.h" | 7 #include "chrome/common/local_discovery/local_discovery_messages.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "content/public/browser/utility_process_host.h" | 9 #include "content/public/browser/utility_process_host.h" |
10 #include "net/dns/mdns_client.h" | 10 #include "net/dns/mdns_client.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 started_(false) { | 62 started_(false) { |
63 } | 63 } |
64 | 64 |
65 virtual ~ServiceWatcherProxy() { | 65 virtual ~ServiceWatcherProxy() { |
66 DVLOG(1) << "~ServiceWatcherProxy with id " << id_; | 66 DVLOG(1) << "~ServiceWatcherProxy with id " << id_; |
67 host_->UnregisterWatcherCallback(id_); | 67 host_->UnregisterWatcherCallback(id_); |
68 if (started_) | 68 if (started_) |
69 host_->Send(new LocalDiscoveryMsg_DestroyWatcher(id_)); | 69 host_->Send(new LocalDiscoveryMsg_DestroyWatcher(id_)); |
70 } | 70 } |
71 | 71 |
72 virtual void Start() OVERRIDE { | 72 virtual void Start() override { |
73 DVLOG(1) << "ServiceWatcher::Start with id " << id_; | 73 DVLOG(1) << "ServiceWatcher::Start with id " << id_; |
74 DCHECK(!started_); | 74 DCHECK(!started_); |
75 host_->Send(new LocalDiscoveryMsg_StartWatcher(id_, service_type_)); | 75 host_->Send(new LocalDiscoveryMsg_StartWatcher(id_, service_type_)); |
76 started_ = true; | 76 started_ = true; |
77 } | 77 } |
78 | 78 |
79 virtual void DiscoverNewServices(bool force_update) OVERRIDE { | 79 virtual void DiscoverNewServices(bool force_update) override { |
80 DVLOG(1) << "ServiceWatcher::DiscoverNewServices with id " << id_; | 80 DVLOG(1) << "ServiceWatcher::DiscoverNewServices with id " << id_; |
81 DCHECK(started_); | 81 DCHECK(started_); |
82 host_->Send(new LocalDiscoveryMsg_DiscoverServices(id_, force_update)); | 82 host_->Send(new LocalDiscoveryMsg_DiscoverServices(id_, force_update)); |
83 } | 83 } |
84 | 84 |
85 virtual void SetActivelyRefreshServices( | 85 virtual void SetActivelyRefreshServices( |
86 bool actively_refresh_services) OVERRIDE { | 86 bool actively_refresh_services) override { |
87 DVLOG(1) << "ServiceWatcher::SetActivelyRefreshServices with id " << id_; | 87 DVLOG(1) << "ServiceWatcher::SetActivelyRefreshServices with id " << id_; |
88 DCHECK(started_); | 88 DCHECK(started_); |
89 host_->Send(new LocalDiscoveryMsg_SetActivelyRefreshServices( | 89 host_->Send(new LocalDiscoveryMsg_SetActivelyRefreshServices( |
90 id_, actively_refresh_services)); | 90 id_, actively_refresh_services)); |
91 } | 91 } |
92 | 92 |
93 virtual std::string GetServiceType() const OVERRIDE { | 93 virtual std::string GetServiceType() const override { |
94 return service_type_; | 94 return service_type_; |
95 } | 95 } |
96 | 96 |
97 private: | 97 private: |
98 scoped_refptr<ServiceDiscoveryHostClient> host_; | 98 scoped_refptr<ServiceDiscoveryHostClient> host_; |
99 const std::string service_type_; | 99 const std::string service_type_; |
100 const uint64 id_; | 100 const uint64 id_; |
101 bool started_; | 101 bool started_; |
102 }; | 102 }; |
103 | 103 |
104 class ServiceDiscoveryHostClient::ServiceResolverProxy | 104 class ServiceDiscoveryHostClient::ServiceResolverProxy |
105 : public ServiceResolver { | 105 : public ServiceResolver { |
106 public: | 106 public: |
107 ServiceResolverProxy(ServiceDiscoveryHostClient* host, | 107 ServiceResolverProxy(ServiceDiscoveryHostClient* host, |
108 const std::string& service_name, | 108 const std::string& service_name, |
109 const ServiceResolver::ResolveCompleteCallback& callback) | 109 const ServiceResolver::ResolveCompleteCallback& callback) |
110 : host_(host), | 110 : host_(host), |
111 service_name_(service_name), | 111 service_name_(service_name), |
112 id_(host->RegisterResolverCallback(callback)), | 112 id_(host->RegisterResolverCallback(callback)), |
113 started_(false) { | 113 started_(false) { |
114 } | 114 } |
115 | 115 |
116 virtual ~ServiceResolverProxy() { | 116 virtual ~ServiceResolverProxy() { |
117 DVLOG(1) << "~ServiceResolverProxy with id " << id_; | 117 DVLOG(1) << "~ServiceResolverProxy with id " << id_; |
118 host_->UnregisterResolverCallback(id_); | 118 host_->UnregisterResolverCallback(id_); |
119 if (started_) | 119 if (started_) |
120 host_->Send(new LocalDiscoveryMsg_DestroyResolver(id_)); | 120 host_->Send(new LocalDiscoveryMsg_DestroyResolver(id_)); |
121 } | 121 } |
122 | 122 |
123 virtual void StartResolving() OVERRIDE { | 123 virtual void StartResolving() override { |
124 DVLOG(1) << "ServiceResolverProxy::StartResolving with id " << id_; | 124 DVLOG(1) << "ServiceResolverProxy::StartResolving with id " << id_; |
125 DCHECK(!started_); | 125 DCHECK(!started_); |
126 host_->Send(new LocalDiscoveryMsg_ResolveService(id_, service_name_)); | 126 host_->Send(new LocalDiscoveryMsg_ResolveService(id_, service_name_)); |
127 started_ = true; | 127 started_ = true; |
128 } | 128 } |
129 | 129 |
130 virtual std::string GetName() const OVERRIDE { | 130 virtual std::string GetName() const override { |
131 return service_name_; | 131 return service_name_; |
132 } | 132 } |
133 | 133 |
134 private: | 134 private: |
135 scoped_refptr<ServiceDiscoveryHostClient> host_; | 135 scoped_refptr<ServiceDiscoveryHostClient> host_; |
136 const std::string service_name_; | 136 const std::string service_name_; |
137 const uint64 id_; | 137 const uint64 id_; |
138 bool started_; | 138 bool started_; |
139 }; | 139 }; |
140 | 140 |
(...skipping 11 matching lines...) Expand all Loading... |
152 started_(false) { | 152 started_(false) { |
153 } | 153 } |
154 | 154 |
155 virtual ~LocalDomainResolverProxy() { | 155 virtual ~LocalDomainResolverProxy() { |
156 DVLOG(1) << "~LocalDomainResolverProxy with id " << id_; | 156 DVLOG(1) << "~LocalDomainResolverProxy with id " << id_; |
157 host_->UnregisterLocalDomainResolverCallback(id_); | 157 host_->UnregisterLocalDomainResolverCallback(id_); |
158 if (started_) | 158 if (started_) |
159 host_->Send(new LocalDiscoveryMsg_DestroyLocalDomainResolver(id_)); | 159 host_->Send(new LocalDiscoveryMsg_DestroyLocalDomainResolver(id_)); |
160 } | 160 } |
161 | 161 |
162 virtual void Start() OVERRIDE { | 162 virtual void Start() override { |
163 DVLOG(1) << "LocalDomainResolverProxy::Start with id " << id_; | 163 DVLOG(1) << "LocalDomainResolverProxy::Start with id " << id_; |
164 DCHECK(!started_); | 164 DCHECK(!started_); |
165 host_->Send(new LocalDiscoveryMsg_ResolveLocalDomain(id_, domain_, | 165 host_->Send(new LocalDiscoveryMsg_ResolveLocalDomain(id_, domain_, |
166 address_family_)); | 166 address_family_)); |
167 started_ = true; | 167 started_ = true; |
168 } | 168 } |
169 | 169 |
170 private: | 170 private: |
171 scoped_refptr<ServiceDiscoveryHostClient> host_; | 171 scoped_refptr<ServiceDiscoveryHostClient> host_; |
172 std::string domain_; | 172 std::string domain_; |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 bool success, | 446 bool success, |
447 const net::IPAddressNumber& ip_address_ipv4, | 447 const net::IPAddressNumber& ip_address_ipv4, |
448 const net::IPAddressNumber& ip_address_ipv6) { | 448 const net::IPAddressNumber& ip_address_ipv6) { |
449 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 449 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
450 DomainResolverCallbacks::iterator it = domain_resolver_callbacks_.find(id); | 450 DomainResolverCallbacks::iterator it = domain_resolver_callbacks_.find(id); |
451 if (it != domain_resolver_callbacks_.end() && !it->second.is_null()) | 451 if (it != domain_resolver_callbacks_.end() && !it->second.is_null()) |
452 it->second.Run(success, ip_address_ipv4, ip_address_ipv6); | 452 it->second.Run(success, ip_address_ipv4, ip_address_ipv6); |
453 } | 453 } |
454 | 454 |
455 } // namespace local_discovery | 455 } // namespace local_discovery |
OLD | NEW |