Index: mojo/services/test_service/test_service_impl.cc |
diff --git a/mojo/services/test_service/test_service_impl.cc b/mojo/services/test_service/test_service_impl.cc |
index ec652004f9aa5352de5ea74e9b5189612efd8e39..21373532b8f77c0f62ee7a2acd3c86536174c341 100644 |
--- a/mojo/services/test_service/test_service_impl.cc |
+++ b/mojo/services/test_service/test_service_impl.cc |
@@ -4,14 +4,22 @@ |
#include "mojo/services/test_service/test_service_impl.h" |
+#include "base/bind.h" |
+#include "base/i18n/time_formatting.h" |
+#include "base/strings/utf_string_conversions.h" |
+#include "mojo/public/cpp/application/application_connection.h" |
+#include "mojo/services/test_service/test_request_tracker_client_impl.h" |
+#include "mojo/services/test_service/test_request_tracker_impl.h" |
#include "mojo/services/test_service/test_service_application.h" |
+#include "mojo/services/test_service/test_time_service_impl.h" |
+#include "url/gurl.h" |
namespace mojo { |
namespace test { |
TestServiceImpl::TestServiceImpl(ApplicationConnection* connection, |
TestServiceApplication* application) |
- : application_(application) { |
+ : application_(application), connection_(connection) { |
} |
TestServiceImpl::~TestServiceImpl() { |
@@ -26,8 +34,36 @@ void TestServiceImpl::OnConnectionError() { |
} |
void TestServiceImpl::Ping(const mojo::Callback<void()>& callback) { |
+ if (tracking_) |
+ tracking_->RecordNewRequest(); |
callback.Run(); |
} |
+void SendTimeResponse( |
+ const mojo::Callback<void(int64_t)>& requestor_callback, |
+ int64_t time_usec) { |
+ requestor_callback.Run(time_usec); |
+} |
+ |
+void TestServiceImpl::ConnectToAppAndGetTime( |
+ const mojo::String& app_url, |
+ const mojo::Callback<void(int64_t)>& callback) { |
+ connection_->ConnectToService(app_url, &time_service_); |
+ if (tracking_) { |
+ tracking_->RecordNewRequest(); |
+ time_service_->StartTrackingRequests(mojo::Callback<void()>()); |
+ } |
+ time_service_->GetPartyTime(base::Bind(&SendTimeResponse, callback)); |
+} |
+ |
+void TestServiceImpl::StartTrackingRequests( |
+ const mojo::Callback<void()>& callback) { |
+ TestRequestTrackerPtr tracker; |
+ connection_->ConnectToService( |
+ "mojo:mojo_test_request_tracker_app", &tracker); |
+ tracking_.reset( |
+ new TestRequestTrackerClientImpl(tracker.Pass(), Name_, callback)); |
+} |
+ |
} // namespace test |
} // namespace mojo |