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 "mojo/services/test_service/test_time_service_impl.h" | |
6 | |
7 #include <stdint.h> | |
8 | |
9 #include <utility> | |
10 | |
11 #include "base/time/time.h" | |
12 #include "mojo/services/test_service/test_request_tracker.mojom.h" | |
13 #include "mojo/services/test_service/tracked_service.h" | |
14 #include "mojo/shell/public/cpp/connector.h" | |
15 | |
16 namespace mojo { | |
17 namespace test { | |
18 | |
19 TestTimeServiceImpl::TestTimeServiceImpl( | |
20 Connector* connector, | |
21 InterfaceRequest<TestTimeService> request) | |
22 : connector_(connector), binding_(this, std::move(request)) {} | |
23 | |
24 TestTimeServiceImpl::~TestTimeServiceImpl() { | |
25 } | |
26 | |
27 void TestTimeServiceImpl::StartTrackingRequests( | |
28 const mojo::Callback<void()>& callback) { | |
29 TestRequestTrackerPtr tracker; | |
30 connector_->ConnectToInterface("mojo:test_request_tracker_app", &tracker); | |
31 tracking_.reset(new TrackedService(std::move(tracker), Name_, callback)); | |
32 } | |
33 | |
34 void TestTimeServiceImpl::GetPartyTime( | |
35 const mojo::Callback<void(int64_t)>& callback) { | |
36 if (tracking_) | |
37 tracking_->RecordNewRequest(); | |
38 base::Time frozen_time(base::Time::UnixEpoch() | |
39 + base::TimeDelta::FromDays(10957) | |
40 + base::TimeDelta::FromHours(7) | |
41 + base::TimeDelta::FromMinutes(59)); | |
42 int64_t time(frozen_time.ToInternalValue()); | |
43 callback.Run(time); | |
44 } | |
45 | |
46 } // namespace test | |
47 } // namespace mojo | |
OLD | NEW |