OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/time/time.h" |
| 6 #include "mojo/public/cpp/application/application_connection.h" |
| 7 #include "mojo/services/test_service/monitoring_uploader.h" |
| 8 #include "mojo/services/test_service/test_time_service_impl.h" |
| 9 |
| 10 namespace mojo { |
| 11 namespace test { |
| 12 |
| 13 TestTimeServiceImpl::TestTimeServiceImpl(ApplicationConnection* application) |
| 14 : application_(application) { |
| 15 } |
| 16 |
| 17 TestTimeServiceImpl::~TestTimeServiceImpl() { |
| 18 } |
| 19 |
| 20 void TestTimeServiceImpl::StartMonitoring( |
| 21 const mojo::Callback<void()>& callback) { |
| 22 ToyMonitoringServiceStatsRecorderPtr recorder; |
| 23 application_->ConnectToService("mojo:mojo_test_monitoring_app", &recorder); |
| 24 monitoring_.reset(new MonitoringUploader(recorder.Pass(), Name_, callback)); |
| 25 } |
| 26 |
| 27 void TestTimeServiceImpl::GetPartyTime( |
| 28 const mojo::Callback<void(int64_t)>& callback) { |
| 29 if (monitoring_) |
| 30 monitoring_->RecordNewRequest(); |
| 31 base::Time frozen_time(base::Time::UnixEpoch() |
| 32 + base::TimeDelta::FromDays(10957) |
| 33 + base::TimeDelta::FromHours(7) |
| 34 + base::TimeDelta::FromMinutes(59)); |
| 35 int64 time(frozen_time.ToInternalValue()); |
| 36 callback.Run(time); |
| 37 } |
| 38 |
| 39 } // namespace test |
| 40 } // namespace mojo |
OLD | NEW |