summaryrefslogtreecommitdiffstats
path: root/chromeos/network/network_configuration_handler.cc
diff options
context:
space:
mode:
authorstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-28 18:33:30 +0000
committerstevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-28 18:33:30 +0000
commit437a9f8fd20379f3314d1f515dca115dac0aaaaf (patch)
tree41f0d877f211d43bc87d2ef6e2a323d116227f2a /chromeos/network/network_configuration_handler.cc
parent4520d538e9fe0beb97609e1f6438e6a71924c227 (diff)
downloadchromium_src-437a9f8fd20379f3314d1f515dca115dac0aaaaf.zip
chromium_src-437a9f8fd20379f3314d1f515dca115dac0aaaaf.tar.gz
chromium_src-437a9f8fd20379f3314d1f515dca115dac0aaaaf.tar.bz2
Add NetworkHandler to own network handlers in src/chromeos/network
This is just some code cleanup and should have no behavior changes. BUG=239073 For webui/chromeos, browser/geolocation: TBR=nkostylev@chromium.org,joth@chromium.org Review URL: https://chromiumcodereview.appspot.com/14729017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202609 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/network/network_configuration_handler.cc')
-rw-r--r--chromeos/network/network_configuration_handler.cc70
1 files changed, 32 insertions, 38 deletions
diff --git a/chromeos/network/network_configuration_handler.cc b/chromeos/network/network_configuration_handler.cc
index 91c87a0..903e606 100644
--- a/chromeos/network/network_configuration_handler.cc
+++ b/chromeos/network/network_configuration_handler.cc
@@ -24,8 +24,6 @@ namespace chromeos {
namespace {
-NetworkConfigurationHandler* g_configuration_handler_instance = NULL;
-
// None of these error messages are user-facing: they should only appear in
// logs.
const char kErrorsListTag[] = "errors";
@@ -93,17 +91,6 @@ void RunCallbackWithDictionaryValue(
}
}
-void RunCreateNetworkCallback(
- const network_handler::StringResultCallback& callback,
- const dbus::ObjectPath& service_path) {
- callback.Run(service_path.value());
- // This may also get called when CreateConfiguration is used to update an
- // existing configuration, so request a service update just in case.
- // TODO(pneubeck): Separate 'Create' and 'Update' calls and only trigger
- // this on an update.
- NetworkStateHandler::Get()->RequestUpdateForNetwork(service_path.value());
-}
-
void IgnoreObjectPathCallback(const base::Closure& callback,
const dbus::ObjectPath& object_path) {
callback.Run();
@@ -111,26 +98,6 @@ void IgnoreObjectPathCallback(const base::Closure& callback,
} // namespace
-// static
-void NetworkConfigurationHandler::Initialize() {
- CHECK(!g_configuration_handler_instance);
- g_configuration_handler_instance = new NetworkConfigurationHandler;
-}
-
-// static
-void NetworkConfigurationHandler::Shutdown() {
- CHECK(g_configuration_handler_instance);
- delete g_configuration_handler_instance;
- g_configuration_handler_instance = NULL;
-}
-
-// static
-NetworkConfigurationHandler* NetworkConfigurationHandler::Get() {
- CHECK(g_configuration_handler_instance)
- << "NetworkConfigurationHandler::Get() called before Initialize()";
- return g_configuration_handler_instance;
-}
-
void NetworkConfigurationHandler::GetProperties(
const std::string& service_path,
const network_handler::DictionaryResultCallback& callback,
@@ -153,7 +120,7 @@ void NetworkConfigurationHandler::SetProperties(
base::Bind(&IgnoreObjectPathCallback, callback),
base::Bind(&network_handler::ShillErrorCallbackFunction,
service_path, error_callback));
- NetworkStateHandler::Get()->RequestUpdateForNetwork(service_path);
+ network_state_handler_->RequestUpdateForNetwork(service_path);
}
void NetworkConfigurationHandler::ClearProperties(
@@ -176,7 +143,7 @@ void NetworkConfigurationHandler::ClearProperties(
void NetworkConfigurationHandler::CreateConfiguration(
const base::DictionaryValue& properties,
const network_handler::StringResultCallback& callback,
- const network_handler::ErrorCallback& error_callback) const {
+ const network_handler::ErrorCallback& error_callback) {
ShillManagerClient* manager =
DBusThreadManager::Get()->GetShillManagerClient();
@@ -193,13 +160,15 @@ void NetworkConfigurationHandler::CreateConfiguration(
manager->ConfigureServiceForProfile(
dbus::ObjectPath(profile),
properties,
- base::Bind(&RunCreateNetworkCallback, callback),
+ base::Bind(&NetworkConfigurationHandler::RunCreateNetworkCallback,
+ AsWeakPtr(), callback),
base::Bind(&network_handler::ShillErrorCallbackFunction,
"", error_callback));
} else {
manager->GetService(
properties,
- base::Bind(&RunCreateNetworkCallback, callback),
+ base::Bind(&NetworkConfigurationHandler::RunCreateNetworkCallback,
+ AsWeakPtr(), callback),
base::Bind(&network_handler::ShillErrorCallbackFunction,
"", error_callback));
}
@@ -216,10 +185,35 @@ void NetworkConfigurationHandler::RemoveConfiguration(
service_path, error_callback));
}
-NetworkConfigurationHandler::NetworkConfigurationHandler() {
+NetworkConfigurationHandler::NetworkConfigurationHandler()
+ : network_state_handler_(NULL) {
}
NetworkConfigurationHandler::~NetworkConfigurationHandler() {
}
+void NetworkConfigurationHandler::Init(
+ NetworkStateHandler* network_state_handler) {
+ network_state_handler_ = network_state_handler;
+}
+
+void NetworkConfigurationHandler::RunCreateNetworkCallback(
+ const network_handler::StringResultCallback& callback,
+ const dbus::ObjectPath& service_path) {
+ callback.Run(service_path.value());
+ // This may also get called when CreateConfiguration is used to update an
+ // existing configuration, so request a service update just in case.
+ // TODO(pneubeck): Separate 'Create' and 'Update' calls and only trigger
+ // this on an update.
+ network_state_handler_->RequestUpdateForNetwork(service_path.value());
+}
+
+// static
+NetworkConfigurationHandler* NetworkConfigurationHandler::InitializeForTest(
+ NetworkStateHandler* network_state_handler) {
+ NetworkConfigurationHandler* handler = new NetworkConfigurationHandler();
+ handler->Init(network_state_handler);
+ return handler;
+}
+
} // namespace chromeos