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

Unified Diff: chrome/browser/chromeos/cros/cros_network_functions.cc

Issue 10949030: This converts the Shill clients to allow propagation of shill errors (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Review changes Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/cros/cros_network_functions.cc
diff --git a/chrome/browser/chromeos/cros/cros_network_functions.cc b/chrome/browser/chromeos/cros/cros_network_functions.cc
index b8cf380e3e112ff59393cb9eda2122df953ffba9..72b9e979d3febf5cd8942c09ba9efb88641a4be8 100644
--- a/chrome/browser/chromeos/cros/cros_network_functions.cc
+++ b/chrome/browser/chromeos/cros/cros_network_functions.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/cros/cros_network_functions.h"
#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/memory/scoped_ptr.h"
#include "base/string_tokenizer.h"
#include "base/stringprintf.h"
@@ -21,6 +22,8 @@
#include "dbus/object_path.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
+using base::DoNothing;
+
namespace chromeos {
namespace {
@@ -180,7 +183,11 @@ class DataPlanUpdateWatcher : public CrosNetworkWatcher {
};
// Does nothing. Used as a callback.
-void DoNothing(DBusMethodCallStatus call_status) {}
+void DoNothingWithCallStatus(DBusMethodCallStatus call_status) {}
+
+// Ignores errors.
+void IgnoreErrors(const std::string& error_name,
+ const std::string& error_message) {}
// A callback used to implement CrosRequest*Properties functions.
void RunCallbackWithDictionaryValue(const NetworkPropertiesCallback& callback,
@@ -190,17 +197,33 @@ void RunCallbackWithDictionaryValue(const NetworkPropertiesCallback& callback,
callback.Run(path, call_status == DBUS_METHOD_CALL_SUCCESS ? &value : NULL);
}
+// A callback used to implement CrosRequest*Properties functions.
+void RunCallbackWithDictionaryValueNoStatus(
+ const NetworkPropertiesCallback& callback,
+ const std::string& path,
+ const base::DictionaryValue& value) {
+ callback.Run(path, &value);
+}
+
+// A callback used to implement the error callback for CrosRequest*Properties
+// functions.
+void RunCallbackWithDictionaryValueError(
+ const NetworkPropertiesCallback& callback,
+ const std::string& path,
+ const std::string& error_name,
+ const std::string& error_message) {
+ callback.Run(path, NULL);
+}
+
+
hashimoto 2012/09/24 02:28:56 nit: Remove this blank line.
Greg Spencer (Chromium) 2012/09/24 21:50:54 Done.
// Used as a callback for ShillManagerClient::GetService
void OnGetService(const NetworkPropertiesCallback& callback,
- DBusMethodCallStatus call_status,
const dbus::ObjectPath& service_path) {
- if (call_status == DBUS_METHOD_CALL_SUCCESS) {
- VLOG(1) << "OnGetServiceService: " << service_path.value();
- DBusThreadManager::Get()->GetShillServiceClient()->GetProperties(
- service_path, base::Bind(&RunCallbackWithDictionaryValue,
- callback,
- service_path.value()));
- }
+ VLOG(1) << "OnGetServiceService: " << service_path.value();
+ DBusThreadManager::Get()->GetShillServiceClient()->GetProperties(
+ service_path, base::Bind(&RunCallbackWithDictionaryValue,
+ callback,
+ service_path.value()));
}
// A callback used to call a NetworkOperationCallback on error.
@@ -316,20 +339,23 @@ void CrosSetNetworkServiceProperty(const std::string& service_path,
const base::Value& value) {
DBusThreadManager::Get()->GetShillServiceClient()->SetProperty(
dbus::ObjectPath(service_path), property, value,
- base::Bind(&DoNothing));
+ base::Bind(&DoNothing),
+ base::Bind(&IgnoreErrors));
}
void CrosClearNetworkServiceProperty(const std::string& service_path,
const std::string& property) {
DBusThreadManager::Get()->GetShillServiceClient()->ClearProperty(
- dbus::ObjectPath(service_path), property, base::Bind(&DoNothing));
+ dbus::ObjectPath(service_path), property, base::Bind(&DoNothing),
+ base::Bind(&IgnoreErrors));
}
void CrosSetNetworkDeviceProperty(const std::string& device_path,
const std::string& property,
const base::Value& value) {
DBusThreadManager::Get()->GetShillDeviceClient()->SetProperty(
- dbus::ObjectPath(device_path), property, value, base::Bind(&DoNothing));
+ dbus::ObjectPath(device_path), property, value, base::Bind(&DoNothing),
+ base::Bind(&IgnoreErrors));
}
void CrosSetNetworkIPConfigProperty(const std::string& ipconfig_path,
@@ -337,19 +363,23 @@ void CrosSetNetworkIPConfigProperty(const std::string& ipconfig_path,
const base::Value& value) {
DBusThreadManager::Get()->GetShillIPConfigClient()->SetProperty(
dbus::ObjectPath(ipconfig_path), property, value,
- base::Bind(&DoNothing));
+ base::Bind(&DoNothingWithCallStatus));
}
void CrosSetNetworkManagerProperty(const std::string& property,
const base::Value& value) {
DBusThreadManager::Get()->GetShillManagerClient()->SetProperty(
- property, value, base::Bind(&DoNothing));
+ property, value, base::Bind(&DoNothing),
+ base::Bind(&IgnoreErrors));
}
void CrosDeleteServiceFromProfile(const std::string& profile_path,
const std::string& service_path) {
DBusThreadManager::Get()->GetShillProfileClient()->DeleteEntry(
- dbus::ObjectPath(profile_path), service_path, base::Bind(&DoNothing));
+ dbus::ObjectPath(profile_path),
+ service_path,
+ base::Bind(&DoNothing),
+ base::Bind(&IgnoreErrors));
}
void CrosRequestCellularDataPlanUpdate(const std::string& modem_service_path) {
@@ -423,7 +453,9 @@ void CrosRequestNetworkProfileProperties(
const NetworkPropertiesCallback& callback) {
DBusThreadManager::Get()->GetShillProfileClient()->GetProperties(
dbus::ObjectPath(profile_path),
- base::Bind(&RunCallbackWithDictionaryValue, callback, profile_path));
+ base::Bind(&RunCallbackWithDictionaryValueNoStatus,
+ callback, profile_path),
+ base::Bind(RunCallbackWithDictionaryValueError, callback, profile_path));
hashimoto 2012/09/24 02:28:56 Add '&' for consistency.
Greg Spencer (Chromium) 2012/09/24 21:50:54 Done.
}
void CrosRequestNetworkProfileEntryProperties(
@@ -433,7 +465,10 @@ void CrosRequestNetworkProfileEntryProperties(
DBusThreadManager::Get()->GetShillProfileClient()->GetEntry(
dbus::ObjectPath(profile_path),
profile_entry_path,
- base::Bind(&RunCallbackWithDictionaryValue,
+ base::Bind(&RunCallbackWithDictionaryValueNoStatus,
+ callback,
+ profile_entry_path),
+ base::Bind(RunCallbackWithDictionaryValueError,
hashimoto 2012/09/24 02:28:56 Add '&' for consistency.
Greg Spencer (Chromium) 2012/09/24 21:50:54 Done.
callback,
profile_entry_path));
}
@@ -459,7 +494,8 @@ void CrosRequestHiddenWifiNetworkProperties(
// |properties| and return a new or existing service to OnGetService().
// OnGetService will then call GetProperties which will then call callback.
DBusThreadManager::Get()->GetShillManagerClient()->GetService(
- properties, base::Bind(&OnGetService, callback));
+ properties, base::Bind(&OnGetService, callback),
+ base::Bind(&IgnoreErrors));
}
void CrosRequestVirtualNetworkProperties(
@@ -489,32 +525,38 @@ void CrosRequestVirtualNetworkProperties(
// |properties| and pass a new or existing service to OnGetService().
// OnGetService will then call GetProperties which will then call callback.
DBusThreadManager::Get()->GetShillManagerClient()->GetService(
- properties, base::Bind(&OnGetService, callback));
+ properties, base::Bind(&OnGetService, callback),
+ base::Bind(&IgnoreErrors));
}
void CrosRequestNetworkServiceDisconnect(const std::string& service_path) {
DBusThreadManager::Get()->GetShillServiceClient()->Disconnect(
- dbus::ObjectPath(service_path), base::Bind(&DoNothing));
+ dbus::ObjectPath(service_path), base::Bind(&DoNothing),
+ base::Bind(&IgnoreErrors));
}
void CrosRequestRemoveNetworkService(const std::string& service_path) {
DBusThreadManager::Get()->GetShillServiceClient()->Remove(
- dbus::ObjectPath(service_path), base::Bind(&DoNothing));
+ dbus::ObjectPath(service_path), base::Bind(&DoNothing),
+ base::Bind(&IgnoreErrors));
}
void CrosRequestNetworkScan(const std::string& network_type) {
DBusThreadManager::Get()->GetShillManagerClient()->RequestScan(
- network_type, base::Bind(&DoNothing));
+ network_type, base::Bind(&DoNothing),
+ base::Bind(&IgnoreErrors));
}
void CrosRequestNetworkDeviceEnable(const std::string& network_type,
bool enable) {
if (enable) {
DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology(
- network_type, base::Bind(&DoNothing));
+ network_type, base::Bind(&DoNothing),
+ base::Bind(&IgnoreErrors));
} else {
DBusThreadManager::Get()->GetShillManagerClient()->DisableTechnology(
- network_type, base::Bind(&DoNothing));
+ network_type, base::Bind(&DoNothing),
+ base::Bind(&IgnoreErrors));
}
}
@@ -563,7 +605,7 @@ void CrosRequestChangePin(const std::string& device_path,
void CrosProposeScan(const std::string& device_path) {
DBusThreadManager::Get()->GetShillDeviceClient()->ProposeScan(
- dbus::ObjectPath(device_path), base::Bind(&DoNothing));
+ dbus::ObjectPath(device_path), base::Bind(&DoNothingWithCallStatus));
}
void CrosRequestCellularRegister(const std::string& device_path,
@@ -579,7 +621,8 @@ void CrosRequestCellularRegister(const std::string& device_path,
bool CrosSetOfflineMode(bool offline) {
base::FundamentalValue value(offline);
DBusThreadManager::Get()->GetShillManagerClient()->SetProperty(
- flimflam::kOfflineModeProperty, value, base::Bind(&DoNothing));
+ flimflam::kOfflineModeProperty, value, base::Bind(&DoNothing),
+ base::Bind(&IgnoreErrors));
return true;
}
@@ -667,7 +710,7 @@ bool CrosRemoveIPConfig(const std::string& ipconfig_path) {
void CrosRequestIPConfigRefresh(const std::string& ipconfig_path) {
DBusThreadManager::Get()->GetShillIPConfigClient()->Refresh(
dbus::ObjectPath(ipconfig_path),
- base::Bind(&DoNothing));
+ base::Bind(&DoNothingWithCallStatus));
}
bool CrosGetWifiAccessPoints(WifiAccessPointVector* result) {
@@ -758,7 +801,8 @@ bool CrosGetWifiAccessPoints(WifiAccessPointVector* result) {
void CrosConfigureService(const base::DictionaryValue& properties) {
DBusThreadManager::Get()->GetShillManagerClient()->ConfigureService(
- properties, base::Bind(&DoNothing));
+ properties, base::Bind(&DoNothing),
+ base::Bind(&IgnoreErrors));
}
std::string CrosPrefixLengthToNetmask(int32 prefix_length) {

Powered by Google App Engine
This is Rietveld 408576698