diff options
author | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-10 16:58:14 +0000 |
---|---|---|
committer | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-10 16:58:14 +0000 |
commit | e9ea1be4ce8faa933acbd656bd3c8bcc65f1971f (patch) | |
tree | 16dd70cb232bac8009e2737072bdc6875beb6cbb /chromeos | |
parent | b1669b714a9dbc6ec4ddbd368979a00ec0f1e462 (diff) | |
download | chromium_src-e9ea1be4ce8faa933acbd656bd3c8bcc65f1971f.zip chromium_src-e9ea1be4ce8faa933acbd656bd3c8bcc65f1971f.tar.gz chromium_src-e9ea1be4ce8faa933acbd656bd3c8bcc65f1971f.tar.bz2 |
Eliminate inconsistent is_null check from Shill stubs
The non-stub code does not do any is_null checks before calling the
callbacks, so the stub code should be consistent.
BUG=None
R=hashimoto@chromium.org, satorux@chromium.org
Review URL: https://codereview.chromium.org/18355007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210867 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/dbus/shill_client_helper.cc | 15 | ||||
-rw-r--r-- | chromeos/dbus/shill_device_client_stub.cc | 38 | ||||
-rw-r--r-- | chromeos/dbus/shill_ipconfig_client_stub.cc | 8 | ||||
-rw-r--r-- | chromeos/dbus/shill_manager_client_stub.cc | 50 | ||||
-rw-r--r-- | chromeos/dbus/shill_profile_client_stub.cc | 2 | ||||
-rw-r--r-- | chromeos/dbus/shill_service_client_stub.cc | 20 | ||||
-rw-r--r-- | chromeos/network/network_connection_handler_unittest.cc | 10 |
7 files changed, 45 insertions, 98 deletions
diff --git a/chromeos/dbus/shill_client_helper.cc b/chromeos/dbus/shill_client_helper.cc index 5e6b69b..83402a8 100644 --- a/chromeos/dbus/shill_client_helper.cc +++ b/chromeos/dbus/shill_client_helper.cc @@ -227,6 +227,7 @@ void ShillClientHelper::MonitorPropertyChangedInternal( void ShillClientHelper::CallVoidMethod( dbus::MethodCall* method_call, const VoidDBusMethodCallback& callback) { + DCHECK(!callback.is_null()); proxy_->CallMethod(method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::Bind(&OnVoidMethod, callback)); @@ -235,6 +236,7 @@ void ShillClientHelper::CallVoidMethod( void ShillClientHelper::CallObjectPathMethod( dbus::MethodCall* method_call, const ObjectPathDBusMethodCallback& callback) { + DCHECK(!callback.is_null()); proxy_->CallMethod(method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::Bind(&OnObjectPathMethod, callback)); @@ -244,6 +246,8 @@ void ShillClientHelper::CallObjectPathMethodWithErrorCallback( dbus::MethodCall* method_call, const ObjectPathCallback& callback, const ErrorCallback& error_callback) { + DCHECK(!callback.is_null()); + DCHECK(!error_callback.is_null()); proxy_->CallMethodWithErrorCallback( method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, @@ -257,6 +261,7 @@ void ShillClientHelper::CallObjectPathMethodWithErrorCallback( void ShillClientHelper::CallDictionaryValueMethod( dbus::MethodCall* method_call, const DictionaryValueCallback& callback) { + DCHECK(!callback.is_null()); proxy_->CallMethod(method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::Bind(&OnDictionaryValueMethod, callback)); @@ -266,6 +271,8 @@ void ShillClientHelper::CallVoidMethodWithErrorCallback( dbus::MethodCall* method_call, const base::Closure& callback, const ErrorCallback& error_callback) { + DCHECK(!callback.is_null()); + DCHECK(!error_callback.is_null()); proxy_->CallMethodWithErrorCallback( method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::Bind(&OnVoidMethodWithErrorCallback, @@ -278,6 +285,8 @@ void ShillClientHelper::CallBooleanMethodWithErrorCallback( dbus::MethodCall* method_call, const BooleanCallback& callback, const ErrorCallback& error_callback) { + DCHECK(!callback.is_null()); + DCHECK(!error_callback.is_null()); proxy_->CallMethodWithErrorCallback( method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::Bind(&OnBooleanMethodWithErrorCallback, @@ -291,6 +300,8 @@ void ShillClientHelper::CallStringMethodWithErrorCallback( dbus::MethodCall* method_call, const StringCallback& callback, const ErrorCallback& error_callback) { + DCHECK(!callback.is_null()); + DCHECK(!error_callback.is_null()); proxy_->CallMethodWithErrorCallback( method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::Bind(&OnStringMethodWithErrorCallback, @@ -304,6 +315,8 @@ void ShillClientHelper::CallDictionaryValueMethodWithErrorCallback( dbus::MethodCall* method_call, const DictionaryValueCallbackWithoutStatus& callback, const ErrorCallback& error_callback) { + DCHECK(!callback.is_null()); + DCHECK(!error_callback.is_null()); proxy_->CallMethodWithErrorCallback( method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::Bind( @@ -318,6 +331,8 @@ void ShillClientHelper::CallListValueMethodWithErrorCallback( dbus::MethodCall* method_call, const ListValueCallback& callback, const ErrorCallback& error_callback) { + DCHECK(!callback.is_null()); + DCHECK(!error_callback.is_null()); proxy_->CallMethodWithErrorCallback( method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, base::Bind( diff --git a/chromeos/dbus/shill_device_client_stub.cc b/chromeos/dbus/shill_device_client_stub.cc index 9d9e799..ba7e1d3e 100644 --- a/chromeos/dbus/shill_device_client_stub.cc +++ b/chromeos/dbus/shill_device_client_stub.cc @@ -55,8 +55,6 @@ void ShillDeviceClientStub::RemovePropertyChangedObserver( void ShillDeviceClientStub::GetProperties( const dbus::ObjectPath& device_path, const DictionaryValueCallback& callback){ - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ShillDeviceClientStub::PassStubDeviceProperties, @@ -79,12 +77,10 @@ void ShillDeviceClientStub::SetProperty(const dbus::ObjectPath& device_path, &device_properties)) { std::string error_name("org.chromium.flimflam.Error.Failure"); std::string error_message("Failed"); - if (!error_callback.is_null()) { - base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(error_callback, - error_name, - error_message)); - } + base::MessageLoop::current()->PostTask(FROM_HERE, + base::Bind(error_callback, + error_name, + error_message)); return; } device_properties->SetWithoutPathExpansion(name, value.DeepCopy()); @@ -92,8 +88,6 @@ void ShillDeviceClientStub::SetProperty(const dbus::ObjectPath& device_path, FROM_HERE, base::Bind(&ShillDeviceClientStub::NotifyObserversPropertyChanged, weak_ptr_factory_.GetWeakPtr(), device_path, name)); - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -115,12 +109,10 @@ void ShillDeviceClientStub::AddIPConfig( const dbus::ObjectPath& device_path, const std::string& method, const ObjectPathDBusMethodCallback& callback){ - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(callback, - DBUS_METHOD_CALL_SUCCESS, - dbus::ObjectPath())); + base::Bind(callback, + DBUS_METHOD_CALL_SUCCESS, + dbus::ObjectPath())); } void ShillDeviceClientStub::RequirePin(const dbus::ObjectPath& device_path, @@ -128,8 +120,6 @@ void ShillDeviceClientStub::RequirePin(const dbus::ObjectPath& device_path, bool require, const base::Closure& callback, const ErrorCallback& error_callback){ - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -137,8 +127,6 @@ void ShillDeviceClientStub::EnterPin(const dbus::ObjectPath& device_path, const std::string& pin, const base::Closure& callback, const ErrorCallback& error_callback){ - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -147,8 +135,6 @@ void ShillDeviceClientStub::UnblockPin(const dbus::ObjectPath& device_path, const std::string& pin, const base::Closure& callback, const ErrorCallback& error_callback){ - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -157,8 +143,6 @@ void ShillDeviceClientStub::ChangePin(const dbus::ObjectPath& device_path, const std::string& new_pin, const base::Closure& callback, const ErrorCallback& error_callback){ - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -166,8 +150,6 @@ void ShillDeviceClientStub::Register(const dbus::ObjectPath& device_path, const std::string& network_id, const base::Closure& callback, const ErrorCallback& error_callback){ - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -175,16 +157,12 @@ void ShillDeviceClientStub::SetCarrier(const dbus::ObjectPath& device_path, const std::string& carrier, const base::Closure& callback, const ErrorCallback& error_callback){ - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, callback); } void ShillDeviceClientStub::Reset(const dbus::ObjectPath& device_path, const base::Closure& callback, const ErrorCallback& error_callback){ - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -280,8 +258,6 @@ void ShillDeviceClientStub::PassStubDeviceProperties( void ShillDeviceClientStub::PostVoidCallback( const VoidDBusMethodCallback& callback, DBusMethodCallStatus status) { - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, status)); } diff --git a/chromeos/dbus/shill_ipconfig_client_stub.cc b/chromeos/dbus/shill_ipconfig_client_stub.cc index a4ce27db..e5dd830 100644 --- a/chromeos/dbus/shill_ipconfig_client_stub.cc +++ b/chromeos/dbus/shill_ipconfig_client_stub.cc @@ -41,8 +41,6 @@ void ShillIPConfigClientStub::Refresh(const dbus::ObjectPath& ipconfig_path, void ShillIPConfigClientStub::GetProperties( const dbus::ObjectPath& ipconfig_path, const DictionaryValueCallback& callback) { - if (callback.is_null()) - return; const base::DictionaryValue* dict = NULL; if (!ipconfigs_.GetDictionaryWithoutPathExpansion(ipconfig_path.value(), &dict)) @@ -64,8 +62,6 @@ void ShillIPConfigClientStub::SetProperty( const std::string& name, const base::Value& value, const VoidDBusMethodCallback& callback) { - if (callback.is_null()) - return; base::DictionaryValue* dict = NULL; if (ipconfigs_.GetDictionaryWithoutPathExpansion(ipconfig_path.value(), &dict)) { @@ -86,16 +82,12 @@ void ShillIPConfigClientStub::ClearProperty( const dbus::ObjectPath& ipconfig_path, const std::string& name, const VoidDBusMethodCallback& callback) { - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); } void ShillIPConfigClientStub::Remove(const dbus::ObjectPath& ipconfig_path, const VoidDBusMethodCallback& callback) { - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); } diff --git a/chromeos/dbus/shill_manager_client_stub.cc b/chromeos/dbus/shill_manager_client_stub.cc index 121cc8e..beacfb7 100644 --- a/chromeos/dbus/shill_manager_client_stub.cc +++ b/chromeos/dbus/shill_manager_client_stub.cc @@ -58,8 +58,6 @@ void ShillManagerClientStub::RemovePropertyChangedObserver( void ShillManagerClientStub::GetProperties( const DictionaryValueCallback& callback) { - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind( &ShillManagerClientStub::PassStubProperties, @@ -69,8 +67,6 @@ void ShillManagerClientStub::GetProperties( void ShillManagerClientStub::GetNetworksForGeolocation( const DictionaryValueCallback& callback) { - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind( &ShillManagerClientStub::PassStubGeoNetworks, @@ -84,8 +80,6 @@ void ShillManagerClientStub::SetProperty(const std::string& name, const ErrorCallback& error_callback) { stub_properties_.SetWithoutPathExpansion(name, value.DeepCopy()); CallNotifyObserversPropertyChanged(name, 0); - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -124,12 +118,10 @@ void ShillManagerClientStub::EnableTechnology( base::ListValue* enabled_list = NULL; if (!stub_properties_.GetListWithoutPathExpansion( flimflam::kEnabledTechnologiesProperty, &enabled_list)) { - if (!error_callback.is_null()) { - base::MessageLoop::current()->PostTask(FROM_HERE, callback); - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(error_callback, "StubError", "Property not found")); - } + base::MessageLoop::current()->PostTask(FROM_HERE, callback); + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(error_callback, "StubError", "Property not found")); return; } if (CommandLine::ForCurrentProcess()->HasSwitch( @@ -152,11 +144,9 @@ void ShillManagerClientStub::DisableTechnology( base::ListValue* enabled_list = NULL; if (!stub_properties_.GetListWithoutPathExpansion( flimflam::kEnabledTechnologiesProperty, &enabled_list)) { - if (!error_callback.is_null()) { - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(error_callback, "StubError", "Property not found")); - } + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(error_callback, "StubError", "Property not found")); return; } if (CommandLine::ForCurrentProcess()->HasSwitch( @@ -186,10 +176,8 @@ void ShillManagerClientStub::ConfigureService( LOG(ERROR) << "ConfigureService requies GUID and Type to be defined"; // If the properties aren't filled out completely, then just return an empty // object path. - if (!callback.is_null()) { - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(callback, dbus::ObjectPath())); - } + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(callback, dbus::ObjectPath())); return; } @@ -233,10 +221,8 @@ void ShillManagerClientStub::ConfigureService( AddService(profile_path, service_path); } - if (!callback.is_null()) { - base::MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(callback, dbus::ObjectPath(service_path))); - } + base::MessageLoop::current()->PostTask( + FROM_HERE, base::Bind(callback, dbus::ObjectPath(service_path))); } void ShillManagerClientStub::ConfigureServiceForProfile( @@ -256,8 +242,6 @@ void ShillManagerClientStub::GetService( const base::DictionaryValue& properties, const ObjectPathCallback& callback, const ErrorCallback& error_callback) { - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, dbus::ObjectPath())); } @@ -266,8 +250,6 @@ void ShillManagerClientStub::VerifyDestination( const VerificationProperties& properties, const BooleanCallback& callback, const ErrorCallback& error_callback) { - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, true)); } @@ -276,8 +258,6 @@ void ShillManagerClientStub::VerifyAndEncryptCredentials( const std::string& service_path, const StringCallback& callback, const ErrorCallback& error_callback) { - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(callback, "encrypted_credentials")); } @@ -287,8 +267,6 @@ void ShillManagerClientStub::VerifyAndEncryptData( const std::string& data, const StringCallback& callback, const ErrorCallback& error_callback) { - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, "encrypted_data")); } @@ -572,8 +550,7 @@ void ShillManagerClientStub::SetTechnologyEnabled( enabled_list->Remove(base::StringValue(type), NULL); CallNotifyObserversPropertyChanged( flimflam::kEnabledTechnologiesProperty, 0 /* already delayed */); - if (!callback.is_null()) - base::MessageLoop::current()->PostTask(FROM_HERE, callback); + base::MessageLoop::current()->PostTask(FROM_HERE, callback); // May affect available services CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0); CallNotifyObserversPropertyChanged(flimflam::kServiceWatchListProperty, 0); @@ -619,8 +596,7 @@ void ShillManagerClientStub::ScanCompleted(const std::string& device_path, CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0); CallNotifyObserversPropertyChanged(flimflam::kServiceWatchListProperty, 0); - if (!callback.is_null()) - base::MessageLoop::current()->PostTask(FROM_HERE, callback); + base::MessageLoop::current()->PostTask(FROM_HERE, callback); } } // namespace chromeos diff --git a/chromeos/dbus/shill_profile_client_stub.cc b/chromeos/dbus/shill_profile_client_stub.cc index c3cdf32..aadae40 100644 --- a/chromeos/dbus/shill_profile_client_stub.cc +++ b/chromeos/dbus/shill_profile_client_stub.cc @@ -33,8 +33,6 @@ const char kSharedProfilePath[] = "/profile/default"; void PassDictionary( const ShillProfileClient::DictionaryValueCallbackWithoutStatus& callback, const base::DictionaryValue* dictionary) { - if (callback.is_null()) - return; callback.Run(*dictionary); } diff --git a/chromeos/dbus/shill_service_client_stub.cc b/chromeos/dbus/shill_service_client_stub.cc index 3559ee4..f1c47c4 100644 --- a/chromeos/dbus/shill_service_client_stub.cc +++ b/chromeos/dbus/shill_service_client_stub.cc @@ -67,9 +67,6 @@ void ShillServiceClientStub::RemovePropertyChangedObserver( void ShillServiceClientStub::GetProperties( const dbus::ObjectPath& service_path, const DictionaryValueCallback& callback) { - if (callback.is_null()) - return; - base::DictionaryValue* nested_dict = NULL; scoped_ptr<base::DictionaryValue> result_properties; DBusMethodCallStatus call_status; @@ -127,8 +124,6 @@ void ShillServiceClientStub::SetProperty(const dbus::ObjectPath& service_path, FROM_HERE, base::Bind(&ShillServiceClientStub::NotifyObserversPropertyChanged, weak_ptr_factory_.GetWeakPtr(), service_path, name)); - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -148,8 +143,6 @@ void ShillServiceClientStub::ClearProperty( FROM_HERE, base::Bind(&ShillServiceClientStub::NotifyObserversPropertyChanged, weak_ptr_factory_.GetWeakPtr(), service_path, name)); - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -178,8 +171,6 @@ void ShillServiceClientStub::ClearProperties( &ShillServiceClientStub::NotifyObserversPropertyChanged, weak_ptr_factory_.GetWeakPtr(), service_path, *iter)); } - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&PassStubListValue, @@ -192,7 +183,7 @@ void ShillServiceClientStub::Connect(const dbus::ObjectPath& service_path, VLOG(1) << "ShillServiceClientStub::Connect: " << service_path.value(); base::Value* service; if (!stub_services_.Get(service_path.value(), &service)) { - LOG(ERROR) << "Service not found: " << service_path.value(); + LOG(ERROR) << "Service not found: " << service_path.value(); error_callback.Run("Error.InvalidService", "Invalid Service"); return; } @@ -254,8 +245,6 @@ void ShillServiceClientStub::Disconnect(const dbus::ObjectPath& service_path, void ShillServiceClientStub::Remove(const dbus::ObjectPath& service_path, const base::Closure& callback, const ErrorCallback& error_callback) { - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -264,8 +253,6 @@ void ShillServiceClientStub::ActivateCellularModem( const std::string& carrier, const base::Closure& callback, const ErrorCallback& error_callback) { - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -273,8 +260,6 @@ void ShillServiceClientStub::CompleteCellularActivation( const dbus::ObjectPath& service_path, const base::Closure& callback, const ErrorCallback& error_callback) { - if (callback.is_null()) - return; base::MessageLoop::current()->PostTask(FROM_HERE, callback); } @@ -287,9 +272,6 @@ bool ShillServiceClientStub::CallActivateCellularModemAndBlock( void ShillServiceClientStub::GetLoadableProfileEntries( const dbus::ObjectPath& service_path, const DictionaryValueCallback& callback) { - if (callback.is_null()) - return; - // Provide a dictionary with a single { profile_path, service_path } entry // if the Profile property is set, or an empty dictionary. scoped_ptr<base::DictionaryValue> result_properties( diff --git a/chromeos/network/network_connection_handler_unittest.cc b/chromeos/network/network_connection_handler_unittest.cc index 8d8fd7a..96346c7 100644 --- a/chromeos/network/network_connection_handler_unittest.cc +++ b/chromeos/network/network_connection_handler_unittest.cc @@ -20,6 +20,13 @@ namespace { const char* kSuccessResult = "success"; +void ConfigureCallback(const dbus::ObjectPath& result) { +} + +void ConfigureErrorCallback(const std::string& error_name, + const std::string& error_message) { +} + } // namespace namespace chromeos { @@ -68,7 +75,8 @@ class NetworkConnectionHandlerTest : public testing::Test { } DBusThreadManager::Get()->GetShillManagerClient()->ConfigureService( *json_dict, - ObjectPathCallback(), ShillManagerClient::ErrorCallback()); + base::Bind(&ConfigureCallback), + base::Bind(&ConfigureErrorCallback)); message_loop_.RunUntilIdle(); return true; } |