| 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_service_impl.h" | 5 #include "mojo/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/application/public/cpp/application_impl.h" | 10 #include "mojo/application/public/cpp/application_impl.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 void SendTimeResponse( | 37 void SendTimeResponse( |
| 38 const mojo::Callback<void(int64_t)>& requestor_callback, | 38 const mojo::Callback<void(int64_t)>& requestor_callback, |
| 39 int64_t time_usec) { | 39 int64_t time_usec) { |
| 40 requestor_callback.Run(time_usec); | 40 requestor_callback.Run(time_usec); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void TestServiceImpl::ConnectToAppAndGetTime( | 43 void TestServiceImpl::ConnectToAppAndGetTime( |
| 44 const mojo::String& app_url, | 44 const mojo::String& app_url, |
| 45 const mojo::Callback<void(int64_t)>& callback) { | 45 const mojo::Callback<void(int64_t)>& callback) { |
| 46 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 46 app_impl_->ConnectToService(app_url.get(), &time_service_); |
| 47 request->url = mojo::String::From(app_url); | |
| 48 app_impl_->ConnectToService(request.Pass(), &time_service_); | |
| 49 if (tracking_) { | 47 if (tracking_) { |
| 50 tracking_->RecordNewRequest(); | 48 tracking_->RecordNewRequest(); |
| 51 time_service_->StartTrackingRequests(mojo::Callback<void()>()); | 49 time_service_->StartTrackingRequests(mojo::Callback<void()>()); |
| 52 } | 50 } |
| 53 time_service_->GetPartyTime(base::Bind(&SendTimeResponse, callback)); | 51 time_service_->GetPartyTime(base::Bind(&SendTimeResponse, callback)); |
| 54 } | 52 } |
| 55 | 53 |
| 56 void TestServiceImpl::StartTrackingRequests( | 54 void TestServiceImpl::StartTrackingRequests( |
| 57 const mojo::Callback<void()>& callback) { | 55 const mojo::Callback<void()>& callback) { |
| 58 TestRequestTrackerPtr tracker; | 56 TestRequestTrackerPtr tracker; |
| 59 mojo::URLRequestPtr request(mojo::URLRequest::New()); | 57 app_impl_->ConnectToService("mojo:test_request_tracker_app", &tracker); |
| 60 request->url = mojo::String::From("mojo:test_request_tracker_app"); | |
| 61 app_impl_->ConnectToService(request.Pass(), &tracker); | |
| 62 tracking_.reset(new TrackedService(tracker.Pass(), Name_, callback)); | 58 tracking_.reset(new TrackedService(tracker.Pass(), Name_, callback)); |
| 63 } | 59 } |
| 64 | 60 |
| 65 } // namespace test | 61 } // namespace test |
| 66 } // namespace mojo | 62 } // namespace mojo |
| OLD | NEW |