Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(898)

Unified Diff: mojo/services/test_service/test_service_impl.cc

Issue 349303006: mojo: add some end-to-end shell tests and a new test sample app (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ServiceProvider rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..f1117651a87a8931ca211bb24589dd2e4184e6d6 100644
--- a/mojo/services/test_service/test_service_impl.cc
+++ b/mojo/services/test_service/test_service_impl.cc
@@ -4,14 +4,21 @@
#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/monitoring_uploader.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 +33,38 @@ void TestServiceImpl::OnConnectionError() {
}
void TestServiceImpl::Ping(const mojo::Callback<void()>& callback) {
+ if (monitoring_)
+ monitoring_->RecordNewRequest();
callback.Run();
}
+void SendWelcomeMessageWithTime(
+ const mojo::Callback<void(mojo::String)>& requestor_callback,
+ int64_t time_usec) {
+ std::string friendly_msg(TestServiceImpl::kWelcomeMessagePrefix);
+ friendly_msg += UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(
+ base::Time::FromInternalValue(time_usec)));
+ requestor_callback.Run(friendly_msg);
+}
+
+void TestServiceImpl::GetFriendlyWelcomeMessage(
+ const mojo::String& time_app_url,
+ const mojo::Callback<void(mojo::String)>& callback) {
+ connection_->ConnectToService(time_app_url, &time_service_);
+ if (monitoring_) {
+ monitoring_->RecordNewRequest();
+ time_service_->StartMonitoring(mojo::Callback<void()>());
+ }
+ time_service_->GetPartyTime(base::Bind(
+ &SendWelcomeMessageWithTime,
+ callback));
+}
+
+void TestServiceImpl::StartMonitoring(const mojo::Callback<void()>& callback) {
+ ToyMonitoringServiceStatsRecorderPtr recorder;
+ connection_->ConnectToService("mojo:mojo_test_monitoring_app", &recorder);
+ monitoring_.reset(new MonitoringUploader(recorder.Pass(), Name_, callback));
+}
+
} // namespace test
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698