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 {
virtual void CreateConfiguration(
const std::string& userhash,
const base::DictionaryValue& properties,
const network_handler::ServiceResultCallback& callback,
network_handler::ServiceResultCallback callback,
network_handler::ErrorCallback error_callback) const = 0;
// Removes the user's configuration from the network with |service_path|. The
......
......@@ -339,7 +339,7 @@ void ManagedNetworkConfigurationHandlerImpl::SetShillProperties(
void ManagedNetworkConfigurationHandlerImpl::CreateConfiguration(
const std::string& userhash,
const base::DictionaryValue& properties,
const network_handler::ServiceResultCallback& callback,
network_handler::ServiceResultCallback callback,
network_handler::ErrorCallback error_callback) const {
std::string guid =
GetStringFromDictionary(properties, ::onc::network_config::kGUID);
......@@ -449,7 +449,7 @@ void ManagedNetworkConfigurationHandlerImpl::CreateConfiguration(
validated_properties.get()));
network_configuration_handler_->CreateShillConfiguration(
*shill_dictionary, callback, std::move(error_callback));
*shill_dictionary, std::move(callback), std::move(error_callback));
}
void ManagedNetworkConfigurationHandlerImpl::RemoveConfiguration(
......
......@@ -59,7 +59,7 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) ManagedNetworkConfigurationHandlerImpl
void CreateConfiguration(
const std::string& userhash,
const base::DictionaryValue& properties,
const network_handler::ServiceResultCallback& callback,
network_handler::ServiceResultCallback callback,
network_handler::ErrorCallback error_callback) const override;
void RemoveConfiguration(
......
......@@ -37,12 +37,11 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) MockManagedNetworkConfigurationHandler
const base::DictionaryValue& user_settings,
const base::Closure& callback,
network_handler::ErrorCallback error_callback));
MOCK_CONST_METHOD4(
CreateConfiguration,
void(const std::string& userhash,
const base::DictionaryValue& properties,
const network_handler::ServiceResultCallback& callback,
network_handler::ErrorCallback error_callback));
MOCK_CONST_METHOD4(CreateConfiguration,
void(const std::string& userhash,
const base::DictionaryValue& properties,
network_handler::ServiceResultCallback callback,
network_handler::ErrorCallback error_callback));
MOCK_CONST_METHOD3(RemoveConfiguration,
void(const std::string& service_path,
const base::Closure& callback,
......
......@@ -338,7 +338,7 @@ void NetworkConfigurationHandler::ClearShillProperties(
void NetworkConfigurationHandler::CreateShillConfiguration(
const base::DictionaryValue& shill_properties,
const network_handler::ServiceResultCallback& callback,
network_handler::ServiceResultCallback callback,
network_handler::ErrorCallback error_callback) {
ShillManagerClient* manager = ShillManagerClient::Get();
std::string type;
......@@ -372,7 +372,7 @@ void NetworkConfigurationHandler::CreateShillConfiguration(
dbus::ObjectPath(profile_path), *properties_to_set,
base::BindOnce(&NetworkConfigurationHandler::ConfigurationCompleted,
weak_ptr_factory_.GetWeakPtr(), profile_path, guid,
base::Passed(&properties_copy), callback),
base::Passed(&properties_copy), std::move(callback)),
base::BindOnce(&NetworkConfigurationHandler::ConfigurationFailed,
weak_ptr_factory_.GetWeakPtr(),
std::move(error_callback)));
......@@ -474,7 +474,7 @@ void NetworkConfigurationHandler::NetworkListChanged() {
continue;
}
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);
}
}
......@@ -522,7 +522,7 @@ void NetworkConfigurationHandler::ConfigurationCompleted(
const std::string& profile_path,
const std::string& guid,
std::unique_ptr<base::DictionaryValue> configure_properties,
const network_handler::ServiceResultCallback& callback,
network_handler::ServiceResultCallback callback,
const dbus::ObjectPath& service_path) {
// 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
......@@ -542,7 +542,8 @@ void NetworkConfigurationHandler::ConfigurationCompleted(
// |configure_callbacks_| will get triggered when NetworkStateHandler
// notifies this that a state list update has occurred. |service_path|
// 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(
......
......@@ -94,10 +94,9 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) NetworkConfigurationHandler
// Manager.ConfigureServiceForProfile. NOTE: Normally
// ManagedNetworkConfigurationHandler should be used to call
// CreateConfiguration. This will set GUID if not provided.
void CreateShillConfiguration(
const base::DictionaryValue& shill_properties,
const network_handler::ServiceResultCallback& callback,
network_handler::ErrorCallback error_callback);
void CreateShillConfiguration(const base::DictionaryValue& shill_properties,
network_handler::ServiceResultCallback callback,
network_handler::ErrorCallback error_callback);
// Removes the network |service_path| from any profiles that include it.
void RemoveConfiguration(const std::string& service_path,
......@@ -147,7 +146,7 @@ class COMPONENT_EXPORT(CHROMEOS_NETWORK) NetworkConfigurationHandler
const std::string& profile_path,
const std::string& guid,
std::unique_ptr<base::DictionaryValue> configure_properties,
const network_handler::ServiceResultCallback& callback,
network_handler::ServiceResultCallback callback,
const dbus::ObjectPath& service_path);
void ConfigurationFailed(network_handler::ErrorCallback error_callback,
......
......@@ -45,9 +45,9 @@ using ErrorCallback =
typedef base::Callback<void(const std::string& string_result)>
StringResultCallback;
typedef base::Callback<void(const std::string& service_path,
const std::string& guid)>
ServiceResultCallback;
using ServiceResultCallback =
base::OnceCallback<void(const std::string& service_path,
const std::string& guid)>;
// Create a DictionaryValue for passing to ErrorCallback.
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