diff options
23 files changed, 523 insertions, 207 deletions
diff --git a/chrome/browser/chromeos/cros/cros_network_functions.cc b/chrome/browser/chromeos/cros/cros_network_functions.cc index 2765f5f..aff8e27 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" @@ -22,6 +23,8 @@ #include "dbus/object_path.h" #include "third_party/cros_system_api/dbus/service_constants.h" +using base::DoNothing; + namespace chromeos { namespace { @@ -209,7 +212,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, @@ -219,17 +226,32 @@ 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); +} + // 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. @@ -345,20 +367,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, @@ -366,19 +391,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) { @@ -452,7 +481,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)); } void CrosRequestNetworkProfileEntryProperties( @@ -462,7 +493,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, callback, profile_entry_path)); } @@ -488,7 +522,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( @@ -518,32 +553,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)); } } @@ -592,7 +633,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, @@ -608,7 +649,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; } @@ -696,7 +738,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) { @@ -787,7 +829,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) { diff --git a/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc b/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc index 357ff78..8ce527c 100644 --- a/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc +++ b/chrome/browser/chromeos/cros/cros_network_functions_unittest.cc @@ -192,12 +192,22 @@ class CrosNetworkFunctionsTest : public testing::Test { callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_); } + // Handles responses for GetProperties method calls that return + // errors in an error callback. + void OnGetPropertiesWithoutStatus( + const dbus::ObjectPath& path, + const ShillClientHelper::DictionaryValueCallbackWithoutStatus& callback, + const ShillClientHelper::ErrorCallback& error_callback) { + callback.Run(*dictionary_value_result_); + } + // Handles responses for GetEntry method calls. void OnGetEntry( const dbus::ObjectPath& profile_path, const std::string& entry_path, - const ShillClientHelper::DictionaryValueCallback& callback) { - callback.Run(DBUS_METHOD_CALL_SUCCESS, *dictionary_value_result_); + const ShillClientHelper::DictionaryValueCallbackWithoutStatus& callback, + const ShillClientHelper::ErrorCallback& error_callback) { + callback.Run(*dictionary_value_result_); } // Mock NetworkOperationCallback. @@ -244,7 +254,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkServiceProperty) { value.SetString(key2, string2); EXPECT_CALL(*mock_service_client_, SetProperty(dbus::ObjectPath(service_path), property, - IsEqualTo(&value), _)).Times(1); + IsEqualTo(&value), _, _)).Times(1); CrosSetNetworkServiceProperty(service_path, property, value); } @@ -253,7 +263,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosClearNetworkServiceProperty) { const std::string service_path = "/"; const std::string property = "property"; EXPECT_CALL(*mock_service_client_, - ClearProperty(dbus::ObjectPath(service_path), property, _)) + ClearProperty(dbus::ObjectPath(service_path), property, _, _)) .Times(1); CrosClearNetworkServiceProperty(service_path, property); @@ -266,7 +276,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkDeviceProperty) { const base::FundamentalValue value(kBool); EXPECT_CALL(*mock_device_client_, SetProperty(dbus::ObjectPath(device_path), StrEq(property), - IsEqualTo(&value), _)).Times(1); + IsEqualTo(&value), _, _)).Times(1); CrosSetNetworkDeviceProperty(device_path, property, value); } @@ -286,7 +296,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosSetNetworkManagerProperty) { const std::string property = "property"; const base::StringValue value("string"); EXPECT_CALL(*mock_manager_client_, - SetProperty(property, IsEqualTo(&value), _)).Times(1); + SetProperty(property, IsEqualTo(&value), _, _)).Times(1); CrosSetNetworkManagerProperty(property, value); } @@ -295,7 +305,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosDeleteServiceFromProfile) { const std::string profile_path("/profile/path"); const std::string service_path("/service/path"); EXPECT_CALL(*mock_profile_client_, - DeleteEntry(dbus::ObjectPath(profile_path), service_path, _)) + DeleteEntry(dbus::ObjectPath(profile_path), service_path, _, _)) .Times(1); CrosDeleteServiceFromProfile(profile_path, service_path); } @@ -311,6 +321,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosMonitorNetworkManagerProperties) { const std::string key = "key"; const int kValue = 42; const base::FundamentalValue value(kValue); + // Start monitoring. ShillPropertyChangedObserver* observer = NULL; EXPECT_CALL(*mock_manager_client_, AddPropertyChangedObserver(_)) @@ -620,9 +631,11 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileProperties) { result.SetWithoutPathExpansion(key2, base::Value::CreateStringValue(value2)); // Set expectations. dictionary_value_result_ = &result; - EXPECT_CALL(*mock_profile_client_, - GetProperties(dbus::ObjectPath(profile_path), _)).WillOnce( - Invoke(this, &CrosNetworkFunctionsTest::OnGetProperties)); + EXPECT_CALL( + *mock_profile_client_, + GetProperties(dbus::ObjectPath(profile_path), _, _)).WillOnce( + Invoke(this, + &CrosNetworkFunctionsTest::OnGetPropertiesWithoutStatus)); CrosRequestNetworkProfileProperties( profile_path, @@ -643,7 +656,8 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkProfileEntryProperties) { // Set expectations. dictionary_value_result_ = &result; EXPECT_CALL(*mock_profile_client_, - GetEntry(dbus::ObjectPath(profile_path), profile_entry_path, _)) + GetEntry(dbus::ObjectPath(profile_path), + profile_entry_path, _, _)) .WillOnce(Invoke(this, &CrosNetworkFunctionsTest::OnGetEntry)); CrosRequestNetworkProfileEntryProperties( @@ -680,8 +694,8 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestHiddenWifiNetworkProperties) { base::Value::CreateStringValue(security)); // Set expectations. const dbus::ObjectPath service_path("/service/path"); - ObjectPathDBusMethodCallback callback; - EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _)) + ObjectPathCallback callback; + EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _, _)) .WillOnce(SaveArg<1>(&callback)); EXPECT_CALL(*mock_service_client_, GetProperties(service_path, _)).WillOnce( @@ -693,7 +707,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestHiddenWifiNetworkProperties) { MockNetworkPropertiesCallback::CreateCallback(service_path.value(), result)); // Run callback to invoke GetProperties. - callback.Run(DBUS_METHOD_CALL_SUCCESS, service_path); + callback.Run(service_path); } TEST_F(CrosNetworkFunctionsTest, CrosRequestVirtualNetworkProperties) { @@ -728,8 +742,8 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestVirtualNetworkProperties) { // Set expectations. const dbus::ObjectPath service_path("/service/path"); - ObjectPathDBusMethodCallback callback; - EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _)) + ObjectPathCallback callback; + EXPECT_CALL(*mock_manager_client_, GetService(IsEqualTo(&properties), _, _)) .WillOnce(SaveArg<1>(&callback)); EXPECT_CALL(*mock_service_client_, GetProperties(service_path, _)).WillOnce( @@ -741,38 +755,38 @@ TEST_F(CrosNetworkFunctionsTest, CrosRequestVirtualNetworkProperties) { MockNetworkPropertiesCallback::CreateCallback(service_path.value(), result)); // Run callback to invoke GetProperties. - callback.Run(DBUS_METHOD_CALL_SUCCESS, service_path); + callback.Run(service_path); } TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkServiceDisconnect) { const std::string service_path = "/service/path"; EXPECT_CALL(*mock_service_client_, - Disconnect(dbus::ObjectPath(service_path), _)).Times(1); + Disconnect(dbus::ObjectPath(service_path), _, _)).Times(1); CrosRequestNetworkServiceDisconnect(service_path); } TEST_F(CrosNetworkFunctionsTest, CrosRequestRemoveNetworkService) { const std::string service_path = "/service/path"; EXPECT_CALL(*mock_service_client_, - Remove(dbus::ObjectPath(service_path), _)).Times(1); + Remove(dbus::ObjectPath(service_path), _, _)).Times(1); CrosRequestRemoveNetworkService(service_path); } TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkScan) { EXPECT_CALL(*mock_manager_client_, - RequestScan(flimflam::kTypeWifi, _)).Times(1); + RequestScan(flimflam::kTypeWifi, _, _)).Times(1); CrosRequestNetworkScan(flimflam::kTypeWifi); } TEST_F(CrosNetworkFunctionsTest, CrosRequestNetworkDeviceEnable) { const bool kEnable = true; EXPECT_CALL(*mock_manager_client_, - EnableTechnology(flimflam::kTypeWifi, _)).Times(1); + EnableTechnology(flimflam::kTypeWifi, _, _)).Times(1); CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kEnable); const bool kDisable = false; EXPECT_CALL(*mock_manager_client_, - DisableTechnology(flimflam::kTypeWifi, _)).Times(1); + DisableTechnology(flimflam::kTypeWifi, _, _)).Times(1); CrosRequestNetworkDeviceEnable(flimflam::kTypeWifi, kDisable); } @@ -883,7 +897,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosSetOfflineMode) { const bool kOffline = true; const base::FundamentalValue value(kOffline); EXPECT_CALL(*mock_manager_client_, SetProperty( - flimflam::kOfflineModeProperty, IsEqualTo(&value), _)).Times(1); + flimflam::kOfflineModeProperty, IsEqualTo(&value), _, _)).Times(1); CrosSetOfflineMode(kOffline); } @@ -1060,7 +1074,7 @@ TEST_F(CrosNetworkFunctionsTest, CrosConfigureService) { base::DictionaryValue value; value.SetString(key1, string1); value.SetString(key2, string2); - EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _)) + EXPECT_CALL(*mock_manager_client_, ConfigureService(IsEqualTo(&value), _, _)) .Times(1); CrosConfigureService(value); } diff --git a/chromeos/dbus/dbus_method_call_status.h b/chromeos/dbus/dbus_method_call_status.h index a45611e..29fa84f 100644 --- a/chromeos/dbus/dbus_method_call_status.h +++ b/chromeos/dbus/dbus_method_call_status.h @@ -39,6 +39,10 @@ typedef base::Callback<void( DBusMethodCallStatus call_status, const dbus::ObjectPath& result)> ObjectPathDBusMethodCallback; +// A callback to handle responses of methods returning a ObjectPath value that +// doens't get call status. +typedef base::Callback<void(const dbus::ObjectPath& result)> ObjectPathCallback; + } // namespace chromeos #endif // CHROMEOS_DBUS_DBUS_METHOD_CALL_STATUS_H_ diff --git a/chromeos/dbus/mock_shill_device_client.h b/chromeos/dbus/mock_shill_device_client.h index 1f0533a..fa0372c 100644 --- a/chromeos/dbus/mock_shill_device_client.h +++ b/chromeos/dbus/mock_shill_device_client.h @@ -30,10 +30,11 @@ class MockShillDeviceClient : public ShillDeviceClient { base::DictionaryValue*(const dbus::ObjectPath& device_path)); MOCK_METHOD2(ProposeScan, void(const dbus::ObjectPath& device_path, const VoidDBusMethodCallback& callback)); - MOCK_METHOD4(SetProperty, void(const dbus::ObjectPath& device_path, + MOCK_METHOD5(SetProperty, void(const dbus::ObjectPath& device_path, const std::string& name, const base::Value& value, - const VoidDBusMethodCallback& callback)); + const base::Closure& callback, + const ErrorCallback& error_callback)); MOCK_METHOD3(ClearProperty, void(const dbus::ObjectPath& device_path, const std::string& name, const VoidDBusMethodCallback& callback)); diff --git a/chromeos/dbus/mock_shill_manager_client.h b/chromeos/dbus/mock_shill_manager_client.h index e8b4c8b..b022520 100644 --- a/chromeos/dbus/mock_shill_manager_client.h +++ b/chromeos/dbus/mock_shill_manager_client.h @@ -23,19 +23,25 @@ class MockShillManagerClient : public ShillManagerClient { void(ShillPropertyChangedObserver* observer)); MOCK_METHOD1(GetProperties, void(const DictionaryValueCallback& callback)); MOCK_METHOD0(CallGetPropertiesAndBlock, base::DictionaryValue*()); - MOCK_METHOD3(SetProperty, void(const std::string& name, + MOCK_METHOD4(SetProperty, void(const std::string& name, const base::Value& value, - const VoidDBusMethodCallback& callback)); - MOCK_METHOD2(RequestScan, void(const std::string& type, - const VoidDBusMethodCallback& callback)); - MOCK_METHOD2(EnableTechnology, void(const std::string& type, - const VoidDBusMethodCallback& callback)); - MOCK_METHOD2(DisableTechnology, void(const std::string& type, - const VoidDBusMethodCallback& callback)); - MOCK_METHOD2(ConfigureService, void(const base::DictionaryValue& properties, - const VoidDBusMethodCallback& callback)); - MOCK_METHOD2(GetService, void(const base::DictionaryValue& properties, - const ObjectPathDBusMethodCallback& callback)); + const base::Closure& callback, + const ErrorCallback& error_callback)); + MOCK_METHOD3(RequestScan, void(const std::string& type, + const base::Closure& callback, + const ErrorCallback& error_callback)); + MOCK_METHOD3(EnableTechnology, void(const std::string& type, + const base::Closure& callback, + const ErrorCallback& error_callback)); + MOCK_METHOD3(DisableTechnology, void(const std::string& type, + const base::Closure& callback, + const ErrorCallback& error_callback)); + MOCK_METHOD3(ConfigureService, void(const base::DictionaryValue& properties, + const base::Closure& callback, + const ErrorCallback& error_callback)); + MOCK_METHOD3(GetService, void(const base::DictionaryValue& properties, + const ObjectPathCallback& callback, + const ErrorCallback& error_callback)); }; } // namespace chromeos diff --git a/chromeos/dbus/mock_shill_profile_client.h b/chromeos/dbus/mock_shill_profile_client.h index 0ce9221..078bb60 100644 --- a/chromeos/dbus/mock_shill_profile_client.h +++ b/chromeos/dbus/mock_shill_profile_client.h @@ -26,14 +26,19 @@ class MockShillProfileClient : public ShillProfileClient { MOCK_METHOD2(RemovePropertyChangedObserver, void(const dbus::ObjectPath& profile_path, ShillPropertyChangedObserver* observer)); - MOCK_METHOD2(GetProperties, void(const dbus::ObjectPath& profile_path, - const DictionaryValueCallback& callback)); - MOCK_METHOD3(GetEntry, void(const dbus::ObjectPath& profile_path, - const std::string& entry_path, - const DictionaryValueCallback& callback)); - MOCK_METHOD3(DeleteEntry, void(const dbus::ObjectPath& profile_path, + MOCK_METHOD3(GetProperties, void( + const dbus::ObjectPath& profile_path, + const DictionaryValueCallbackWithoutStatus& callback, + const ErrorCallback& error_callback)); + MOCK_METHOD4(GetEntry, void( + const dbus::ObjectPath& profile_path, + const std::string& entry_path, + const DictionaryValueCallbackWithoutStatus& callback, + const ErrorCallback& error_callback)); + MOCK_METHOD4(DeleteEntry, void(const dbus::ObjectPath& profile_path, const std::string& entry_path, - const VoidDBusMethodCallback& callback)); + const base::Closure& callback, + const ErrorCallback& error_callback)); }; } // namespace chromeos diff --git a/chromeos/dbus/mock_shill_service_client.h b/chromeos/dbus/mock_shill_service_client.h index d8dfb0b..12d14bb 100644 --- a/chromeos/dbus/mock_shill_service_client.h +++ b/chromeos/dbus/mock_shill_service_client.h @@ -26,24 +26,29 @@ class MockShillServiceClient : public ShillServiceClient { ShillPropertyChangedObserver* observer)); MOCK_METHOD2(GetProperties, void(const dbus::ObjectPath& service_path, const DictionaryValueCallback& callback)); - MOCK_METHOD4(SetProperty, void(const dbus::ObjectPath& service_path, + MOCK_METHOD5(SetProperty, void(const dbus::ObjectPath& service_path, const std::string& name, const base::Value& value, - const VoidDBusMethodCallback& callback)); - MOCK_METHOD3(ClearProperty, void(const dbus::ObjectPath& service_path, + const base::Closure& callback, + const ErrorCallback& error_callback)); + MOCK_METHOD4(ClearProperty, void(const dbus::ObjectPath& service_path, const std::string& name, - const VoidDBusMethodCallback& callback)); + const base::Closure& callback, + const ErrorCallback& error_callback)); MOCK_METHOD3(Connect, void(const dbus::ObjectPath& service_path, const base::Closure& callback, const ErrorCallback& error_callback)); - MOCK_METHOD2(Disconnect, void(const dbus::ObjectPath& service_path, - const VoidDBusMethodCallback& callback)); - MOCK_METHOD2(Remove, void(const dbus::ObjectPath& service_path, - const VoidDBusMethodCallback& callback)); - MOCK_METHOD3(ActivateCellularModem, + MOCK_METHOD3(Disconnect, void(const dbus::ObjectPath& service_path, + const base::Closure& callback, + const ErrorCallback& error_callback)); + MOCK_METHOD3(Remove, void(const dbus::ObjectPath& service_path, + const base::Closure& callback, + const ErrorCallback& error_callback)); + MOCK_METHOD4(ActivateCellularModem, void(const dbus::ObjectPath& service_path, const std::string& carrier, - const VoidDBusMethodCallback& callback)); + const base::Closure& callback, + const ErrorCallback& error_callback)); MOCK_METHOD2(CallActivateCellularModemAndBlock, bool(const dbus::ObjectPath& service_path, const std::string& carrier)); diff --git a/chromeos/dbus/shill_client_helper.cc b/chromeos/dbus/shill_client_helper.cc index 7bc7ef0..f6d0fdc 100644 --- a/chromeos/dbus/shill_client_helper.cc +++ b/chromeos/dbus/shill_client_helper.cc @@ -13,6 +13,13 @@ namespace chromeos { +namespace { + +const char kInvalidResponseErrorName[] = ""; // No error name. +const char kInvalidResponseErrorMessage[] = "Invalid response."; + +} // namespace + ShillClientHelper::ShillClientHelper(dbus::Bus* bus, dbus::ObjectProxy* proxy) : blocking_method_caller_(bus, proxy), @@ -63,6 +70,22 @@ void ShillClientHelper::CallObjectPathMethod( callback)); } +void ShillClientHelper::CallObjectPathMethodWithErrorCallback( + dbus::MethodCall* method_call, + const ObjectPathCallback& callback, + const ErrorCallback& error_callback) { + proxy_->CallMethodWithErrorCallback( + method_call, + dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, + base::Bind(&ShillClientHelper::OnObjectPathMethodWithoutStatus, + weak_ptr_factory_.GetWeakPtr(), + callback, + error_callback), + base::Bind(&ShillClientHelper::OnError, + weak_ptr_factory_.GetWeakPtr(), + error_callback)); +} + void ShillClientHelper::CallDictionaryValueMethod( dbus::MethodCall* method_call, const DictionaryValueCallback& callback) { @@ -233,6 +256,23 @@ void ShillClientHelper::OnObjectPathMethod( callback.Run(DBUS_METHOD_CALL_SUCCESS, result); } +void ShillClientHelper::OnObjectPathMethodWithoutStatus( + const ObjectPathCallback& callback, + const ErrorCallback& error_callback, + dbus::Response* response) { + if (!response) { + error_callback.Run(kInvalidResponseErrorName, kInvalidResponseErrorMessage); + return; + } + dbus::MessageReader reader(response); + dbus::ObjectPath result; + if (!reader.PopObjectPath(&result)) { + error_callback.Run(kInvalidResponseErrorName, kInvalidResponseErrorMessage); + return; + } + callback.Run(result); +} + void ShillClientHelper::OnDictionaryValueMethod( const DictionaryValueCallback& callback, dbus::Response* response) { @@ -266,9 +306,7 @@ void ShillClientHelper::OnDictionaryValueMethodWithErrorCallback( scoped_ptr<base::Value> value(dbus::PopDataAsValue(&reader)); base::DictionaryValue* result = NULL; if (!value.get() || !value->GetAsDictionary(&result)) { - const std::string error_name; // No error name. - const std::string error_message = "Invalid response."; - error_callback.Run(error_name, error_message); + error_callback.Run(kInvalidResponseErrorName, kInvalidResponseErrorMessage); return; } callback.Run(*result); diff --git a/chromeos/dbus/shill_client_helper.h b/chromeos/dbus/shill_client_helper.h index a0225d0..8782d90 100644 --- a/chromeos/dbus/shill_client_helper.h +++ b/chromeos/dbus/shill_client_helper.h @@ -79,6 +79,12 @@ class ShillClientHelper { void CallObjectPathMethod(dbus::MethodCall* method_call, const ObjectPathDBusMethodCallback& callback); + // Calls a method with an object path result where there is an error callback. + void CallObjectPathMethodWithErrorCallback( + dbus::MethodCall* method_call, + const ObjectPathCallback& callback, + const ErrorCallback& error_callback); + // Calls a method with a dictionary value result. void CallDictionaryValueMethod(dbus::MethodCall* method_call, const DictionaryValueCallback& callback); @@ -128,6 +134,12 @@ class ShillClientHelper { void OnObjectPathMethod(const ObjectPathDBusMethodCallback& callback, dbus::Response* response); + // Handles responses for methods with ObjectPath results. + void OnObjectPathMethodWithoutStatus( + const ObjectPathCallback& callback, + const ErrorCallback& error_callback, + dbus::Response* response); + // Handles responses for methods with DictionaryValue results. void OnDictionaryValueMethod(const DictionaryValueCallback& callback, dbus::Response* response); diff --git a/chromeos/dbus/shill_client_unittest_base.cc b/chromeos/dbus/shill_client_unittest_base.cc index 2a7eb3c..1907cb0 100644 --- a/chromeos/dbus/shill_client_unittest_base.cc +++ b/chromeos/dbus/shill_client_unittest_base.cc @@ -226,11 +226,16 @@ void ShillClientUnittestBase::ExpectObjectPathResult( } // static -void ShillClientUnittestBase::ExpectDictionaryValueResult( +void ShillClientUnittestBase::ExpectObjectPathResultWithoutStatus( + const dbus::ObjectPath& expected_result, + const dbus::ObjectPath& result) { + EXPECT_EQ(expected_result, result); +} + +// static +void ShillClientUnittestBase::ExpectDictionaryValueResultWithoutStatus( const base::DictionaryValue* expected_result, - DBusMethodCallStatus call_status, const base::DictionaryValue& result) { - EXPECT_EQ(DBUS_METHOD_CALL_SUCCESS, call_status); std::string expected_result_string; base::JSONWriter::Write(expected_result, &expected_result_string); std::string result_string; @@ -238,6 +243,15 @@ void ShillClientUnittestBase::ExpectDictionaryValueResult( EXPECT_EQ(expected_result_string, result_string); } +// static +void ShillClientUnittestBase::ExpectDictionaryValueResult( + const base::DictionaryValue* expected_result, + DBusMethodCallStatus call_status, + const base::DictionaryValue& result) { + EXPECT_EQ(DBUS_METHOD_CALL_SUCCESS, call_status); + ExpectDictionaryValueResultWithoutStatus(expected_result, result); +} + void ShillClientUnittestBase::OnConnectToSignal( const std::string& interface_name, const std::string& signal_name, diff --git a/chromeos/dbus/shill_client_unittest_base.h b/chromeos/dbus/shill_client_unittest_base.h index 22bfb6f..96f4e93 100644 --- a/chromeos/dbus/shill_client_unittest_base.h +++ b/chromeos/dbus/shill_client_unittest_base.h @@ -140,11 +140,21 @@ class ShillClientUnittestBase : public testing::Test { const dbus::ObjectPath& result); // Checks the result and expects the call status to be SUCCESS. + static void ExpectObjectPathResultWithoutStatus( + const dbus::ObjectPath& expected_result, + const dbus::ObjectPath& result); + + // Checks the result and expects the call status to be SUCCESS. static void ExpectDictionaryValueResult( const base::DictionaryValue* expected_result, DBusMethodCallStatus call_status, const base::DictionaryValue& result); + // Expects the |expected_result| to match the |result|. + static void ExpectDictionaryValueResultWithoutStatus( + const base::DictionaryValue* expected_result, + const base::DictionaryValue& result); + // A message loop to emulate asynchronous behavior. MessageLoop message_loop_; // The mock bus. diff --git a/chromeos/dbus/shill_device_client.cc b/chromeos/dbus/shill_device_client.cc index 9e29101..b2cc011 100644 --- a/chromeos/dbus/shill_device_client.cc +++ b/chromeos/dbus/shill_device_client.cc @@ -67,13 +67,16 @@ class ShillDeviceClientImpl : public ShillDeviceClient { virtual void SetProperty(const dbus::ObjectPath& device_path, const std::string& name, const base::Value& value, - const VoidDBusMethodCallback& callback) OVERRIDE { + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { dbus::MethodCall method_call(flimflam::kFlimflamDeviceInterface, flimflam::kSetPropertyFunction); dbus::MessageWriter writer(&method_call); writer.AppendString(name); ShillClientHelper::AppendValueDataAsVariant(&writer, value); - GetHelper(device_path)->CallVoidMethod(&method_call, callback); + GetHelper(device_path)->CallVoidMethodWithErrorCallback(&method_call, + callback, + error_callback); } virtual void ClearProperty(const dbus::ObjectPath& device_path, @@ -281,14 +284,20 @@ class ShillDeviceClientStubImpl : public ShillDeviceClient { virtual void SetProperty(const dbus::ObjectPath& device_path, const std::string& name, const base::Value& value, - const VoidDBusMethodCallback& callback) OVERRIDE { + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { base::DictionaryValue* device_properties = NULL; if (!stub_devices_.GetDictionary(device_path.value(), &device_properties)) { - PostVoidCallback(callback, DBUS_METHOD_CALL_FAILURE); + std::string error_name("org.chromium.flimflam.Error.Failure"); + std::string error_message("Failed"); + MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(error_callback, + error_name, + error_message)); return; } device_properties->Set(name, value.DeepCopy()); - PostVoidCallback(callback, DBUS_METHOD_CALL_SUCCESS); + MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual void ClearProperty(const dbus::ObjectPath& device_path, diff --git a/chromeos/dbus/shill_device_client.h b/chromeos/dbus/shill_device_client.h index c4e808c..7ac7e20 100644 --- a/chromeos/dbus/shill_device_client.h +++ b/chromeos/dbus/shill_device_client.h @@ -81,7 +81,8 @@ class CHROMEOS_EXPORT ShillDeviceClient { virtual void SetProperty(const dbus::ObjectPath& device_path, const std::string& name, const base::Value& value, - const VoidDBusMethodCallback& callback) = 0; + const base::Closure& callback, + const ErrorCallback& error_callback) = 0; // Calls ClearProperty method. // |callback| is called after the method call finishes. diff --git a/chromeos/dbus/shill_device_client_unittest.cc b/chromeos/dbus/shill_device_client_unittest.cc index ef85d20..8f504f5 100644 --- a/chromeos/dbus/shill_device_client_unittest.cc +++ b/chromeos/dbus/shill_device_client_unittest.cc @@ -196,10 +196,16 @@ TEST_F(ShillDeviceClientTest, SetProperty) { &value), response.get()); // Call method. + MockClosure mock_closure; + MockErrorCallback mock_error_callback; client_->SetProperty(dbus::ObjectPath(kExampleDevicePath), flimflam::kCellularAllowRoamingProperty, value, - base::Bind(&ExpectNoResultValue)); + mock_closure.GetCallback(), + mock_error_callback.GetCallback()); + EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Run the message loop. message_loop_.RunAllPending(); } @@ -272,6 +278,7 @@ TEST_F(ShillDeviceClientTest, RequirePin) { kRequired), response.get()); EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); // Call method. client_->RequirePin(dbus::ObjectPath(kExampleDevicePath), kPin, @@ -295,6 +302,8 @@ TEST_F(ShillDeviceClientTest, EnterPin) { kPin), response.get()); EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Call method. client_->EnterPin(dbus::ObjectPath(kExampleDevicePath), kPin, @@ -317,6 +326,8 @@ TEST_F(ShillDeviceClientTest, UnblockPin) { base::Bind(&ExpectTwoStringArguments, kPuk, kPin), response.get()); EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Call method. client_->UnblockPin(dbus::ObjectPath(kExampleDevicePath), kPuk, @@ -342,6 +353,8 @@ TEST_F(ShillDeviceClientTest, ChangePin) { kNewPin), response.get()); EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Call method. client_->ChangePin(dbus::ObjectPath(kExampleDevicePath), kOldPin, @@ -364,6 +377,8 @@ TEST_F(ShillDeviceClientTest, Register) { base::Bind(&ExpectStringArgument, kNetworkId), response.get()); EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Call method. client_->Register(dbus::ObjectPath(kExampleDevicePath), kNetworkId, diff --git a/chromeos/dbus/shill_manager_client.cc b/chromeos/dbus/shill_manager_client.cc index deb560b..08f163b 100644 --- a/chromeos/dbus/shill_manager_client.cc +++ b/chromeos/dbus/shill_manager_client.cc @@ -84,63 +84,81 @@ class ShillManagerClientImpl : public ShillManagerClient { virtual void SetProperty(const std::string& name, const base::Value& value, - const VoidDBusMethodCallback& callback) OVERRIDE { + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, flimflam::kSetPropertyFunction); dbus::MessageWriter writer(&method_call); writer.AppendString(name); ShillClientHelper::AppendValueDataAsVariant(&writer, value); - helper_.CallVoidMethod(&method_call, callback); + helper_.CallVoidMethodWithErrorCallback(&method_call, + callback, + error_callback); } virtual void RequestScan(const std::string& type, - const VoidDBusMethodCallback& callback) OVERRIDE { + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, flimflam::kRequestScanFunction); dbus::MessageWriter writer(&method_call); writer.AppendString(type); - helper_.CallVoidMethod(&method_call, callback); + helper_.CallVoidMethodWithErrorCallback(&method_call, + callback, + error_callback); } virtual void EnableTechnology( const std::string& type, - const VoidDBusMethodCallback& callback) OVERRIDE { + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, flimflam::kEnableTechnologyFunction); dbus::MessageWriter writer(&method_call); writer.AppendString(type); - helper_.CallVoidMethod(&method_call, callback); + helper_.CallVoidMethodWithErrorCallback(&method_call, + callback, + error_callback); } virtual void DisableTechnology( const std::string& type, - const VoidDBusMethodCallback& callback) OVERRIDE { + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, flimflam::kDisableTechnologyFunction); dbus::MessageWriter writer(&method_call); writer.AppendString(type); - helper_.CallVoidMethod(&method_call, callback); + helper_.CallVoidMethodWithErrorCallback(&method_call, + callback, + error_callback); } virtual void ConfigureService( const base::DictionaryValue& properties, - const VoidDBusMethodCallback& callback) OVERRIDE { + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { DCHECK(AreServicePropertiesValid(properties)); dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, flimflam::kConfigureServiceFunction); dbus::MessageWriter writer(&method_call); AppendServicePropertiesDictionary(&writer, properties); - helper_.CallVoidMethod(&method_call, callback); + helper_.CallVoidMethodWithErrorCallback(&method_call, + callback, + error_callback); } virtual void GetService( const base::DictionaryValue& properties, - const ObjectPathDBusMethodCallback& callback) OVERRIDE { + const ObjectPathCallback& callback, + const ErrorCallback& error_callback) OVERRIDE { dbus::MethodCall method_call(flimflam::kFlimflamManagerInterface, flimflam::kGetServiceFunction); dbus::MessageWriter writer(&method_call); AppendServicePropertiesDictionary(&writer, properties); - helper_.CallObjectPathMethod(&method_call, callback); + helper_.CallObjectPathMethodWithErrorCallback(&method_call, + callback, + error_callback); } private: @@ -191,55 +209,50 @@ class ShillManagerClientStubImpl : public ShillManagerClient { // ShillManagerClient override. virtual void SetProperty(const std::string& name, const base::Value& value, - const VoidDBusMethodCallback& callback) OVERRIDE { + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { stub_properties_.Set(name, value.DeepCopy()); - MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(callback, - DBUS_METHOD_CALL_SUCCESS)); + MessageLoop::current()->PostTask(FROM_HERE, callback); } // ShillManagerClient override. virtual void RequestScan(const std::string& type, - const VoidDBusMethodCallback& callback) OVERRIDE { - MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(callback, - DBUS_METHOD_CALL_SUCCESS)); + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { + MessageLoop::current()->PostTask(FROM_HERE, callback); } // ShillManagerClient override. virtual void EnableTechnology( const std::string& type, - const VoidDBusMethodCallback& callback) OVERRIDE { - MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(callback, - DBUS_METHOD_CALL_SUCCESS)); + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { + MessageLoop::current()->PostTask(FROM_HERE, callback); } // ShillManagerClient override. virtual void DisableTechnology( const std::string& type, - const VoidDBusMethodCallback& callback) OVERRIDE { - MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(callback, - DBUS_METHOD_CALL_SUCCESS)); + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { + MessageLoop::current()->PostTask(FROM_HERE, callback); } // ShillManagerClient override. virtual void ConfigureService( const base::DictionaryValue& properties, - const VoidDBusMethodCallback& callback) OVERRIDE { - MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(callback, - DBUS_METHOD_CALL_SUCCESS)); + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { + MessageLoop::current()->PostTask(FROM_HERE, callback); } // ShillManagerClient override. virtual void GetService( const base::DictionaryValue& properties, - const ObjectPathDBusMethodCallback& callback) OVERRIDE { + const ObjectPathCallback& callback, + const ErrorCallback& error_callback) OVERRIDE { MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, - DBUS_METHOD_CALL_SUCCESS, dbus::ObjectPath())); } diff --git a/chromeos/dbus/shill_manager_client.h b/chromeos/dbus/shill_manager_client.h index 195b230..8034830 100644 --- a/chromeos/dbus/shill_manager_client.h +++ b/chromeos/dbus/shill_manager_client.h @@ -30,6 +30,7 @@ class CHROMEOS_EXPORT ShillManagerClient { public: typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler; typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback; + typedef ShillClientHelper::ErrorCallback ErrorCallback; virtual ~ShillManagerClient(); @@ -62,32 +63,38 @@ class CHROMEOS_EXPORT ShillManagerClient { // |callback| is called after the method call succeeds. virtual void SetProperty(const std::string& name, const base::Value& value, - const VoidDBusMethodCallback& callback) = 0; + const base::Closure& callback, + const ErrorCallback& error_callback) = 0; // Calls RequestScan method. // |callback| is called after the method call succeeds. virtual void RequestScan(const std::string& type, - const VoidDBusMethodCallback& callback) = 0; + const base::Closure& callback, + const ErrorCallback& error_callback) = 0; // Calls EnableTechnology method. // |callback| is called after the method call succeeds. virtual void EnableTechnology(const std::string& type, - const VoidDBusMethodCallback& callback) = 0; + const base::Closure& callback, + const ErrorCallback& error_callback) = 0; // Calls DisableTechnology method. // |callback| is called after the method call succeeds. virtual void DisableTechnology(const std::string& type, - const VoidDBusMethodCallback& callback) = 0; + const base::Closure& callback, + const ErrorCallback& error_callback) = 0; // Calls ConfigureService method. // |callback| is called after the method call succeeds. virtual void ConfigureService(const base::DictionaryValue& properties, - const VoidDBusMethodCallback& callback) = 0; + const base::Closure& callback, + const ErrorCallback& error_callback) = 0; // Calls GetService method. // |callback| is called after the method call succeeds. virtual void GetService(const base::DictionaryValue& properties, - const ObjectPathDBusMethodCallback& callback) = 0; + const ObjectPathCallback& callback, + const ErrorCallback& error_callback) = 0; protected: // Create() should be used instead. diff --git a/chromeos/dbus/shill_manager_client_unittest.cc b/chromeos/dbus/shill_manager_client_unittest.cc index e101bf2..b80d8d9 100644 --- a/chromeos/dbus/shill_manager_client_unittest.cc +++ b/chromeos/dbus/shill_manager_client_unittest.cc @@ -221,9 +221,15 @@ TEST_F(ShillManagerClientTest, SetProperty) { &value), response.get()); // Call method. + MockClosure mock_closure; + MockErrorCallback mock_error_callback; client_->SetProperty(flimflam::kCheckPortalListProperty, value, - base::Bind(&ExpectNoResultValue)); + mock_closure.GetCallback(), + mock_error_callback.GetCallback()); + EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Run the message loop. message_loop_.RunAllPending(); } @@ -236,7 +242,14 @@ TEST_F(ShillManagerClientTest, RequestScan) { base::Bind(&ExpectStringArgument, flimflam::kTypeWifi), response.get()); // Call method. - client_->RequestScan(flimflam::kTypeWifi, base::Bind(&ExpectNoResultValue)); + MockClosure mock_closure; + MockErrorCallback mock_error_callback; + client_->RequestScan(flimflam::kTypeWifi, + mock_closure.GetCallback(), + mock_error_callback.GetCallback()); + EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Run the message loop. message_loop_.RunAllPending(); } @@ -249,8 +262,14 @@ TEST_F(ShillManagerClientTest, EnableTechnology) { base::Bind(&ExpectStringArgument, flimflam::kTypeWifi), response.get()); // Call method. + MockClosure mock_closure; + MockErrorCallback mock_error_callback; client_->EnableTechnology(flimflam::kTypeWifi, - base::Bind(&ExpectNoResultValue)); + mock_closure.GetCallback(), + mock_error_callback.GetCallback()); + EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Run the message loop. message_loop_.RunAllPending(); } @@ -263,8 +282,14 @@ TEST_F(ShillManagerClientTest, DisableTechnology) { base::Bind(&ExpectStringArgument, flimflam::kTypeWifi), response.get()); // Call method. + MockClosure mock_closure; + MockErrorCallback mock_error_callback; client_->DisableTechnology(flimflam::kTypeWifi, - base::Bind(&ExpectNoResultValue)); + mock_closure.GetCallback(), + mock_error_callback.GetCallback()); + EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Run the message loop. message_loop_.RunAllPending(); } @@ -279,7 +304,14 @@ TEST_F(ShillManagerClientTest, ConfigureService) { base::Bind(&ExpectDictionaryValueArgument, arg.get()), response.get()); // Call method. - client_->ConfigureService(*arg, base::Bind(&ExpectNoResultValue)); + MockClosure mock_closure; + MockErrorCallback mock_error_callback; + client_->ConfigureService(*arg, + mock_closure.GetCallback(), + mock_error_callback.GetCallback()); + EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Run the message loop. message_loop_.RunAllPending(); } @@ -297,7 +329,13 @@ TEST_F(ShillManagerClientTest, GetService) { base::Bind(&ExpectDictionaryValueArgument, arg.get()), response.get()); // Call method. - client_->GetService(*arg, base::Bind(&ExpectObjectPathResult, object_path)); + MockErrorCallback mock_error_callback; + client_->GetService(*arg, + base::Bind(&ExpectObjectPathResultWithoutStatus, + object_path), + mock_error_callback.GetCallback()); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Run the message loop. message_loop_.RunAllPending(); } diff --git a/chromeos/dbus/shill_profile_client.cc b/chromeos/dbus/shill_profile_client.cc index 70e5b20..6b2544c 100644 --- a/chromeos/dbus/shill_profile_client.cc +++ b/chromeos/dbus/shill_profile_client.cc @@ -37,14 +37,18 @@ class ShillProfileClientImpl : public ShillProfileClient { ShillPropertyChangedObserver* observer) OVERRIDE { GetHelper(profile_path)->RemovePropertyChangedObserver(observer); } - virtual void GetProperties(const dbus::ObjectPath& profile_path, - const DictionaryValueCallback& callback) OVERRIDE; + virtual void GetProperties( + const dbus::ObjectPath& profile_path, + const DictionaryValueCallbackWithoutStatus& callback, + const ErrorCallback& error_callback) OVERRIDE; virtual void GetEntry(const dbus::ObjectPath& profile_path, const std::string& entry_path, - const DictionaryValueCallback& callback) OVERRIDE; + const DictionaryValueCallbackWithoutStatus& callback, + const ErrorCallback& error_callback) OVERRIDE; virtual void DeleteEntry(const dbus::ObjectPath& profile_path, const std::string& entry_path, - const VoidDBusMethodCallback& callback) OVERRIDE; + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE; private: typedef std::map<std::string, ShillClientHelper*> HelperMap; @@ -81,32 +85,38 @@ ShillClientHelper* ShillProfileClientImpl::GetHelper( void ShillProfileClientImpl::GetProperties( const dbus::ObjectPath& profile_path, - const DictionaryValueCallback& callback) { + const DictionaryValueCallbackWithoutStatus& callback, + const ErrorCallback& error_callback) { dbus::MethodCall method_call(flimflam::kFlimflamProfileInterface, flimflam::kGetPropertiesFunction); - GetHelper(profile_path)->CallDictionaryValueMethod(&method_call, callback); + GetHelper(profile_path)->CallDictionaryValueMethodWithErrorCallback( + &method_call, callback, error_callback); } void ShillProfileClientImpl::GetEntry( const dbus::ObjectPath& profile_path, const std::string& entry_path, - const DictionaryValueCallback& callback) { + const DictionaryValueCallbackWithoutStatus& callback, + const ErrorCallback& error_callback) { dbus::MethodCall method_call(flimflam::kFlimflamProfileInterface, flimflam::kGetEntryFunction); dbus::MessageWriter writer(&method_call); writer.AppendString(entry_path); - GetHelper(profile_path)->CallDictionaryValueMethod(&method_call, callback); + GetHelper(profile_path)->CallDictionaryValueMethodWithErrorCallback( + &method_call, callback, error_callback); } void ShillProfileClientImpl::DeleteEntry( const dbus::ObjectPath& profile_path, const std::string& entry_path, - const VoidDBusMethodCallback& callback) { + const base::Closure& callback, + const ErrorCallback& error_callback) { dbus::MethodCall method_call(flimflam::kFlimflamProfileInterface, flimflam::kDeleteEntryFunction); dbus::MessageWriter writer(&method_call); writer.AppendString(entry_path); - GetHelper(profile_path)->CallVoidMethod(&method_call, callback); + GetHelper(profile_path)->CallVoidMethodWithErrorCallback( + &method_call, callback, error_callback); } // A stub implementation of ShillProfileClient. @@ -126,9 +136,10 @@ class ShillProfileClientStubImpl : public ShillProfileClient { const dbus::ObjectPath& profile_path, ShillPropertyChangedObserver* observer) OVERRIDE {} - // ShillProfileClient override. - virtual void GetProperties(const dbus::ObjectPath& profile_path, - const DictionaryValueCallback& callback) OVERRIDE { + virtual void GetProperties( + const dbus::ObjectPath& profile_path, + const DictionaryValueCallbackWithoutStatus& callback, + const ErrorCallback& error_callback) OVERRIDE { MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ShillProfileClientStubImpl::PassEmptyDictionaryValue, @@ -138,7 +149,8 @@ class ShillProfileClientStubImpl : public ShillProfileClient { virtual void GetEntry(const dbus::ObjectPath& profile_path, const std::string& entry_path, - const DictionaryValueCallback& callback) OVERRIDE { + const DictionaryValueCallbackWithoutStatus& callback, + const ErrorCallback& error_callback) OVERRIDE { MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ShillProfileClientStubImpl::PassEmptyDictionaryValue, @@ -148,16 +160,16 @@ class ShillProfileClientStubImpl : public ShillProfileClient { virtual void DeleteEntry(const dbus::ObjectPath& profile_path, const std::string& entry_path, - const VoidDBusMethodCallback& callback) OVERRIDE { - MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(callback, - DBUS_METHOD_CALL_SUCCESS)); + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { + MessageLoop::current()->PostTask(FROM_HERE, callback); } private: - void PassEmptyDictionaryValue(const DictionaryValueCallback& callback) const { + void PassEmptyDictionaryValue( + const DictionaryValueCallbackWithoutStatus& callback) const { base::DictionaryValue dictionary; - callback.Run(DBUS_METHOD_CALL_SUCCESS, dictionary); + callback.Run(dictionary); } // Note: This should remain the last member so it'll be destroyed and diff --git a/chromeos/dbus/shill_profile_client.h b/chromeos/dbus/shill_profile_client.h index ece50d4..2c45ac7 100644 --- a/chromeos/dbus/shill_profile_client.h +++ b/chromeos/dbus/shill_profile_client.h @@ -37,7 +37,9 @@ class ShillPropertyChangedObserver; class CHROMEOS_EXPORT ShillProfileClient { public: typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler; - typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback; + typedef ShillClientHelper::DictionaryValueCallbackWithoutStatus + DictionaryValueCallbackWithoutStatus; + typedef ShillClientHelper::ErrorCallback ErrorCallback; virtual ~ShillProfileClient(); @@ -58,20 +60,24 @@ class CHROMEOS_EXPORT ShillProfileClient { // Calls GetProperties method. // |callback| is called after the method call succeeds. - virtual void GetProperties(const dbus::ObjectPath& profile_path, - const DictionaryValueCallback& callback) = 0; + virtual void GetProperties( + const dbus::ObjectPath& profile_path, + const DictionaryValueCallbackWithoutStatus& callback, + const ErrorCallback& error_callback) = 0; // Calls GetEntry method. // |callback| is called after the method call succeeds. virtual void GetEntry(const dbus::ObjectPath& profile_path, const std::string& entry_path, - const DictionaryValueCallback& callback) = 0; + const DictionaryValueCallbackWithoutStatus& callback, + const ErrorCallback& error_callback) = 0; // Calls DeleteEntry method. // |callback| is called after the method call succeeds. virtual void DeleteEntry(const dbus::ObjectPath& profile_path, const std::string& entry_path, - const VoidDBusMethodCallback& callback) = 0; + const base::Closure& callback, + const ErrorCallback& error_callback) = 0; protected: // Create() should be used instead. diff --git a/chromeos/dbus/shill_profile_client_unittest.cc b/chromeos/dbus/shill_profile_client_unittest.cc index 5e024a1..47d6cc0 100644 --- a/chromeos/dbus/shill_profile_client_unittest.cc +++ b/chromeos/dbus/shill_profile_client_unittest.cc @@ -116,8 +116,13 @@ TEST_F(ShillProfileClientTest, GetProperties) { base::Bind(&ExpectNoArgument), response.get()); // Call method. + MockErrorCallback error_callback; client_->GetProperties(dbus::ObjectPath(kDefaultProfilePath), - base::Bind(&ExpectDictionaryValueResult, &value)); + base::Bind(&ExpectDictionaryValueResultWithoutStatus, + &value), + error_callback.GetCallback()); + EXPECT_CALL(error_callback, Run(_, _)).Times(0); + // Run the message loop. message_loop_.RunAllPending(); } @@ -145,9 +150,13 @@ TEST_F(ShillProfileClientTest, GetEntry) { base::Bind(&ExpectStringArgument, kExampleEntryPath), response.get()); // Call method. + MockErrorCallback error_callback; client_->GetEntry(dbus::ObjectPath(kDefaultProfilePath), kExampleEntryPath, - base::Bind(&ExpectDictionaryValueResult, &value)); + base::Bind(&ExpectDictionaryValueResultWithoutStatus, + &value), + error_callback.GetCallback()); + EXPECT_CALL(error_callback, Run(_, _)).Times(0); // Run the message loop. message_loop_.RunAllPending(); } @@ -165,9 +174,15 @@ TEST_F(ShillProfileClientTest, DeleteEntry) { base::Bind(&ExpectStringArgument, kExampleEntryPath), response.get()); // Call method. + MockClosure mock_closure; + MockErrorCallback mock_error_callback; client_->DeleteEntry(dbus::ObjectPath(kDefaultProfilePath), kExampleEntryPath, - base::Bind(&ExpectNoResultValue)); + mock_closure.GetCallback(), + mock_error_callback.GetCallback()); + EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Run the message loop. message_loop_.RunAllPending(); } diff --git a/chromeos/dbus/shill_service_client.cc b/chromeos/dbus/shill_service_client.cc index 6a1c617..46fe0f4 100644 --- a/chromeos/dbus/shill_service_client.cc +++ b/chromeos/dbus/shill_service_client.cc @@ -75,23 +75,29 @@ class ShillServiceClientImpl : public ShillServiceClient { virtual void SetProperty(const dbus::ObjectPath& service_path, const std::string& name, const base::Value& value, - const VoidDBusMethodCallback& callback) OVERRIDE { + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, flimflam::kSetPropertyFunction); dbus::MessageWriter writer(&method_call); writer.AppendString(name); ShillClientHelper::AppendValueDataAsVariant(&writer, value); - GetHelper(service_path)->CallVoidMethod(&method_call, callback); + GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, + callback, + error_callback); } virtual void ClearProperty(const dbus::ObjectPath& service_path, const std::string& name, - const VoidDBusMethodCallback& callback) OVERRIDE { + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, flimflam::kClearPropertyFunction); dbus::MessageWriter writer(&method_call); writer.AppendString(name); - GetHelper(service_path)->CallVoidMethod(&method_call, callback); + GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, + callback, + error_callback); } virtual void Connect(const dbus::ObjectPath& service_path, @@ -104,28 +110,37 @@ class ShillServiceClientImpl : public ShillServiceClient { } virtual void Disconnect(const dbus::ObjectPath& service_path, - const VoidDBusMethodCallback& callback) OVERRIDE { + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, flimflam::kDisconnectFunction); - GetHelper(service_path)->CallVoidMethod(&method_call, callback); + GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, + callback, + error_callback); } virtual void Remove(const dbus::ObjectPath& service_path, - const VoidDBusMethodCallback& callback) OVERRIDE { + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, flimflam::kRemoveServiceFunction); - GetHelper(service_path)->CallVoidMethod(&method_call, callback); + GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, + callback, + error_callback); } virtual void ActivateCellularModem( const dbus::ObjectPath& service_path, const std::string& carrier, - const VoidDBusMethodCallback& callback) OVERRIDE { + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { dbus::MethodCall method_call(flimflam::kFlimflamServiceInterface, flimflam::kActivateCellularModemFunction); dbus::MessageWriter writer(&method_call); writer.AppendString(carrier); - GetHelper(service_path)->CallVoidMethod(&method_call, callback); + GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, + callback, + error_callback); } virtual bool CallActivateCellularModemAndBlock( @@ -192,14 +207,16 @@ class ShillServiceClientStubImpl : public ShillServiceClient { virtual void SetProperty(const dbus::ObjectPath& service_path, const std::string& name, const base::Value& value, - const VoidDBusMethodCallback& callback) OVERRIDE { - PostSuccessVoidCallback(callback); + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { + MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual void ClearProperty(const dbus::ObjectPath& service_path, const std::string& name, - const VoidDBusMethodCallback& callback) OVERRIDE { - PostSuccessVoidCallback(callback); + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { + MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual void Connect(const dbus::ObjectPath& service_path, @@ -209,20 +226,23 @@ class ShillServiceClientStubImpl : public ShillServiceClient { } virtual void Disconnect(const dbus::ObjectPath& service_path, - const VoidDBusMethodCallback& callback) OVERRIDE { - PostSuccessVoidCallback(callback); + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { + MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual void Remove(const dbus::ObjectPath& service_path, - const VoidDBusMethodCallback& callback) OVERRIDE { - PostSuccessVoidCallback(callback); + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { + MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual void ActivateCellularModem( const dbus::ObjectPath& service_path, const std::string& carrier, - const VoidDBusMethodCallback& callback) OVERRIDE { - PostSuccessVoidCallback(callback); + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE { + MessageLoop::current()->PostTask(FROM_HERE, callback); } virtual bool CallActivateCellularModemAndBlock( @@ -237,13 +257,6 @@ class ShillServiceClientStubImpl : public ShillServiceClient { callback.Run(DBUS_METHOD_CALL_SUCCESS, dictionary); } - // Posts a task to run a void callback with success status code. - void PostSuccessVoidCallback(const VoidDBusMethodCallback& callback) { - MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(callback, - DBUS_METHOD_CALL_SUCCESS)); - } - // Note: This should remain the last member so it'll be destroyed and // invalidate its weak pointers before any other members are destroyed. base::WeakPtrFactory<ShillServiceClientStubImpl> weak_ptr_factory_; diff --git a/chromeos/dbus/shill_service_client.h b/chromeos/dbus/shill_service_client.h index 7f0cf1c..0e30243 100644 --- a/chromeos/dbus/shill_service_client.h +++ b/chromeos/dbus/shill_service_client.h @@ -66,13 +66,15 @@ class CHROMEOS_EXPORT ShillServiceClient { virtual void SetProperty(const dbus::ObjectPath& service_path, const std::string& name, const base::Value& value, - const VoidDBusMethodCallback& callback) = 0; + const base::Closure& callback, + const ErrorCallback& error_callback) = 0; // Calls ClearProperty method. // |callback| is called after the method call succeeds. virtual void ClearProperty(const dbus::ObjectPath& service_path, const std::string& name, - const VoidDBusMethodCallback& callback) = 0; + const base::Closure& callback, + const ErrorCallback& error_callback) = 0; // Calls Connect method. // |callback| is called after the method call succeeds. @@ -83,19 +85,22 @@ class CHROMEOS_EXPORT ShillServiceClient { // Calls Disconnect method. // |callback| is called after the method call succeeds. virtual void Disconnect(const dbus::ObjectPath& service_path, - const VoidDBusMethodCallback& callback) = 0; + const base::Closure& callback, + const ErrorCallback& error_callback) = 0; // Calls Remove method. // |callback| is called after the method call succeeds. virtual void Remove(const dbus::ObjectPath& service_path, - const VoidDBusMethodCallback& callback) = 0; + const base::Closure& callback, + const ErrorCallback& error_callback) = 0; // Calls ActivateCellularModem method. // |callback| is called after the method call succeeds. virtual void ActivateCellularModem( const dbus::ObjectPath& service_path, const std::string& carrier, - const VoidDBusMethodCallback& callback) = 0; + const base::Closure& callback, + const ErrorCallback& error_callback) = 0; // DEPRECATED DO NOT USE: Calls ActivateCellularModem method and blocks until // the method call finishes. diff --git a/chromeos/dbus/shill_service_client_unittest.cc b/chromeos/dbus/shill_service_client_unittest.cc index c951075..93a9731 100644 --- a/chromeos/dbus/shill_service_client_unittest.cc +++ b/chromeos/dbus/shill_service_client_unittest.cc @@ -124,10 +124,16 @@ TEST_F(ShillServiceClientTest, SetProperty) { &value), response.get()); // Call method. + MockClosure mock_closure; + MockErrorCallback mock_error_callback; client_->SetProperty(dbus::ObjectPath(kExampleServicePath), flimflam::kPassphraseProperty, value, - base::Bind(&ExpectNoResultValue)); + mock_closure.GetCallback(), + mock_error_callback.GetCallback()); + EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Run the message loop. message_loop_.RunAllPending(); } @@ -142,9 +148,15 @@ TEST_F(ShillServiceClientTest, ClearProperty) { flimflam::kPassphraseProperty), response.get()); // Call method. + MockClosure mock_closure; + MockErrorCallback mock_error_callback; client_->ClearProperty(dbus::ObjectPath(kExampleServicePath), flimflam::kPassphraseProperty, - base::Bind(&ExpectNoResultValue)); + mock_closure.GetCallback(), + mock_error_callback.GetCallback()); + EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Run the message loop. message_loop_.RunAllPending(); } @@ -178,8 +190,14 @@ TEST_F(ShillServiceClientTest, Disconnect) { base::Bind(&ExpectNoArgument), response.get()); // Call method. + MockClosure mock_closure; + MockErrorCallback mock_error_callback; client_->Disconnect(dbus::ObjectPath(kExampleServicePath), - base::Bind(&ExpectNoResultValue)); + mock_closure.GetCallback(), + mock_error_callback.GetCallback()); + EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Run the message loop. message_loop_.RunAllPending(); } @@ -193,8 +211,14 @@ TEST_F(ShillServiceClientTest, Remove) { base::Bind(&ExpectNoArgument), response.get()); // Call method. + MockClosure mock_closure; + MockErrorCallback mock_error_callback; client_->Remove(dbus::ObjectPath(kExampleServicePath), - base::Bind(&ExpectNoResultValue)); + mock_closure.GetCallback(), + mock_error_callback.GetCallback()); + EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Run the message loop. message_loop_.RunAllPending(); } @@ -209,9 +233,15 @@ TEST_F(ShillServiceClientTest, ActivateCellularModem) { base::Bind(&ExpectStringArgument, kCarrier), response.get()); // Call method. + MockClosure mock_closure; + MockErrorCallback mock_error_callback; client_->ActivateCellularModem(dbus::ObjectPath(kExampleServicePath), kCarrier, - base::Bind(&ExpectNoResultValue)); + mock_closure.GetCallback(), + mock_error_callback.GetCallback()); + EXPECT_CALL(mock_closure, Run()).Times(1); + EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); + // Run the message loop. message_loop_.RunAllPending(); } |