Commit 97cd6235 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

[Code Health] Convert ServiceResultCallback to OnceCallback

This conversion should have no functional change.

Note: I will convert base::Bind calls to base::BindOnce all at once once
all the uses of Callback and Closure are converted in
//chromeos/network.

Bug: 1007660
Change-Id: Id38c76057055ffb3eac02f31c37763928e98e6c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2289086
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789222}
parent 3439e837
...@@ -99,7 +99,7 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) ManagedNetworkConfigurationHandler { ...@@ -99,7 +99,7 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) ManagedNetworkConfigurationHandler {
virtual void CreateConfiguration( virtual void CreateConfiguration(
const std::string& userhash, const std::string& userhash,
const base::DictionaryValue& properties, const base::DictionaryValue& properties,
const network_handler::ServiceResultCallback& callback, network_handler::ServiceResultCallback callback,
network_handler::ErrorCallback error_callback) const = 0; network_handler::ErrorCallback error_callback) const = 0;
// Removes the user's configuration from the network with |service_path|. The // Removes the user's configuration from the network with |service_path|. The
......
...@@ -339,7 +339,7 @@ void ManagedNetworkConfigurationHandlerImpl::SetShillProperties( ...@@ -339,7 +339,7 @@ void ManagedNetworkConfigurationHandlerImpl::SetShillProperties(
void ManagedNetworkConfigurationHandlerImpl::CreateConfiguration( void ManagedNetworkConfigurationHandlerImpl::CreateConfiguration(
const std::string& userhash, const std::string& userhash,
const base::DictionaryValue& properties, const base::DictionaryValue& properties,
const network_handler::ServiceResultCallback& callback, network_handler::ServiceResultCallback callback,
network_handler::ErrorCallback error_callback) const { network_handler::ErrorCallback error_callback) const {
std::string guid = std::string guid =
GetStringFromDictionary(properties, ::onc::network_config::kGUID); GetStringFromDictionary(properties, ::onc::network_config::kGUID);
...@@ -449,7 +449,7 @@ void ManagedNetworkConfigurationHandlerImpl::CreateConfiguration( ...@@ -449,7 +449,7 @@ void ManagedNetworkConfigurationHandlerImpl::CreateConfiguration(
validated_properties.get())); validated_properties.get()));
network_configuration_handler_->CreateShillConfiguration( network_configuration_handler_->CreateShillConfiguration(
*shill_dictionary, callback, std::move(error_callback)); *shill_dictionary, std::move(callback), std::move(error_callback));
} }
void ManagedNetworkConfigurationHandlerImpl::RemoveConfiguration( void ManagedNetworkConfigurationHandlerImpl::RemoveConfiguration(
......
...@@ -59,7 +59,7 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) ManagedNetworkConfigurationHandlerImpl ...@@ -59,7 +59,7 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) ManagedNetworkConfigurationHandlerImpl
void CreateConfiguration( void CreateConfiguration(
const std::string& userhash, const std::string& userhash,
const base::DictionaryValue& properties, const base::DictionaryValue& properties,
const network_handler::ServiceResultCallback& callback, network_handler::ServiceResultCallback callback,
network_handler::ErrorCallback error_callback) const override; network_handler::ErrorCallback error_callback) const override;
void RemoveConfiguration( void RemoveConfiguration(
......
...@@ -37,11 +37,10 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) MockManagedNetworkConfigurationHandler ...@@ -37,11 +37,10 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) MockManagedNetworkConfigurationHandler
const base::DictionaryValue& user_settings, const base::DictionaryValue& user_settings,
const base::Closure& callback, const base::Closure& callback,
network_handler::ErrorCallback error_callback)); network_handler::ErrorCallback error_callback));
MOCK_CONST_METHOD4( MOCK_CONST_METHOD4(CreateConfiguration,
CreateConfiguration,
void(const std::string& userhash, void(const std::string& userhash,
const base::DictionaryValue& properties, const base::DictionaryValue& properties,
const network_handler::ServiceResultCallback& callback, network_handler::ServiceResultCallback callback,
network_handler::ErrorCallback error_callback)); network_handler::ErrorCallback error_callback));
MOCK_CONST_METHOD3(RemoveConfiguration, MOCK_CONST_METHOD3(RemoveConfiguration,
void(const std::string& service_path, void(const std::string& service_path,
......
...@@ -338,7 +338,7 @@ void NetworkConfigurationHandler::ClearShillProperties( ...@@ -338,7 +338,7 @@ void NetworkConfigurationHandler::ClearShillProperties(
void NetworkConfigurationHandler::CreateShillConfiguration( void NetworkConfigurationHandler::CreateShillConfiguration(
const base::DictionaryValue& shill_properties, const base::DictionaryValue& shill_properties,
const network_handler::ServiceResultCallback& callback, network_handler::ServiceResultCallback callback,
network_handler::ErrorCallback error_callback) { network_handler::ErrorCallback error_callback) {
ShillManagerClient* manager = ShillManagerClient::Get(); ShillManagerClient* manager = ShillManagerClient::Get();
std::string type; std::string type;
...@@ -372,7 +372,7 @@ void NetworkConfigurationHandler::CreateShillConfiguration( ...@@ -372,7 +372,7 @@ void NetworkConfigurationHandler::CreateShillConfiguration(
dbus::ObjectPath(profile_path), *properties_to_set, dbus::ObjectPath(profile_path), *properties_to_set,
base::BindOnce(&NetworkConfigurationHandler::ConfigurationCompleted, base::BindOnce(&NetworkConfigurationHandler::ConfigurationCompleted,
weak_ptr_factory_.GetWeakPtr(), profile_path, guid, weak_ptr_factory_.GetWeakPtr(), profile_path, guid,
base::Passed(&properties_copy), callback), base::Passed(&properties_copy), std::move(callback)),
base::BindOnce(&NetworkConfigurationHandler::ConfigurationFailed, base::BindOnce(&NetworkConfigurationHandler::ConfigurationFailed,
weak_ptr_factory_.GetWeakPtr(), weak_ptr_factory_.GetWeakPtr(),
std::move(error_callback))); std::move(error_callback)));
...@@ -474,7 +474,7 @@ void NetworkConfigurationHandler::NetworkListChanged() { ...@@ -474,7 +474,7 @@ void NetworkConfigurationHandler::NetworkListChanged() {
continue; continue;
} }
network_handler::ServiceResultCallback& callback = iter->second; network_handler::ServiceResultCallback& callback = iter->second;
callback.Run(service_path, state->guid()); std::move(callback).Run(service_path, state->guid());
iter = configure_callbacks_.erase(iter); iter = configure_callbacks_.erase(iter);
} }
} }
...@@ -522,7 +522,7 @@ void NetworkConfigurationHandler::ConfigurationCompleted( ...@@ -522,7 +522,7 @@ void NetworkConfigurationHandler::ConfigurationCompleted(
const std::string& profile_path, const std::string& profile_path,
const std::string& guid, const std::string& guid,
std::unique_ptr<base::DictionaryValue> configure_properties, std::unique_ptr<base::DictionaryValue> configure_properties,
const network_handler::ServiceResultCallback& callback, network_handler::ServiceResultCallback callback,
const dbus::ObjectPath& service_path) { const dbus::ObjectPath& service_path) {
// It is possible that the newly-configured network was already being tracked // It is possible that the newly-configured network was already being tracked
// by |network_state_handler_|. If this is the case, clear any existing error // by |network_state_handler_|. If this is the case, clear any existing error
...@@ -542,7 +542,8 @@ void NetworkConfigurationHandler::ConfigurationCompleted( ...@@ -542,7 +542,8 @@ void NetworkConfigurationHandler::ConfigurationCompleted(
// |configure_callbacks_| will get triggered when NetworkStateHandler // |configure_callbacks_| will get triggered when NetworkStateHandler
// notifies this that a state list update has occurred. |service_path| // notifies this that a state list update has occurred. |service_path|
// is unique per configuration. // is unique per configuration.
configure_callbacks_.insert(std::make_pair(service_path.value(), callback)); configure_callbacks_.insert(
std::make_pair(service_path.value(), std::move(callback)));
} }
void NetworkConfigurationHandler::ProfileEntryDeleterCompleted( void NetworkConfigurationHandler::ProfileEntryDeleterCompleted(
......
...@@ -94,9 +94,8 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) NetworkConfigurationHandler ...@@ -94,9 +94,8 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) NetworkConfigurationHandler
// Manager.ConfigureServiceForProfile. NOTE: Normally // Manager.ConfigureServiceForProfile. NOTE: Normally
// ManagedNetworkConfigurationHandler should be used to call // ManagedNetworkConfigurationHandler should be used to call
// CreateConfiguration. This will set GUID if not provided. // CreateConfiguration. This will set GUID if not provided.
void CreateShillConfiguration( void CreateShillConfiguration(const base::DictionaryValue& shill_properties,
const base::DictionaryValue& shill_properties, network_handler::ServiceResultCallback callback,
const network_handler::ServiceResultCallback& callback,
network_handler::ErrorCallback error_callback); network_handler::ErrorCallback error_callback);
// Removes the network |service_path| from any profiles that include it. // Removes the network |service_path| from any profiles that include it.
...@@ -147,7 +146,7 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) NetworkConfigurationHandler ...@@ -147,7 +146,7 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) NetworkConfigurationHandler
const std::string& profile_path, const std::string& profile_path,
const std::string& guid, const std::string& guid,
std::unique_ptr<base::DictionaryValue> configure_properties, std::unique_ptr<base::DictionaryValue> configure_properties,
const network_handler::ServiceResultCallback& callback, network_handler::ServiceResultCallback callback,
const dbus::ObjectPath& service_path); const dbus::ObjectPath& service_path);
void ConfigurationFailed(network_handler::ErrorCallback error_callback, void ConfigurationFailed(network_handler::ErrorCallback error_callback,
......
...@@ -45,9 +45,9 @@ using ErrorCallback = ...@@ -45,9 +45,9 @@ using ErrorCallback =
typedef base::Callback<void(const std::string& string_result)> typedef base::Callback<void(const std::string& string_result)>
StringResultCallback; StringResultCallback;
typedef base::Callback<void(const std::string& service_path, using ServiceResultCallback =
const std::string& guid)> base::OnceCallback<void(const std::string& service_path,
ServiceResultCallback; const std::string& guid)>;
// Create a DictionaryValue for passing to ErrorCallback. // Create a DictionaryValue for passing to ErrorCallback.
COMPONENT_EXPORT(CHROMEOS_NETWORK) COMPONENT_EXPORT(CHROMEOS_NETWORK)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment