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 "chromeos/network/shill_property_handler.h" | 5 #include "chromeos/network/shill_property_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 AsWeakPtr(), type, path)); | 198 AsWeakPtr(), type, path)); |
199 } else { | 199 } else { |
200 NOTREACHED(); | 200 NOTREACHED(); |
201 } | 201 } |
202 } | 202 } |
203 | 203 |
204 void ShillPropertyHandler::OnPropertyChanged(const std::string& key, | 204 void ShillPropertyHandler::OnPropertyChanged(const std::string& key, |
205 const base::Value& value) { | 205 const base::Value& value) { |
206 if (ManagerPropertyChanged(key, value)) | 206 if (ManagerPropertyChanged(key, value)) |
207 listener_->ManagerPropertyChanged(); | 207 listener_->ManagerPropertyChanged(); |
208 // If the service watch or device list changed and there are no pending | 208 // If the service or device list changed and there are no pending |
209 // updates, signal the state list changed callback. | 209 // updates, signal the state list changed callback. |
210 if ((key == flimflam::kServiceWatchListProperty) && | 210 if ((key == flimflam::kServicesProperty) && |
211 pending_updates_[ManagedState::MANAGED_TYPE_NETWORK].size() == 0) { | 211 pending_updates_[ManagedState::MANAGED_TYPE_NETWORK].size() == 0) { |
212 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_NETWORK); | 212 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_NETWORK); |
213 } | 213 } |
214 if (key == flimflam::kDevicesProperty && | 214 if (key == flimflam::kDevicesProperty && |
215 pending_updates_[ManagedState::MANAGED_TYPE_DEVICE].size() == 0) { | 215 pending_updates_[ManagedState::MANAGED_TYPE_DEVICE].size() == 0) { |
216 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_DEVICE); | 216 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_DEVICE); |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 //------------------------------------------------------------------------------ | 220 //------------------------------------------------------------------------------ |
(...skipping 30 matching lines...) Expand all Loading... | |
251 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_NETWORK); | 251 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_NETWORK); |
252 if (pending_updates_[ManagedState::MANAGED_TYPE_DEVICE].size() == 0) | 252 if (pending_updates_[ManagedState::MANAGED_TYPE_DEVICE].size() == 0) |
253 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_DEVICE); | 253 listener_->ManagedStateListChanged(ManagedState::MANAGED_TYPE_DEVICE); |
254 } | 254 } |
255 | 255 |
256 bool ShillPropertyHandler::ManagerPropertyChanged(const std::string& key, | 256 bool ShillPropertyHandler::ManagerPropertyChanged(const std::string& key, |
257 const base::Value& value) { | 257 const base::Value& value) { |
258 bool notify_manager_changed = false; | 258 bool notify_manager_changed = false; |
259 if (key == flimflam::kServicesProperty) { | 259 if (key == flimflam::kServicesProperty) { |
260 const base::ListValue* vlist = GetListValue(key, value); | 260 const base::ListValue* vlist = GetListValue(key, value); |
261 if (vlist) | 261 if (vlist) { |
262 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_NETWORK, *vlist); | 262 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_NETWORK, *vlist); |
263 } else if (key == flimflam::kServiceWatchListProperty) { | 263 // UpdateObserved used to use kServiceWatchListProperty for TYPE_NETWORK, |
pneubeck (no reviews)
2013/05/13 10:21:03
shouldn't this be a method comment?
stevenjb
2013/05/13 21:31:40
No, it's really an implementation detail. I'd rath
| |
264 const base::ListValue* vlist = GetListValue(key, value); | 264 // however that prevents us from receiving Strength updates from inactive |
265 if (vlist) { | 265 // networks. The overhead for observing all services is not unreasonable |
266 // (and we limit the max number of observed services to kMaxObserved). | |
266 UpdateObserved(ManagedState::MANAGED_TYPE_NETWORK, *vlist); | 267 UpdateObserved(ManagedState::MANAGED_TYPE_NETWORK, *vlist); |
267 } | 268 } |
268 } else if (key == flimflam::kDevicesProperty) { | 269 } else if (key == flimflam::kDevicesProperty) { |
269 const ListValue* vlist = GetListValue(key, value); | 270 const ListValue* vlist = GetListValue(key, value); |
270 if (vlist) { | 271 if (vlist) { |
271 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_DEVICE, *vlist); | 272 listener_->UpdateManagedList(ManagedState::MANAGED_TYPE_DEVICE, *vlist); |
272 UpdateObserved(ManagedState::MANAGED_TYPE_DEVICE, *vlist); | 273 UpdateObserved(ManagedState::MANAGED_TYPE_DEVICE, *vlist); |
273 } | 274 } |
274 } else if (key == flimflam::kAvailableTechnologiesProperty) { | 275 } else if (key == flimflam::kAvailableTechnologiesProperty) { |
275 const base::ListValue* vlist = GetListValue(key, value); | 276 const base::ListValue* vlist = GetListValue(key, value); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 // Request an update. | 315 // Request an update. |
315 RequestProperties(type, path); | 316 RequestProperties(type, path); |
316 // Create an observer for future updates. | 317 // Create an observer for future updates. |
317 new_observed[path] = new ShillPropertyObserver( | 318 new_observed[path] = new ShillPropertyObserver( |
318 type, path, base::Bind( | 319 type, path, base::Bind( |
319 &ShillPropertyHandler::PropertyChangedCallback, AsWeakPtr())); | 320 &ShillPropertyHandler::PropertyChangedCallback, AsWeakPtr())); |
320 network_event_log::AddEntry(kLogModule, "StartObserving", path); | 321 network_event_log::AddEntry(kLogModule, "StartObserving", path); |
321 } | 322 } |
322 observer_map.erase(path); | 323 observer_map.erase(path); |
323 // Limit the number of observed services. | 324 // Limit the number of observed services. |
324 if (new_observed.size() >= kMaxObserved) | 325 if (new_observed.size() >= kMaxObserved) |
pneubeck (no reviews)
2013/05/13 10:21:03
This is a serious restriction which should be docu
stevenjb
2013/05/13 21:31:40
I don't think this is a big of a restriction as yo
pneubeck (no reviews)
2013/05/14 14:12:32
Ok. Here is the conflict we run into with this:
-
| |
325 break; | 326 break; |
326 } | 327 } |
327 // Delete network service observers still in observer_map. | 328 // Delete network service observers still in observer_map. |
328 for (ShillPropertyObserverMap::iterator iter = observer_map.begin(); | 329 for (ShillPropertyObserverMap::iterator iter = observer_map.begin(); |
329 iter != observer_map.end(); ++iter) { | 330 iter != observer_map.end(); ++iter) { |
330 network_event_log::AddEntry(kLogModule, "StopObserving", iter->first); | 331 network_event_log::AddEntry(kLogModule, "StopObserving", iter->first); |
331 delete iter->second; | 332 delete iter->second; |
332 } | 333 } |
333 observer_map.swap(new_observed); | 334 observer_map.swap(new_observed); |
334 } | 335 } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 | 486 |
486 void ShillPropertyHandler::NetworkDevicePropertyChangedCallback( | 487 void ShillPropertyHandler::NetworkDevicePropertyChangedCallback( |
487 const std::string& path, | 488 const std::string& path, |
488 const std::string& key, | 489 const std::string& key, |
489 const base::Value& value) { | 490 const base::Value& value) { |
490 listener_->UpdateDeviceProperty(path, key, value); | 491 listener_->UpdateDeviceProperty(path, key, value); |
491 } | 492 } |
492 | 493 |
493 } // namespace internal | 494 } // namespace internal |
494 } // namespace chromeos | 495 } // namespace chromeos |
OLD | NEW |