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