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 "services/test_service/test_service_impl.h" | 5 #include "services/test_service/test_service_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "mojo/public/cpp/application/application_impl.h" | 10 #include "mojo/public/cpp/application/application_impl.h" |
| 11 #include "mojo/public/cpp/application/connect.h" |
11 #include "services/test_service/test_service_application.h" | 12 #include "services/test_service/test_service_application.h" |
12 #include "services/test_service/test_time_service_impl.h" | 13 #include "services/test_service/test_time_service_impl.h" |
13 #include "services/test_service/tracked_service.h" | 14 #include "services/test_service/tracked_service.h" |
14 | 15 |
15 namespace mojo { | 16 namespace mojo { |
16 namespace test { | 17 namespace test { |
17 | 18 |
18 TestServiceImpl::TestServiceImpl(ApplicationImpl* app_impl, | 19 TestServiceImpl::TestServiceImpl(ApplicationImpl* app_impl, |
19 TestServiceApplication* application, | 20 TestServiceApplication* application, |
20 InterfaceRequest<TestService> request) | 21 InterfaceRequest<TestService> request) |
(...skipping 15 matching lines...) Expand all Loading... |
36 | 37 |
37 void SendTimeResponse( | 38 void SendTimeResponse( |
38 const mojo::Callback<void(int64_t)>& requestor_callback, | 39 const mojo::Callback<void(int64_t)>& requestor_callback, |
39 int64_t time_usec) { | 40 int64_t time_usec) { |
40 requestor_callback.Run(time_usec); | 41 requestor_callback.Run(time_usec); |
41 } | 42 } |
42 | 43 |
43 void TestServiceImpl::ConnectToAppAndGetTime( | 44 void TestServiceImpl::ConnectToAppAndGetTime( |
44 const mojo::String& app_url, | 45 const mojo::String& app_url, |
45 const mojo::Callback<void(int64_t)>& callback) { | 46 const mojo::Callback<void(int64_t)>& callback) { |
46 app_impl_->ConnectToServiceDeprecated(app_url, &time_service_); | 47 ConnectToService(app_impl_->shell(), app_url, GetProxy(&time_service_)); |
47 if (tracking_) { | 48 if (tracking_) { |
48 tracking_->RecordNewRequest(); | 49 tracking_->RecordNewRequest(); |
49 time_service_->StartTrackingRequests(mojo::Callback<void()>()); | 50 time_service_->StartTrackingRequests(mojo::Callback<void()>()); |
50 } | 51 } |
51 time_service_->GetPartyTime(base::Bind(&SendTimeResponse, callback)); | 52 time_service_->GetPartyTime(base::Bind(&SendTimeResponse, callback)); |
52 } | 53 } |
53 | 54 |
54 void TestServiceImpl::StartTrackingRequests( | 55 void TestServiceImpl::StartTrackingRequests( |
55 const mojo::Callback<void()>& callback) { | 56 const mojo::Callback<void()>& callback) { |
56 TestRequestTrackerPtr tracker; | 57 TestRequestTrackerPtr tracker; |
57 app_impl_->ConnectToServiceDeprecated("mojo:test_request_tracker_app", | 58 ConnectToService(app_impl_->shell(), "mojo:test_request_tracker_app", |
58 &tracker); | 59 GetProxy(&tracker)); |
59 tracking_.reset(new TrackedService(tracker.Pass(), Name_, callback)); | 60 tracking_.reset(new TrackedService(tracker.Pass(), Name_, callback)); |
60 } | 61 } |
61 | 62 |
62 } // namespace test | 63 } // namespace test |
63 } // namespace mojo | 64 } // namespace mojo |
OLD | NEW |