Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: chromeos/network/network_configuration_handler.cc

Issue 2413963002: Replace FOR_EACH_OBSERVER in chromeos/ with range-based for (Closed)
Patch Set: Run the script again with '/mg' Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/network_configuration_handler.h" 5 #include "chromeos/network/network_configuration_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 std::unique_ptr<base::DictionaryValue> configure_properties, 394 std::unique_ptr<base::DictionaryValue> configure_properties,
395 const network_handler::ServiceResultCallback& callback, 395 const network_handler::ServiceResultCallback& callback,
396 const dbus::ObjectPath& service_path) { 396 const dbus::ObjectPath& service_path) {
397 if (!callback.is_null()) { 397 if (!callback.is_null()) {
398 std::string guid; 398 std::string guid;
399 configure_properties->GetStringWithoutPathExpansion( 399 configure_properties->GetStringWithoutPathExpansion(
400 ::onc::network_config::kGUID, &guid); 400 ::onc::network_config::kGUID, &guid);
401 DCHECK(!guid.empty()); 401 DCHECK(!guid.empty());
402 callback.Run(service_path.value(), guid); 402 callback.Run(service_path.value(), guid);
403 } 403 }
404 FOR_EACH_OBSERVER(NetworkConfigurationObserver, observers_, 404 for (auto& observer : observers_) {
405 OnConfigurationCreated(service_path.value(), profile_path, 405 observer.OnConfigurationCreated(service_path.value(), profile_path,
406 *configure_properties, source)); 406 *configure_properties, source);
407 }
407 // This may also get called when CreateConfiguration is used to update an 408 // This may also get called when CreateConfiguration is used to update an
408 // existing configuration, so request a service update just in case. 409 // existing configuration, so request a service update just in case.
409 // TODO(pneubeck): Separate 'Create' and 'Update' calls and only trigger 410 // TODO(pneubeck): Separate 'Create' and 'Update' calls and only trigger
410 // this on an update. 411 // this on an update.
411 network_state_handler_->RequestUpdateForNetwork(service_path.value()); 412 network_state_handler_->RequestUpdateForNetwork(service_path.value());
412 } 413 }
413 414
414 void NetworkConfigurationHandler::ProfileEntryDeleterCompleted( 415 void NetworkConfigurationHandler::ProfileEntryDeleterCompleted(
415 const std::string& service_path, 416 const std::string& service_path,
416 const std::string& guid, 417 const std::string& guid,
417 NetworkConfigurationObserver::Source source, 418 NetworkConfigurationObserver::Source source,
418 bool success) { 419 bool success) {
419 if (success) { 420 if (success) {
420 FOR_EACH_OBSERVER(NetworkConfigurationObserver, observers_, 421 for (auto& observer : observers_)
421 OnConfigurationRemoved(service_path, guid, source)); 422 observer.OnConfigurationRemoved(service_path, guid, source);
422 } 423 }
423 auto iter = profile_entry_deleters_.find(service_path); 424 auto iter = profile_entry_deleters_.find(service_path);
424 DCHECK(iter != profile_entry_deleters_.end()); 425 DCHECK(iter != profile_entry_deleters_.end());
425 profile_entry_deleters_.erase(iter); 426 profile_entry_deleters_.erase(iter);
426 } 427 }
427 428
428 void NetworkConfigurationHandler::SetNetworkProfileCompleted( 429 void NetworkConfigurationHandler::SetNetworkProfileCompleted(
429 const std::string& service_path, 430 const std::string& service_path,
430 const std::string& profile_path, 431 const std::string& profile_path,
431 NetworkConfigurationObserver::Source source, 432 NetworkConfigurationObserver::Source source,
432 const base::Closure& callback) { 433 const base::Closure& callback) {
433 if (!callback.is_null()) 434 if (!callback.is_null())
434 callback.Run(); 435 callback.Run();
435 FOR_EACH_OBSERVER( 436 for (auto& observer : observers_)
436 NetworkConfigurationObserver, observers_, 437 observer.OnConfigurationProfileChanged(service_path, profile_path, source);
437 OnConfigurationProfileChanged(service_path, profile_path, source));
438 } 438 }
439 439
440 void NetworkConfigurationHandler::GetPropertiesCallback( 440 void NetworkConfigurationHandler::GetPropertiesCallback(
441 const network_handler::DictionaryResultCallback& callback, 441 const network_handler::DictionaryResultCallback& callback,
442 const network_handler::ErrorCallback& error_callback, 442 const network_handler::ErrorCallback& error_callback,
443 const std::string& service_path, 443 const std::string& service_path,
444 DBusMethodCallStatus call_status, 444 DBusMethodCallStatus call_status,
445 const base::DictionaryValue& properties) { 445 const base::DictionaryValue& properties) {
446 if (call_status != DBUS_METHOD_CALL_SUCCESS) { 446 if (call_status != DBUS_METHOD_CALL_SUCCESS) {
447 // Because network services are added and removed frequently, we will see 447 // Because network services are added and removed frequently, we will see
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 std::unique_ptr<base::DictionaryValue> set_properties, 481 std::unique_ptr<base::DictionaryValue> set_properties,
482 NetworkConfigurationObserver::Source source, 482 NetworkConfigurationObserver::Source source,
483 const base::Closure& callback) { 483 const base::Closure& callback) {
484 if (!callback.is_null()) 484 if (!callback.is_null())
485 callback.Run(); 485 callback.Run();
486 const NetworkState* network_state = 486 const NetworkState* network_state =
487 network_state_handler_->GetNetworkState(service_path); 487 network_state_handler_->GetNetworkState(service_path);
488 if (!network_state) 488 if (!network_state)
489 return; // Network no longer exists, do not notify or request update. 489 return; // Network no longer exists, do not notify or request update.
490 490
491 FOR_EACH_OBSERVER(NetworkConfigurationObserver, observers_, 491 for (auto& observer : observers_) {
492 OnPropertiesSet(service_path, network_state->guid(), 492 observer.OnPropertiesSet(service_path, network_state->guid(),
493 *set_properties, source)); 493 *set_properties, source);
494 }
494 network_state_handler_->RequestUpdateForNetwork(service_path); 495 network_state_handler_->RequestUpdateForNetwork(service_path);
495 } 496 }
496 497
497 void NetworkConfigurationHandler::SetPropertiesErrorCallback( 498 void NetworkConfigurationHandler::SetPropertiesErrorCallback(
498 const std::string& service_path, 499 const std::string& service_path,
499 const network_handler::ErrorCallback& error_callback, 500 const network_handler::ErrorCallback& error_callback,
500 const std::string& dbus_error_name, 501 const std::string& dbus_error_name,
501 const std::string& dbus_error_message) { 502 const std::string& dbus_error_message) {
502 network_handler::ShillErrorCallbackFunction( 503 network_handler::ShillErrorCallbackFunction(
503 "Config.SetProperties Failed", service_path, error_callback, 504 "Config.SetProperties Failed", service_path, error_callback,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 // static 560 // static
560 NetworkConfigurationHandler* NetworkConfigurationHandler::InitializeForTest( 561 NetworkConfigurationHandler* NetworkConfigurationHandler::InitializeForTest(
561 NetworkStateHandler* network_state_handler, 562 NetworkStateHandler* network_state_handler,
562 NetworkDeviceHandler* network_device_handler) { 563 NetworkDeviceHandler* network_device_handler) {
563 NetworkConfigurationHandler* handler = new NetworkConfigurationHandler(); 564 NetworkConfigurationHandler* handler = new NetworkConfigurationHandler();
564 handler->Init(network_state_handler, network_device_handler); 565 handler->Init(network_state_handler, network_device_handler);
565 return handler; 566 return handler;
566 } 567 }
567 568
568 } // namespace chromeos 569 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/managed_network_configuration_handler_impl.cc ('k') | chromeos/network/network_connection_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698