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

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

Issue 1674903003: Extract shell methods from ApplicationImpl into a base class, and pass this to Initialize() instead. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojom
Patch Set: . Created 4 years, 10 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 | « mojo/services/test_service/test_time_service_impl.h ('k') | mojo/services/tracing/main.cc » ('j') | 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 "mojo/services/test_service/test_time_service_impl.h" 5 #include "mojo/services/test_service/test_time_service_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "mojo/services/test_service/test_request_tracker.mojom.h" 12 #include "mojo/services/test_service/test_request_tracker.mojom.h"
13 #include "mojo/services/test_service/tracked_service.h" 13 #include "mojo/services/test_service/tracked_service.h"
14 #include "mojo/shell/public/cpp/application_impl.h" 14 #include "mojo/shell/public/cpp/shell.h"
15 15
16 namespace mojo { 16 namespace mojo {
17 namespace test { 17 namespace test {
18 18
19 TestTimeServiceImpl::TestTimeServiceImpl( 19 TestTimeServiceImpl::TestTimeServiceImpl(
20 ApplicationImpl* app_impl, 20 Shell* shell,
21 InterfaceRequest<TestTimeService> request) 21 InterfaceRequest<TestTimeService> request)
22 : app_impl_(app_impl), binding_(this, std::move(request)) {} 22 : shell_(shell), binding_(this, std::move(request)) {}
23 23
24 TestTimeServiceImpl::~TestTimeServiceImpl() { 24 TestTimeServiceImpl::~TestTimeServiceImpl() {
25 } 25 }
26 26
27 void TestTimeServiceImpl::StartTrackingRequests( 27 void TestTimeServiceImpl::StartTrackingRequests(
28 const mojo::Callback<void()>& callback) { 28 const mojo::Callback<void()>& callback) {
29 TestRequestTrackerPtr tracker; 29 TestRequestTrackerPtr tracker;
30 app_impl_->ConnectToService("mojo:test_request_tracker_app", &tracker); 30 shell_->ConnectToService("mojo:test_request_tracker_app", &tracker);
31 tracking_.reset(new TrackedService(std::move(tracker), Name_, callback)); 31 tracking_.reset(new TrackedService(std::move(tracker), Name_, callback));
32 } 32 }
33 33
34 void TestTimeServiceImpl::GetPartyTime( 34 void TestTimeServiceImpl::GetPartyTime(
35 const mojo::Callback<void(int64_t)>& callback) { 35 const mojo::Callback<void(int64_t)>& callback) {
36 if (tracking_) 36 if (tracking_)
37 tracking_->RecordNewRequest(); 37 tracking_->RecordNewRequest();
38 base::Time frozen_time(base::Time::UnixEpoch() 38 base::Time frozen_time(base::Time::UnixEpoch()
39 + base::TimeDelta::FromDays(10957) 39 + base::TimeDelta::FromDays(10957)
40 + base::TimeDelta::FromHours(7) 40 + base::TimeDelta::FromHours(7)
41 + base::TimeDelta::FromMinutes(59)); 41 + base::TimeDelta::FromMinutes(59));
42 int64_t time(frozen_time.ToInternalValue()); 42 int64_t time(frozen_time.ToInternalValue());
43 callback.Run(time); 43 callback.Run(time);
44 } 44 }
45 45
46 } // namespace test 46 } // namespace test
47 } // namespace mojo 47 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/test_service/test_time_service_impl.h ('k') | mojo/services/tracing/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698