Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / mojo / services / test_service / test_time_service_impl.cc
blobf4adbaa0ede5df7f2299f84578dc616b53b0a03e
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.
5 #include "base/time/time.h"
6 #include "mojo/public/cpp/application/application_connection.h"
7 #include "mojo/services/test_service/test_request_tracker.mojom.h"
8 #include "mojo/services/test_service/test_request_tracker_client_impl.h"
9 #include "mojo/services/test_service/test_time_service_impl.h"
11 namespace mojo {
12 namespace test {
14 TestTimeServiceImpl::TestTimeServiceImpl(ApplicationConnection* application)
15 : application_(application) {
18 TestTimeServiceImpl::~TestTimeServiceImpl() {
21 void TestTimeServiceImpl::StartTrackingRequests(
22 const mojo::Callback<void()>& callback) {
23 TestRequestTrackerPtr tracker;
24 application_->ConnectToService(
25 "mojo:mojo_test_request_tracker_app", &tracker);
26 tracking_.reset(new TestRequestTrackerClientImpl(
27 tracker.Pass(), Name_, callback));
30 void TestTimeServiceImpl::GetPartyTime(
31 const mojo::Callback<void(int64_t)>& callback) {
32 if (tracking_)
33 tracking_->RecordNewRequest();
34 base::Time frozen_time(base::Time::UnixEpoch()
35 + base::TimeDelta::FromDays(10957)
36 + base::TimeDelta::FromHours(7)
37 + base::TimeDelta::FromMinutes(59));
38 int64 time(frozen_time.ToInternalValue());
39 callback.Run(time);
42 } // namespace test
43 } // namespace mojo