summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-17 01:22:10 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-17 01:22:10 +0000
commit4b90452ae334ce1401b5408c4576262f628dc2de (patch)
tree843e27da78d75c1ee4d85b3d6414f3ad443d6cd5 /chromeos
parent8737cec4bd7341fc4f2b0fb0fa63caabb5409dec (diff)
downloadchromium_src-4b90452ae334ce1401b5408c4576262f628dc2de.zip
chromium_src-4b90452ae334ce1401b5408c4576262f628dc2de.tar.gz
chromium_src-4b90452ae334ce1401b5408c4576262f628dc2de.tar.bz2
Reimplement Libcros fucntions using FlimflamProfileClient
Change FlimflamProfileClient's interface to deal with multiple profile objects Change FlimflamProfileClient's interface to send an entry's path as a string, not an ObjectPath Add non-Libcros implementations of CrosDeleteServiceFromProfile, CrosRequestNetworkProfileProperties and CrosRequestNetworkProfileEntryProperties Add EnableNonLibcrosNetworkFunctions Add --enable-non-libcros-network-functions commandline option Rename existing CrosNetworkFunctionsTest to CrosNetworkFunctionsLibcrosTest Add new CrosNetworkFunctionsTest which tests the non Libcros implementation BUG=chromium-os:16557 TEST=unit_tests --gtest_filter="CrosNetworkFunctions*" Review URL: https://chromiumcodereview.appspot.com/9958045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132502 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/dbus/flimflam_profile_client.cc100
-rw-r--r--chromeos/dbus/flimflam_profile_client.h13
-rw-r--r--chromeos/dbus/mock_flimflam_profile_client.h17
3 files changed, 81 insertions, 49 deletions
diff --git a/chromeos/dbus/flimflam_profile_client.cc b/chromeos/dbus/flimflam_profile_client.cc
index 9079109..edc7ce6 100644
--- a/chromeos/dbus/flimflam_profile_client.cc
+++ b/chromeos/dbus/flimflam_profile_client.cc
@@ -6,11 +6,11 @@
#include "base/bind.h"
#include "base/message_loop.h"
+#include "base/stl_util.h"
#include "base/values.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
-#include "dbus/object_proxy.h"
#include "dbus/values_util.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -25,74 +25,91 @@ class FlimflamProfileClientImpl : public FlimflamProfileClient {
// FlimflamProfileClient overrides:
virtual void SetPropertyChangedHandler(
+ const dbus::ObjectPath& profile_path,
const PropertyChangedHandler& handler) OVERRIDE;
- virtual void ResetPropertyChangedHandler() OVERRIDE;
- virtual void GetProperties(const DictionaryValueCallback& callback) OVERRIDE;
- virtual void GetEntry(const dbus::ObjectPath& path,
+ virtual void ResetPropertyChangedHandler(
+ const dbus::ObjectPath& profile_path) OVERRIDE;
+ virtual void GetProperties(const dbus::ObjectPath& profile_path,
+ const DictionaryValueCallback& callback) OVERRIDE;
+ virtual void GetEntry(const dbus::ObjectPath& profile_path,
+ const std::string& entry_path,
const DictionaryValueCallback& callback) OVERRIDE;
- virtual void DeleteEntry(const dbus::ObjectPath& path,
+ virtual void DeleteEntry(const dbus::ObjectPath& profile_path,
+ const std::string& entry_path,
const VoidCallback& callback) OVERRIDE;
private:
- // Handles the result of signal connection setup.
- void OnSignalConnected(const std::string& interface,
- const std::string& signal,
- bool success);
- // Handles PropertyChanged signal.
- void OnPropertyChanged(dbus::Signal* signal);
- // Handles responses for methods without results.
- void OnVoidMethod(const VoidCallback& callback, dbus::Response* response);
- // Handles responses for methods with DictionaryValue results.
- void OnDictionaryValueMethod(const DictionaryValueCallback& callback,
- dbus::Response* response);
-
- dbus::ObjectProxy* proxy_;
- FlimflamClientHelper helper_;
+ typedef std::map<std::string, FlimflamClientHelper*> HelperMap;
+
+ // Returns the corresponding FlimflamClientHelper for the profile.
+ FlimflamClientHelper* GetHelper(const dbus::ObjectPath& profile_path);
+
+ dbus::Bus* bus_;
+ HelperMap helpers_;
+ STLValueDeleter<HelperMap> helpers_deleter_;
DISALLOW_COPY_AND_ASSIGN(FlimflamProfileClientImpl);
};
FlimflamProfileClientImpl::FlimflamProfileClientImpl(dbus::Bus* bus)
- : proxy_(bus->GetObjectProxy(
- flimflam::kFlimflamServiceName,
- dbus::ObjectPath(flimflam::kFlimflamServicePath))),
- helper_(proxy_) {
- helper_.MonitorPropertyChanged(flimflam::kFlimflamProfileInterface);
+ : bus_(bus),
+ helpers_deleter_(&helpers_) {
+}
+
+FlimflamClientHelper* FlimflamProfileClientImpl::GetHelper(
+ const dbus::ObjectPath& profile_path) {
+ HelperMap::iterator it = helpers_.find(profile_path.value());
+ if (it != helpers_.end())
+ return it->second;
+
+ // There is no helper for the profile, create it.
+ dbus::ObjectProxy* object_proxy =
+ bus_->GetObjectProxy(flimflam::kFlimflamServiceName, profile_path);
+ FlimflamClientHelper* helper = new FlimflamClientHelper(object_proxy);
+ helper->MonitorPropertyChanged(flimflam::kFlimflamProfileInterface);
+ helpers_.insert(HelperMap::value_type(profile_path.value(), helper));
+ return helper;
}
void FlimflamProfileClientImpl::SetPropertyChangedHandler(
+ const dbus::ObjectPath& profile_path,
const PropertyChangedHandler& handler) {
- helper_.SetPropertyChangedHandler(handler);
+ GetHelper(profile_path)->SetPropertyChangedHandler(handler);
}
-void FlimflamProfileClientImpl::ResetPropertyChangedHandler() {
- helper_.ResetPropertyChangedHandler();
+void FlimflamProfileClientImpl::ResetPropertyChangedHandler(
+ const dbus::ObjectPath& profile_path) {
+ GetHelper(profile_path)->ResetPropertyChangedHandler();
}
void FlimflamProfileClientImpl::GetProperties(
+ const dbus::ObjectPath& profile_path,
const DictionaryValueCallback& callback) {
dbus::MethodCall method_call(flimflam::kFlimflamProfileInterface,
flimflam::kGetPropertiesFunction);
- helper_.CallDictionaryValueMethod(&method_call, callback);
+ GetHelper(profile_path)->CallDictionaryValueMethod(&method_call, callback);
}
void FlimflamProfileClientImpl::GetEntry(
- const dbus::ObjectPath& path,
+ const dbus::ObjectPath& profile_path,
+ const std::string& entry_path,
const DictionaryValueCallback& callback) {
dbus::MethodCall method_call(flimflam::kFlimflamProfileInterface,
flimflam::kGetEntryFunction);
dbus::MessageWriter writer(&method_call);
- writer.AppendObjectPath(path);
- helper_.CallDictionaryValueMethod(&method_call, callback);
+ writer.AppendString(entry_path);
+ GetHelper(profile_path)->CallDictionaryValueMethod(&method_call, callback);
}
-void FlimflamProfileClientImpl::DeleteEntry(const dbus::ObjectPath& path,
- const VoidCallback& callback) {
+void FlimflamProfileClientImpl::DeleteEntry(
+ const dbus::ObjectPath& profile_path,
+ const std::string& entry_path,
+ const VoidCallback& callback) {
dbus::MethodCall method_call(flimflam::kFlimflamProfileInterface,
flimflam::kDeleteEntryFunction);
dbus::MessageWriter writer(&method_call);
- writer.AppendObjectPath(path);
- helper_.CallVoidMethod(&method_call, callback);
+ writer.AppendString(entry_path);
+ GetHelper(profile_path)->CallVoidMethod(&method_call, callback);
}
// A stub implementation of FlimflamProfileClient.
@@ -104,13 +121,16 @@ class FlimflamProfileClientStubImpl : public FlimflamProfileClient {
// FlimflamProfileClient override.
virtual void SetPropertyChangedHandler(
+ const dbus::ObjectPath& profile_path,
const PropertyChangedHandler& handler) OVERRIDE {}
// FlimflamProfileClient override.
- virtual void ResetPropertyChangedHandler() OVERRIDE {}
+ virtual void ResetPropertyChangedHandler(
+ const dbus::ObjectPath& profile_path) OVERRIDE {}
// FlimflamProfileClient override.
- virtual void GetProperties(const DictionaryValueCallback& callback) OVERRIDE {
+ virtual void GetProperties(const dbus::ObjectPath& profile_path,
+ const DictionaryValueCallback& callback) OVERRIDE {
MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&FlimflamProfileClientStubImpl::PassEmptyDictionaryValue,
@@ -119,7 +139,8 @@ class FlimflamProfileClientStubImpl : public FlimflamProfileClient {
}
// FlimflamProfileClient override.
- virtual void GetEntry(const dbus::ObjectPath& path,
+ virtual void GetEntry(const dbus::ObjectPath& profile_path,
+ const std::string& entry_path,
const DictionaryValueCallback& callback) OVERRIDE {
MessageLoop::current()->PostTask(
FROM_HERE,
@@ -129,7 +150,8 @@ class FlimflamProfileClientStubImpl : public FlimflamProfileClient {
}
// FlimflamProfileClient override.
- virtual void DeleteEntry(const dbus::ObjectPath& path,
+ virtual void DeleteEntry(const dbus::ObjectPath& profile_path,
+ const std::string& entry_path,
const VoidCallback& callback) OVERRIDE {
MessageLoop::current()->PostTask(FROM_HERE,
base::Bind(callback,
diff --git a/chromeos/dbus/flimflam_profile_client.h b/chromeos/dbus/flimflam_profile_client.h
index 4cc9f70..d226aa3 100644
--- a/chromeos/dbus/flimflam_profile_client.h
+++ b/chromeos/dbus/flimflam_profile_client.h
@@ -47,23 +47,28 @@ class CHROMEOS_EXPORT FlimflamProfileClient {
// Sets PropertyChanged signal handler.
virtual void SetPropertyChangedHandler(
+ const dbus::ObjectPath& profile_path,
const PropertyChangedHandler& handler) = 0;
// Resets PropertyChanged signal handler.
- virtual void ResetPropertyChangedHandler() = 0;
+ virtual void ResetPropertyChangedHandler(
+ const dbus::ObjectPath& profile_path) = 0;
// Calls GetProperties method.
// |callback| is called after the method call succeeds.
- virtual void GetProperties(const DictionaryValueCallback& callback) = 0;
+ virtual void GetProperties(const dbus::ObjectPath& profile_path,
+ const DictionaryValueCallback& callback) = 0;
// Calls GetEntry method.
// |callback| is called after the method call succeeds.
- virtual void GetEntry(const dbus::ObjectPath& path,
+ virtual void GetEntry(const dbus::ObjectPath& profile_path,
+ const std::string& entry_path,
const DictionaryValueCallback& callback) = 0;
// Calls DeleteEntry method.
// |callback| is called after the method call succeeds.
- virtual void DeleteEntry(const dbus::ObjectPath& path,
+ virtual void DeleteEntry(const dbus::ObjectPath& profile_path,
+ const std::string& entry_path,
const VoidCallback& callback) = 0;
protected:
diff --git a/chromeos/dbus/mock_flimflam_profile_client.h b/chromeos/dbus/mock_flimflam_profile_client.h
index 61afc1b..88e67f5 100644
--- a/chromeos/dbus/mock_flimflam_profile_client.h
+++ b/chromeos/dbus/mock_flimflam_profile_client.h
@@ -17,13 +17,18 @@ class MockFlimflamProfileClient : public FlimflamProfileClient {
MockFlimflamProfileClient();
virtual ~MockFlimflamProfileClient();
- MOCK_METHOD1(SetPropertyChangedHandler,
- void(const PropertyChangedHandler& handler));
- MOCK_METHOD0(ResetPropertyChangedHandler, void());
- MOCK_METHOD1(GetProperties, void(const DictionaryValueCallback& callback));
- MOCK_METHOD2(GetEntry, void(const dbus::ObjectPath& path,
+ MOCK_METHOD2(SetPropertyChangedHandler,
+ void(const dbus::ObjectPath& profile_path,
+ const PropertyChangedHandler& handler));
+ MOCK_METHOD1(ResetPropertyChangedHandler,
+ void(const dbus::ObjectPath& profile_path));
+ 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_METHOD2(DeleteEntry, void(const dbus::ObjectPath& path,
+ MOCK_METHOD3(DeleteEntry, void(const dbus::ObjectPath& profile_path,
+ const std::string& entry_path,
const VoidCallback& callback));
};