Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1025)

Side by Side Diff: services/test_service/test_time_service_impl.cc

Issue 2004493002: Add a mojo::RunApplication() for running implementations of ApplicationImplBase. (Closed) Base URL: https://github.com/domokit/mojo.git@work790_environment_no_instantiate
Patch Set: rebased Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/test_service/test_time_service_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_impl.h" 6 #include "mojo/public/cpp/application/application_impl_base.h"
7 #include "mojo/public/cpp/application/connect.h" 7 #include "mojo/public/cpp/application/connect.h"
8 #include "services/test_service/test_request_tracker.mojom.h" 8 #include "services/test_service/test_request_tracker.mojom.h"
9 #include "services/test_service/test_time_service_impl.h" 9 #include "services/test_service/test_time_service_impl.h"
10 #include "services/test_service/tracked_service.h" 10 #include "services/test_service/tracked_service.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 namespace test { 13 namespace test {
14 14
15 TestTimeServiceImpl::TestTimeServiceImpl( 15 TestTimeServiceImpl::TestTimeServiceImpl(
16 ApplicationImpl* app_impl, 16 ApplicationImplBase* application,
17 InterfaceRequest<TestTimeService> request) 17 InterfaceRequest<TestTimeService> request)
18 : app_impl_(app_impl), binding_(this, request.Pass()) { 18 : application_(application), binding_(this, request.Pass()) {}
19 }
20 19
21 TestTimeServiceImpl::~TestTimeServiceImpl() { 20 TestTimeServiceImpl::~TestTimeServiceImpl() {}
22 }
23 21
24 void TestTimeServiceImpl::StartTrackingRequests( 22 void TestTimeServiceImpl::StartTrackingRequests(
25 const mojo::Callback<void()>& callback) { 23 const mojo::Callback<void()>& callback) {
26 TestRequestTrackerPtr tracker; 24 TestRequestTrackerPtr tracker;
27 ConnectToService(app_impl_->shell(), "mojo:test_request_tracker_app", 25 ConnectToService(application_->shell(), "mojo:test_request_tracker_app",
28 GetProxy(&tracker)); 26 GetProxy(&tracker));
29 tracking_.reset(new TrackedService(tracker.Pass(), Name_, callback)); 27 tracking_.reset(new TrackedService(tracker.Pass(), Name_, callback));
30 } 28 }
31 29
32 void TestTimeServiceImpl::GetPartyTime( 30 void TestTimeServiceImpl::GetPartyTime(
33 const mojo::Callback<void(int64_t)>& callback) { 31 const mojo::Callback<void(int64_t)>& callback) {
34 if (tracking_) 32 if (tracking_)
35 tracking_->RecordNewRequest(); 33 tracking_->RecordNewRequest();
36 base::Time frozen_time(base::Time::UnixEpoch() 34 base::Time frozen_time(base::Time::UnixEpoch()
37 + base::TimeDelta::FromDays(10957) 35 + base::TimeDelta::FromDays(10957)
38 + base::TimeDelta::FromHours(7) 36 + base::TimeDelta::FromHours(7)
39 + base::TimeDelta::FromMinutes(59)); 37 + base::TimeDelta::FromMinutes(59));
40 int64 time(frozen_time.ToInternalValue()); 38 int64 time(frozen_time.ToInternalValue());
41 callback.Run(time); 39 callback.Run(time);
42 } 40 }
43 41
44 } // namespace test 42 } // namespace test
45 } // namespace mojo 43 } // namespace mojo
OLDNEW
« no previous file with comments | « services/test_service/test_time_service_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698