summaryrefslogtreecommitdiff
path: root/test-rpc-proxy
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2015-10-01 13:39:13 -0700
committerRoshan Pius <rpius@google.com>2015-10-01 16:22:41 -0700
commit9040f7dd043943832e96a37f53fa33c287f84781 (patch)
tree2c9bf4e1cda286ccb1e28c6cf548d75460de4be7 /test-rpc-proxy
parent5c01b468e7dc6bfd74928bbd5e9726df374fd252 (diff)
downloadshill-9040f7dd043943832e96a37f53fa33c287f84781.tar.gz
shill-test-proxy: Create a shill client interface (3/3).
Changes in the rest of test-proxy needed to work with the new Shill client interface. The RPC server thread to the main dbus server thread communication is a todo. Bug: 24335496 Change-Id: Ie4b4947f4df1d0c1c0a5053204f58565d84da2dc TEST: mmm system/connectivity/shill/test-rpc-proxy
Diffstat (limited to 'test-rpc-proxy')
-rw-r--r--test-rpc-proxy/Android.mk38
-rw-r--r--test-rpc-proxy/proxy_daemon.cc16
-rw-r--r--test-rpc-proxy/proxy_daemon.h16
-rw-r--r--test-rpc-proxy/proxy_main.cc7
-rw-r--r--test-rpc-proxy/proxy_rpc_server.cc8
-rw-r--r--test-rpc-proxy/proxy_rpc_server.h29
-rw-r--r--test-rpc-proxy/proxy_shill_wifi_client.h1
7 files changed, 57 insertions, 58 deletions
diff --git a/test-rpc-proxy/Android.mk b/test-rpc-proxy/Android.mk
index 62670dd8..895182e2 100644
--- a/test-rpc-proxy/Android.mk
+++ b/test-rpc-proxy/Android.mk
@@ -8,32 +8,32 @@ LOCAL_CPP_EXTENSION := .cc
LOCAL_CLANG := true
LOCAL_RTTI_FLAG := -frtti
LOCAL_CPPFLAGS := \
- -Werror \
- -Wextra\
- -Wno-unused-parameter \
- -fno-strict-aliasing \
- -Woverloaded-virtual \
- -Wno-sign-promo \
- -Wno-missing-field-initializers
+ -Werror \
+ -Wextra\
+ -Wno-unused-parameter \
+ -fno-strict-aliasing \
+ -Woverloaded-virtual \
+ -Wno-sign-promo \
+ -Wno-missing-field-initializers
LOCAL_C_INCLUDES := \
- external/cros/system_api \
- external/gtest/include \
- external/xmlrpcpp/src \
- system/connectivity \
- system/update_engine/include
+ external/cros/system_api \
+ external/gtest/include \
+ external/xmlrpcpp/src \
+ system/connectivity \
+ system/update_engine/include
LOCAL_SHARED_LIBRARIES := \
- libchrome \
- libchrome-dbus \
- libchromeos \
- libchromeos-dbus \
- libxmlrpc++
+ libchrome \
+ libchrome-dbus \
+ libchromeos \
+ libchromeos-dbus \
+ libxmlrpc++
proxy_src_files := \
- $(wildcard $(LOCAL_PATH)/*.cc)
+ $(wildcard $(LOCAL_PATH)/*.cc)
LOCAL_SRC_FILES := \
- $(proxy_src_files:$(LOCAL_PATH)/%=%)
+ $(proxy_src_files:$(LOCAL_PATH)/%=%)
include $(BUILD_EXECUTABLE)
endif # HOST_OS == linux
diff --git a/test-rpc-proxy/proxy_daemon.cc b/test-rpc-proxy/proxy_daemon.cc
index 4159fa10..a170ff9f 100644
--- a/test-rpc-proxy/proxy_daemon.cc
+++ b/test-rpc-proxy/proxy_daemon.cc
@@ -14,8 +14,9 @@
// limitations under the License.
//
#include "proxy_daemon.h"
+#include "proxy_dbus_shill_wifi_client.h"
-void ProxyDaemon::start_rpc_server_thread(std::shared_ptr<ProxyRpcServer> rpc_server) {
+void ProxyDaemon::start_rpc_server_thread(std::unique_ptr<ProxyRpcServer> rpc_server) {
rpc_server->Run();
}
@@ -25,13 +26,18 @@ int ProxyDaemon::OnInit() {
return ret;
}
- rpc_server_->set_proxy_dbus_client(dbus_client_);
- dbus_client_->set_proxy_dbus(bus_);
- dbus_client_->set_proxy_message_loop(base::MessageLoop::current());
+ // TODO: Create a RPC Event dispatcher and send it to the RPC server
+ // to schedule tasks on the main thread.
+
+ // Create the RPC server object
+ rpc_server_.reset(
+ new ProxyRpcServer(xml_rpc_server_port_, xml_rpc_lib_verbosity_));
+ // We're creating the Dbus version of the Shill Wifi Client for now.
+ shill_wifi_client_.reset(new ProxyDbusShillWifiClient(bus_));
rpc_server_thread_ = new std::thread(
&ProxyDaemon::start_rpc_server_thread,
- rpc_server_);
+ std::move(rpc_server_));
rpc_server_thread_->detach();
return EX_OK;
diff --git a/test-rpc-proxy/proxy_daemon.h b/test-rpc-proxy/proxy_daemon.h
index 270fee52..41e96bc2 100644
--- a/test-rpc-proxy/proxy_daemon.h
+++ b/test-rpc-proxy/proxy_daemon.h
@@ -28,24 +28,26 @@
#include <chromeos/any.h>
#include <chromeos/daemons/dbus_daemon.h>
-#include "proxy_dbus_client.h"
+#include "proxy_shill_wifi_client.h"
#include "proxy_rpc_server.h"
class ProxyDaemon : public chromeos::DBusDaemon {
public:
- ProxyDaemon(ProxyDbusClient *dbus_client, ProxyRpcServer *rpc_server) :
- dbus_client_(dbus_client), rpc_server_(rpc_server) {}
+ ProxyDaemon(int xml_rpc_server_port, int xml_rpc_lib_verbosity):
+ xml_rpc_server_port_(xml_rpc_server_port) {}
~ProxyDaemon() override = default;
- static void start_rpc_server_thread(
- std::shared_ptr<ProxyRpcServer> rpc_server);
+ static void start_rpc_server_thread(std::unique_ptr<ProxyRpcServer> rpc_server);
protected:
int OnInit() override;
void OnShutdown (int* exit_code) override;
private:
- std::shared_ptr<ProxyDbusClient> dbus_client_;
- std::shared_ptr<ProxyRpcServer> rpc_server_;
+ int xml_rpc_server_port_;
+ int xml_rpc_lib_verbosity_;
+ std::unique_ptr<ProxyShillWifiClient> shill_wifi_client_;
+ std::unique_ptr<ProxyRpcServer> rpc_server_;
std::thread *rpc_server_thread_;
+
};
#endif //PROXY_DAEMON_H
diff --git a/test-rpc-proxy/proxy_main.cc b/test-rpc-proxy/proxy_main.cc
index 30d09be7..148816f7 100644
--- a/test-rpc-proxy/proxy_main.cc
+++ b/test-rpc-proxy/proxy_main.cc
@@ -58,11 +58,10 @@ int main(int argc, char* argv[]) {
int port = std::stoi(cl->GetSwitchValueASCII(switches::kPort));
- ProxyDaemon proxy_daemon(
- new ProxyDbusClient(),
- new ProxyRpcServer(port, kXmlRpcLibVerbosity));
+ // Create the dbus daemon
+ ProxyDaemon proxy_daemon(port, kXmlRpcLibVerbosity);
- // Wait indefinitely
+ // Run indefinitely
proxy_daemon.Run();
return 0;
diff --git a/test-rpc-proxy/proxy_rpc_server.cc b/test-rpc-proxy/proxy_rpc_server.cc
index ee8edaf9..80826349 100644
--- a/test-rpc-proxy/proxy_rpc_server.cc
+++ b/test-rpc-proxy/proxy_rpc_server.cc
@@ -51,7 +51,9 @@ void ConnectWifi::execute(XmlRpcValue& params, XmlRpcValue& result) {
std::string ssid = std::string(params[0]);
bool is_hex_ssid = bool(params[1]);
std::string psk = std::string(params[2]);
- proxy_dbus_client_->OnConnectWifiRPCRequest(ssid, is_hex_ssid, psk);
+
+ // TODO: Use RPC Event dispatcher here
+ // proxy_dbus_client_->OnConnectWifiRPCRequest(ssid, is_hex_ssid, psk);
result[0] = kSuccess;
};
@@ -60,8 +62,8 @@ void ConnectWifi::execute(XmlRpcValue& params, XmlRpcValue& result) {
// Return: 0 <success>, -1 <Invalid args>, 1 <Failure>
void DisconnectWifi::execute(XmlRpcValue& params, XmlRpcValue& result) {
- // Send a message to the main proxy task to trigger the required dbus commands.
- proxy_dbus_client_->OnDisconnectWifiRPCRequest();
+ // TODO: Use RPC Event dispatcher here
+ // proxy_dbus_client_->OnDisconnectWifiRPCRequest();
result[0] = kSuccess;
};
diff --git a/test-rpc-proxy/proxy_rpc_server.h b/test-rpc-proxy/proxy_rpc_server.h
index 076f44f9..f5725616 100644
--- a/test-rpc-proxy/proxy_rpc_server.h
+++ b/test-rpc-proxy/proxy_rpc_server.h
@@ -40,36 +40,23 @@ class ProxyRpcServer : public XmlRpcServer {
XmlRpcServer(),
server_port_(server_port),
xml_rpc_lib_verbosity_(xml_rpc_lib_verbosity) {}
-
void Run();
- void set_proxy_dbus_client(std::shared_ptr<ProxyDbusClient> dbus_client) {
- proxy_dbus_client_ = dbus_client;
- }
-
- std::shared_ptr<ProxyDbusClient> get_proxy_dbus_client() {
- return proxy_dbus_client_;
- }
-
private:
int server_port_;
int xml_rpc_lib_verbosity_;
- std::shared_ptr<ProxyDbusClient> proxy_dbus_client_;
};
// Generic class for all the RPC methods exposed by Shill RPC server
class ProxyRpcServerMethod : public XmlRpcServerMethod {
-
public:
- ProxyRpcServerMethod(ProxyRpcServer* rpc_server) :
- XmlRpcServerMethod(typeid(*this).name(), rpc_server),
- proxy_dbus_client_(rpc_server->get_proxy_dbus_client()) {}
+ ProxyRpcServerMethod(std::string method_name, ProxyRpcServer* rpc_server) :
+ XmlRpcServerMethod(method_name, rpc_server) {}
protected:
int kSuccess = 0;
int kFailure = 1;
int kInvalidArgs = -1;
- std::shared_ptr<ProxyDbusClient> proxy_dbus_client_;
private:
};
@@ -80,16 +67,20 @@ class ProxyRpcServerMethod : public XmlRpcServerMethod {
// Param3: PSK <string>
// Return: 0 <success>, -1 <Invalid args>, 1 <Failure>
class ConnectWifi : public ProxyRpcServerMethod {
- using ProxyRpcServerMethod::ProxyRpcServerMethod;
-
+ public:
+ ConnectWifi(ProxyRpcServer* rpc_server) :
+ ProxyRpcServerMethod("ConnectWifi", rpc_server) {}
+ private:
void execute(XmlRpcValue& params, XmlRpcValue& result);
};
// MethodName: DisconnectWifi
// Return: 0 <success>, -1 <Invalid args>, 1 <Failure>
class DisconnectWifi : public ProxyRpcServerMethod {
- using ProxyRpcServerMethod::ProxyRpcServerMethod;
-
+ public:
+ DisconnectWifi(ProxyRpcServer* rpc_server) :
+ ProxyRpcServerMethod("DisconnectWifi", rpc_server) {}
+ private:
void execute(XmlRpcValue& params, XmlRpcValue& result);
};
diff --git a/test-rpc-proxy/proxy_shill_wifi_client.h b/test-rpc-proxy/proxy_shill_wifi_client.h
index c6b64a14..3413004f 100644
--- a/test-rpc-proxy/proxy_shill_wifi_client.h
+++ b/test-rpc-proxy/proxy_shill_wifi_client.h
@@ -29,7 +29,6 @@
// needs to use: Dbus, Binder, etc.
// TODO: Need to come up with comments explaining what each method needs to do here.
class ProxyShillWifiClient {
-
public:
enum AutoConnectType {
AUTO_CONNECT_TYPE_UNSPECIFIED,