| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 void DialRegistry::AddDeviceForTest(const DialDeviceData& device_data) { | 119 void DialRegistry::AddDeviceForTest(const DialDeviceData& device_data) { |
| 120 std::unique_ptr<DialDeviceData> test_data = | 120 std::unique_ptr<DialDeviceData> test_data = |
| 121 base::MakeUnique<DialDeviceData>(device_data); | 121 base::MakeUnique<DialDeviceData>(device_data); |
| 122 device_by_label_map_.insert( | 122 device_by_label_map_.insert( |
| 123 std::make_pair(device_data.label(), test_data.get())); | 123 std::make_pair(device_data.label(), test_data.get())); |
| 124 device_by_id_map_.insert( | 124 device_by_id_map_.insert( |
| 125 std::make_pair(device_data.device_id(), std::move(test_data))); | 125 std::make_pair(device_data.device_id(), std::move(test_data))); |
| 126 } | 126 } |
| 127 | 127 |
| 128 bool DialRegistry::ReadyToDiscover() { | 128 bool DialRegistry::ReadyToDiscover() { |
| 129 if (num_listeners_ == 0) { | 129 if (!observers_.might_have_observers()) { |
| 130 OnDialError(DIAL_NO_LISTENERS); | 130 OnDialError(DIAL_NO_LISTENERS); |
| 131 return false; | 131 return false; |
| 132 } | 132 } |
| 133 if (NetworkChangeNotifier::IsOffline()) { | 133 if (NetworkChangeNotifier::IsOffline()) { |
| 134 OnDialError(DIAL_NETWORK_DISCONNECTED); | 134 OnDialError(DIAL_NETWORK_DISCONNECTED); |
| 135 return false; | 135 return false; |
| 136 } | 136 } |
| 137 if (NetworkChangeNotifier::IsConnectionCellular( | 137 if (NetworkChangeNotifier::IsConnectionCellular( |
| 138 NetworkChangeNotifier::GetConnectionType())) { | 138 NetworkChangeNotifier::GetConnectionType())) { |
| 139 OnDialError(DIAL_CELLULAR_NETWORK); | 139 OnDialError(DIAL_CELLULAR_NETWORK); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 for (auto& observer : observers_) | 382 for (auto& observer : observers_) |
| 383 observer.OnDialDeviceEvent(devices); | 383 observer.OnDialDeviceEvent(devices); |
| 384 } | 384 } |
| 385 | 385 |
| 386 void DialRegistry::OnDialError(DialErrorCode type) { | 386 void DialRegistry::OnDialError(DialErrorCode type) { |
| 387 for (auto& observer : observers_) | 387 for (auto& observer : observers_) |
| 388 observer.OnDialError(type); | 388 observer.OnDialError(type); |
| 389 } | 389 } |
| 390 | 390 |
| 391 } // namespace media_router | 391 } // namespace media_router |
| OLD | NEW |