| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/media/router/discovery/dial/dial_registry.h" | 5 #include "chrome/browser/media/router/discovery/dial/dial_registry.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 using base::Time; | 22 using base::Time; |
| 23 using base::TimeDelta; | 23 using base::TimeDelta; |
| 24 using content::BrowserThread; | 24 using content::BrowserThread; |
| 25 using net::NetworkChangeNotifier; | 25 using net::NetworkChangeNotifier; |
| 26 | 26 |
| 27 namespace media_router { | 27 namespace media_router { |
| 28 | 28 |
| 29 DialRegistry::DialRegistry(base::TimeDelta refresh_interval, | 29 DialRegistry::DialRegistry(base::TimeDelta refresh_interval, |
| 30 base::TimeDelta expiration, | 30 base::TimeDelta expiration, |
| 31 const size_t max_devices) | 31 const size_t max_devices) |
| 32 : num_listeners_(0), | 32 : RefcountedKeyedService( |
| 33 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)), |
| 34 num_listeners_(0), |
| 33 registry_generation_(0), | 35 registry_generation_(0), |
| 34 last_event_registry_generation_(0), | 36 last_event_registry_generation_(0), |
| 35 label_count_(0), | 37 label_count_(0), |
| 36 refresh_interval_delta_(refresh_interval), | 38 refresh_interval_delta_(refresh_interval), |
| 37 expiration_delta_(expiration), | 39 expiration_delta_(expiration), |
| 38 max_devices_(max_devices) { | 40 max_devices_(max_devices) { |
| 39 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 41 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 40 DCHECK_GT(max_devices_, 0U); | 42 DCHECK_GT(max_devices_, 0U); |
| 41 NetworkChangeNotifier::AddNetworkChangeObserver(this); | 43 NetworkChangeNotifier::AddNetworkChangeObserver(this); |
| 42 } | 44 } |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 | 245 |
| 244 // Reset watermark. | 246 // Reset watermark. |
| 245 last_event_registry_generation_ = registry_generation_; | 247 last_event_registry_generation_ = registry_generation_; |
| 246 } | 248 } |
| 247 | 249 |
| 248 std::string DialRegistry::NextLabel() { | 250 std::string DialRegistry::NextLabel() { |
| 249 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 251 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 250 return base::IntToString(++label_count_); | 252 return base::IntToString(++label_count_); |
| 251 } | 253 } |
| 252 | 254 |
| 255 void DialRegistry::ShutdownOnUIThread() {} |
| 256 |
| 253 void DialRegistry::OnDiscoveryRequest(DialService* service) { | 257 void DialRegistry::OnDiscoveryRequest(DialService* service) { |
| 254 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 258 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 255 MaybeSendEvent(); | 259 MaybeSendEvent(); |
| 256 } | 260 } |
| 257 | 261 |
| 258 void DialRegistry::OnDeviceDiscovered(DialService* service, | 262 void DialRegistry::OnDeviceDiscovered(DialService* service, |
| 259 const DialDeviceData& device) { | 263 const DialDeviceData& device) { |
| 260 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 264 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 261 | 265 |
| 262 // Adds |device| to our list of devices or updates an existing device, unless | 266 // Adds |device| to our list of devices or updates an existing device, unless |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 for (auto& observer : observers_) | 366 for (auto& observer : observers_) |
| 363 observer.OnDialDeviceEvent(devices); | 367 observer.OnDialDeviceEvent(devices); |
| 364 } | 368 } |
| 365 | 369 |
| 366 void DialRegistry::OnDialError(DialErrorCode type) { | 370 void DialRegistry::OnDialError(DialErrorCode type) { |
| 367 for (auto& observer : observers_) | 371 for (auto& observer : observers_) |
| 368 observer.OnDialError(type); | 372 observer.OnDialError(type); |
| 369 } | 373 } |
| 370 | 374 |
| 371 } // namespace media_router | 375 } // namespace media_router |
| OLD | NEW |