OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
| 5 #include "mojo/services/test_service/test_time_service_impl.h" |
| 6 |
| 7 #include <utility> |
| 8 |
5 #include "base/time/time.h" | 9 #include "base/time/time.h" |
6 #include "mojo/application/public/cpp/application_impl.h" | 10 #include "mojo/application/public/cpp/application_impl.h" |
7 #include "mojo/services/test_service/test_request_tracker.mojom.h" | 11 #include "mojo/services/test_service/test_request_tracker.mojom.h" |
8 #include "mojo/services/test_service/test_time_service_impl.h" | |
9 #include "mojo/services/test_service/tracked_service.h" | 12 #include "mojo/services/test_service/tracked_service.h" |
10 | 13 |
11 namespace mojo { | 14 namespace mojo { |
12 namespace test { | 15 namespace test { |
13 | 16 |
14 TestTimeServiceImpl::TestTimeServiceImpl( | 17 TestTimeServiceImpl::TestTimeServiceImpl( |
15 ApplicationImpl* app_impl, | 18 ApplicationImpl* app_impl, |
16 InterfaceRequest<TestTimeService> request) | 19 InterfaceRequest<TestTimeService> request) |
17 : app_impl_(app_impl), binding_(this, request.Pass()) { | 20 : app_impl_(app_impl), binding_(this, std::move(request)) {} |
18 } | |
19 | 21 |
20 TestTimeServiceImpl::~TestTimeServiceImpl() { | 22 TestTimeServiceImpl::~TestTimeServiceImpl() { |
21 } | 23 } |
22 | 24 |
23 void TestTimeServiceImpl::StartTrackingRequests( | 25 void TestTimeServiceImpl::StartTrackingRequests( |
24 const mojo::Callback<void()>& callback) { | 26 const mojo::Callback<void()>& callback) { |
25 TestRequestTrackerPtr tracker; | 27 TestRequestTrackerPtr tracker; |
26 app_impl_->ConnectToService("mojo:test_request_tracker_app", &tracker); | 28 app_impl_->ConnectToService("mojo:test_request_tracker_app", &tracker); |
27 tracking_.reset(new TrackedService(tracker.Pass(), Name_, callback)); | 29 tracking_.reset(new TrackedService(std::move(tracker), Name_, callback)); |
28 } | 30 } |
29 | 31 |
30 void TestTimeServiceImpl::GetPartyTime( | 32 void TestTimeServiceImpl::GetPartyTime( |
31 const mojo::Callback<void(int64_t)>& callback) { | 33 const mojo::Callback<void(int64_t)>& callback) { |
32 if (tracking_) | 34 if (tracking_) |
33 tracking_->RecordNewRequest(); | 35 tracking_->RecordNewRequest(); |
34 base::Time frozen_time(base::Time::UnixEpoch() | 36 base::Time frozen_time(base::Time::UnixEpoch() |
35 + base::TimeDelta::FromDays(10957) | 37 + base::TimeDelta::FromDays(10957) |
36 + base::TimeDelta::FromHours(7) | 38 + base::TimeDelta::FromHours(7) |
37 + base::TimeDelta::FromMinutes(59)); | 39 + base::TimeDelta::FromMinutes(59)); |
38 int64 time(frozen_time.ToInternalValue()); | 40 int64 time(frozen_time.ToInternalValue()); |
39 callback.Run(time); | 41 callback.Run(time); |
40 } | 42 } |
41 | 43 |
42 } // namespace test | 44 } // namespace test |
43 } // namespace mojo | 45 } // namespace mojo |
OLD | NEW |