summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chromeos/dbus/debug_daemon_client.cc27
-rw-r--r--chromeos/dbus/debug_daemon_client.h13
-rw-r--r--chromeos/dbus/mock_debug_daemon_client.h1
3 files changed, 41 insertions, 0 deletions
diff --git a/chromeos/dbus/debug_daemon_client.cc b/chromeos/dbus/debug_daemon_client.cc
index 8ae9c0a..4b7571d 100644
--- a/chromeos/dbus/debug_daemon_client.cc
+++ b/chromeos/dbus/debug_daemon_client.cc
@@ -306,6 +306,20 @@ class DebugDaemonClientImpl : public DebugDaemonClient {
return true;
}
+ virtual void TestICMP(const std::string& ip_address,
+ const TestICMPCallback& callback) OVERRIDE {
+ dbus::MethodCall method_call(debugd::kDebugdInterface,
+ debugd::kTestICMP);
+ dbus::MessageWriter writer(&method_call);
+ writer.AppendString(ip_address);
+ debugdaemon_proxy_->CallMethod(
+ &method_call,
+ dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&DebugDaemonClientImpl::OnTestICMP,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback));
+ }
+
private:
// Called to check descriptor validity on a thread where i/o is permitted.
static void CheckValidity(dbus::FileDescriptor* file_descriptor) {
@@ -458,6 +472,14 @@ class DebugDaemonClientImpl : public DebugDaemonClient {
// NB: requester is signaled when i/o completes
}
+ void OnTestICMP(const TestICMPCallback& callback, dbus::Response* response) {
+ std::string status;
+ if (response && dbus::MessageReader(response).PopString(&status))
+ callback.Run(true, status);
+ else
+ callback.Run(false, "");
+ }
+
// Called when pipe i/o completes; pass data on and delete the instance.
void OnIOComplete() {
callback_.Run(base::RefCountedString::TakeString(pipe_reader_->data()));
@@ -512,6 +534,11 @@ class DebugDaemonClientStubImpl : public DebugDaemonClient {
std::map<std::string, std::string> empty;
callback.Run(false, empty);
}
+
+ virtual void TestICMP(const std::string& ip_address,
+ const TestICMPCallback& callback) OVERRIDE {
+ callback.Run(false, "");
+ }
};
DebugDaemonClient::DebugDaemonClient() {
diff --git a/chromeos/dbus/debug_daemon_client.h b/chromeos/dbus/debug_daemon_client.h
index 07e52ba..8159354 100644
--- a/chromeos/dbus/debug_daemon_client.h
+++ b/chromeos/dbus/debug_daemon_client.h
@@ -96,6 +96,19 @@ class CHROMEOS_EXPORT DebugDaemonClient {
// Returns an empty SystemTracingCallback that does nothing.
static StopSystemTracingCallback EmptyStopSystemTracingCallback();
+ // Called once TestICMP() is complete. Takes two parameters:
+ // - succeeded: information was obtained successfully.
+ // - status: information about ICMP connectivity to a specified host as json.
+ // For details please refer to
+ // https://gerrit.chromium.org/gerrit/#/c/30310/2/src/helpers/icmp.cc
+ typedef base::Callback<void(bool succeeded, const std::string& status)>
+ TestICMPCallback;
+
+ // Tests ICMP connectivity to a specified host. The |ip_address| contains the
+ // IPv4 or IPv6 address of the host, for example "8.8.8.8".
+ virtual void TestICMP(const std::string& ip_address,
+ const TestICMPCallback& callback) = 0;
+
// Factory function, creates a new instance and returns ownership.
// For normal usage, access the singleton via DBusThreadManager::Get().
static DebugDaemonClient* Create(DBusClientImplementationType type,
diff --git a/chromeos/dbus/mock_debug_daemon_client.h b/chromeos/dbus/mock_debug_daemon_client.h
index 002efb4..fe8d933 100644
--- a/chromeos/dbus/mock_debug_daemon_client.h
+++ b/chromeos/dbus/mock_debug_daemon_client.h
@@ -27,6 +27,7 @@ class MockDebugDaemonClient : public DebugDaemonClient {
MOCK_METHOD1(RequestStopSystemTracing,
bool(const StopSystemTracingCallback&));
MOCK_METHOD0(StartSystemTracing, void());
+ MOCK_METHOD2(TestICMP, void(const std::string&, const TestICMPCallback&));
};
} // namespace chromeos