shill: Remove shill::Error dependency from libshill-net shared library.
Update the ErrorCallback in the IOHandler to pass back a std::string
(error message) instead of shill::Error objet to remove the dependency
of shill:: Error from the libshill-net library, which also allow it to
remove the dependency for dbus-c++.
BUG=chromium:427982
TEST=unittests
Change-Id: I2e756d5e0744f449fcdcb157f5356112c45fd855
Reviewed-on: https://chromium-review.googlesource.com/226291
Reviewed-by: Paul Stewart <pstew@chromium.org>
Reviewed-by: Peter Qiu <zqiu@chromium.org>
Commit-Queue: Peter Qiu <zqiu@chromium.org>
Tested-by: Peter Qiu <zqiu@chromium.org>
diff --git a/crypto_util_proxy.cc b/crypto_util_proxy.cc
index af8d26c..c11341f 100644
--- a/crypto_util_proxy.cc
+++ b/crypto_util_proxy.cc
@@ -186,7 +186,7 @@
shim_stdout_handler_.reset(dispatcher_->CreateInputHandler(
shim_stdout_,
Bind(&CryptoUtilProxy::HandleShimOutput, AsWeakPtr()),
- Bind(&CryptoUtilProxy::HandleShimError, AsWeakPtr())));
+ Bind(&CryptoUtilProxy::HandleShimReadError, AsWeakPtr())));
shim_stdin_handler_.reset(dispatcher_->CreateReadyHandler(
shim_stdin_,
IOHandler::kModeOutput,
@@ -297,6 +297,11 @@
CleanupShim(error);
}
+void CryptoUtilProxy::HandleShimReadError(const string &error_msg) {
+ Error e(Error::kOperationFailed, error_msg);
+ HandleShimError(e);
+}
+
void CryptoUtilProxy::HandleShimTimeout() {
Error e(Error::kOperationTimeout);
HandleShimError(e);
diff --git a/crypto_util_proxy.h b/crypto_util_proxy.h
index 876a421..757902d 100644
--- a/crypto_util_proxy.h
+++ b/crypto_util_proxy.h
@@ -107,6 +107,7 @@
// GLib on changes in file descriptor state.
void HandleShimStdinReady(int fd);
void HandleShimOutput(InputData *data);
+ void HandleShimReadError(const std::string &error_msg);
void HandleShimError(const Error &error);
void HandleShimTimeout();
// Used to handle the final result of both operations. |result| is a
diff --git a/http_proxy.cc b/http_proxy.cc
index 0bd72ec..ba17773 100644
--- a/http_proxy.cc
+++ b/http_proxy.cc
@@ -227,7 +227,7 @@
StartTransmit();
}
-void HTTPProxy::OnReadError(const Error &error) {
+void HTTPProxy::OnReadError(const string &error_msg) {
StopClient();
}
diff --git a/http_proxy.h b/http_proxy.h
index 40009cd..412b97f 100644
--- a/http_proxy.h
+++ b/http_proxy.h
@@ -95,7 +95,7 @@
void AcceptClient(int fd);
bool ConnectServer(const IPAddress &address, int port);
void GetDNSResult(const Error &error, const IPAddress &address);
- void OnReadError(const Error &error);
+ void OnReadError(const std::string &error_msg);
void OnConnectCompletion(bool success, int fd);
bool ParseClientRequest();
bool ProcessLastHeaderLine();
diff --git a/http_proxy_unittest.cc b/http_proxy_unittest.cc
index 4efd471..b340d1c 100644
--- a/http_proxy_unittest.cc
+++ b/http_proxy_unittest.cc
@@ -445,7 +445,7 @@
EXPECT_EQ(HTTPProxy::kStateTunnelData, GetProxyState());
}
void CauseReadError() {
- proxy_.OnReadError(Error());
+ proxy_.OnReadError(string());
}
private:
diff --git a/http_request.cc b/http_request.cc
index 6d11213..2a6f3c8 100644
--- a/http_request.cc
+++ b/http_request.cc
@@ -202,7 +202,7 @@
StartIdleTimeout(kInputTimeoutSeconds, kResultRequestTimeout);
}
-void HTTPRequest::OnServerReadError(const Error &/*error*/) {
+void HTTPRequest::OnServerReadError(const string &/*error_msg*/) {
SendStatus(kResultResponseFailure);
}
diff --git a/http_request.h b/http_request.h
index 028d8bf..1b5ad57 100644
--- a/http_request.h
+++ b/http_request.h
@@ -98,7 +98,7 @@
bool ConnectServer(const IPAddress &address, int port);
void GetDNSResult(const Error &error, const IPAddress &address);
void OnConnectCompletion(bool success, int fd);
- void OnServerReadError(const Error &error);
+ void OnServerReadError(const std::string &error_msg);
void ReadFromServer(InputData *data);
void SendStatus(Result result);
void StartIdleTimeout(int timeout_seconds, Result timeout_result);
diff --git a/http_request_unittest.cc b/http_request_unittest.cc
index c9eb02c..2af5127 100644
--- a/http_request_unittest.cc
+++ b/http_request_unittest.cc
@@ -316,7 +316,7 @@
request_->TimeoutTask();
}
void CallServerErrorCallback() {
- request_->OnServerReadError(Error());
+ request_->OnServerReadError(string());
}
private:
diff --git a/net/glib_io_input_handler.cc b/net/glib_io_input_handler.cc
index 4c68634..c0d113c 100644
--- a/net/glib_io_input_handler.cc
+++ b/net/glib_io_input_handler.cc
@@ -16,8 +16,6 @@
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
-#include "shill/error.h"
-
using base::Callback;
using base::StringPrintf;
using std::string;
@@ -60,8 +58,7 @@
"Unexpected GLib return status: %d", status);
LOG(ERROR) << condition;
error_conditions.push_back(condition);
- Error error(Error::kOperationFailed, JoinString(error_conditions, ';'));
- handler->error_callback().Run(error);
+ handler->error_callback().Run(JoinString(error_conditions, ';'));
return FALSE;
}
diff --git a/net/io_handler.h b/net/io_handler.h
index 316934c..52d6dca 100644
--- a/net/io_handler.h
+++ b/net/io_handler.h
@@ -5,12 +5,12 @@
#ifndef SHILL_NET_IO_HANDLER_H_
#define SHILL_NET_IO_HANDLER_H_
+#include <string>
+
#include <base/callback.h>
namespace shill {
-class Error;
-
struct InputData {
InputData() : buf(nullptr), len(0) {}
InputData(unsigned char *in_buf, size_t in_len) : buf(in_buf), len(in_len) {}
@@ -26,7 +26,7 @@
kModeOutput
};
- typedef base::Callback<void(const Error &)> ErrorCallback;
+ typedef base::Callback<void(const std::string &)> ErrorCallback;
typedef base::Callback<void(InputData *)> InputCallback;
typedef base::Callback<void(int)> ReadyCallback;
diff --git a/net/io_input_handler.cc b/net/io_input_handler.cc
index f5d616f..ad086c8 100644
--- a/net/io_input_handler.cc
+++ b/net/io_input_handler.cc
@@ -10,8 +10,6 @@
#include <base/logging.h>
#include <base/strings/stringprintf.h>
-#include "shill/error.h"
-
namespace shill {
IOInputHandler::IOInputHandler(int fd,
@@ -46,8 +44,7 @@
std::string condition = base::StringPrintf(
"File read error: %d", errno);
LOG(ERROR) << condition;
- Error error(Error::kOperationFailed, condition);
- error_callback_.Run(error);
+ error_callback_.Run(condition);
}
InputData input_data(buf, len);
diff --git a/net/rtnl_handler.cc b/net/rtnl_handler.cc
index 84eb241..0d2b56b 100644
--- a/net/rtnl_handler.cc
+++ b/net/rtnl_handler.cc
@@ -19,7 +19,6 @@
#include <base/bind.h>
#include <base/logging.h>
-#include "shill/error.h"
#include "shill/net/io_handler.h"
#include "shill/net/ip_address.h"
#include "shill/net/ndisc.h"
@@ -412,9 +411,9 @@
return true;
}
-void RTNLHandler::OnReadError(const Error &error) {
+void RTNLHandler::OnReadError(const string &error_msg) {
LOG(FATAL) << "RTNL Socket read returns error: "
- << error.message();
+ << error_msg;
}
} // namespace shill
diff --git a/net/rtnl_handler.h b/net/rtnl_handler.h
index c67efc7..fe43ef2 100644
--- a/net/rtnl_handler.h
+++ b/net/rtnl_handler.h
@@ -22,7 +22,6 @@
namespace shill {
-class Error;
class Sockets;
// This singleton class is responsible for interacting with the RTNL subsystem.
@@ -132,7 +131,7 @@
const IPAddress &peer);
// Called by the RTNL read handler on exceptional events.
- void OnReadError(const Error &error);
+ void OnReadError(const std::string &error_msg);
Sockets *sockets_;
bool in_request_;
diff --git a/netlink_manager.cc b/netlink_manager.cc
index 4fd24c0..d525fef 100644
--- a/netlink_manager.cc
+++ b/netlink_manager.cc
@@ -15,7 +15,6 @@
#include <base/stl_util.h>
#include "shill/attribute_list.h"
-#include "shill/error.h"
#include "shill/event_dispatcher.h"
#include "shill/generic_netlink_message.h"
#include "shill/logging.h"
@@ -640,12 +639,12 @@
}
}
-void NetlinkManager::OnReadError(const Error &error) {
+void NetlinkManager::OnReadError(const string &error_msg) {
// TODO(wdg): When netlink_manager is used for scan, et al., this should
// either be LOG(FATAL) or the code should properly deal with errors,
// e.g., dropped messages due to the socket buffer being full.
LOG(ERROR) << "NetlinkManager's netlink Socket read returns error: "
- << error.message();
+ << error_msg;
}
diff --git a/netlink_manager.h b/netlink_manager.h
index d871fd8..9486bb5 100644
--- a/netlink_manager.h
+++ b/netlink_manager.h
@@ -77,7 +77,6 @@
namespace shill {
class ControlNetlinkMessage;
-class Error;
class EventDispatcher;
struct InputData;
class Nl80211Message;
@@ -311,7 +310,7 @@
void OnNlMessageReceived(nlmsghdr *msg);
// Called by InputHandler on exceptional events.
- void OnReadError(const Error &error);
+ void OnReadError(const std::string &error_msg);
// Just for tests, this method turns off WiFi and clears the subscribed
// events list. If |full| is true, also clears state set by Init.
diff --git a/openvpn_management_server.cc b/openvpn_management_server.cc
index de6e2f9..58a6e5b 100644
--- a/openvpn_management_server.cc
+++ b/openvpn_management_server.cc
@@ -175,8 +175,8 @@
}
}
-void OpenVPNManagementServer::OnInputError(const Error &error) {
- LOG(ERROR) << error;
+void OpenVPNManagementServer::OnInputError(const std::string &error_msg) {
+ LOG(ERROR) << error_msg;
driver_->FailService(Service::kFailureInternal, Service::kErrorDetailsNone);
}
diff --git a/openvpn_management_server.h b/openvpn_management_server.h
index 70c9430..340a8a1 100644
--- a/openvpn_management_server.h
+++ b/openvpn_management_server.h
@@ -87,7 +87,7 @@
// IO handler callbacks.
void OnReady(int fd);
void OnInput(InputData *data);
- void OnInputError(const Error &error);
+ void OnInputError(const std::string &error_msg);
void Send(const std::string &data);
void SendState(const std::string &state);
diff --git a/shill.gyp b/shill.gyp
index aa27c1e..6d8cdbd 100644
--- a/shill.gyp
+++ b/shill.gyp
@@ -136,7 +136,6 @@
'type': 'shared_library',
'variables': {
'exported_deps': [
- 'dbus-c++-1',
'glib-2.0',
],
'deps': ['<@(exported_deps)'],
@@ -145,7 +144,6 @@
'-fvisibility=default',
],
'sources': [
- 'error.cc',
'net/byte_string.cc',
'net/glib_io_input_handler.cc',
'net/glib_io_ready_handler.cc',
@@ -337,6 +335,7 @@
'eap_listener.cc',
'endpoint.cc',
'ephemeral_profile.cc',
+ 'error.cc',
'ethernet.cc',
'ethernet_eap_provider.cc',
'ethernet_eap_service.cc',