| 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/public/cpp/application/application_connection.h" | 10 #include "mojo/public/cpp/application/application_connection.h" |
| 11 #include "mojo/services/test_service/test_request_tracker_client_impl.h" | 11 #include "mojo/services/test_service/test_request_tracker_client_impl.h" |
| 12 #include "mojo/services/test_service/test_service_application.h" | 12 #include "mojo/services/test_service/test_service_application.h" |
| 13 #include "mojo/services/test_service/test_time_service_impl.h" | 13 #include "mojo/services/test_service/test_time_service_impl.h" |
| 14 | 14 |
| 15 namespace mojo { | 15 namespace mojo { |
| 16 namespace test { | 16 namespace test { |
| 17 | 17 |
| 18 TestServiceImpl::TestServiceImpl(ApplicationConnection* connection, | 18 TestServiceImpl::TestServiceImpl(ApplicationConnection* connection, |
| 19 TestServiceApplication* application) | 19 TestServiceApplication* application) |
| 20 : application_(application), connection_(connection) { | 20 : application_(application), connection_(connection) { |
| 21 } | 21 } |
| 22 | 22 |
| 23 TestServiceImpl::~TestServiceImpl() { | 23 TestServiceImpl::~TestServiceImpl() { |
| 24 } | 24 } |
| 25 | 25 |
| 26 void TestServiceImpl::OnConnectionEstablished() { | |
| 27 application_->AddRef(); | |
| 28 } | |
| 29 | |
| 30 void TestServiceImpl::OnConnectionError() { | 26 void TestServiceImpl::OnConnectionError() { |
| 31 application_->ReleaseRef(); | 27 application_->ReleaseRef(); |
| 32 } | 28 } |
| 33 | 29 |
| 34 void TestServiceImpl::Ping(const mojo::Callback<void()>& callback) { | 30 void TestServiceImpl::Ping(const mojo::Callback<void()>& callback) { |
| 35 if (tracking_) | 31 if (tracking_) |
| 36 tracking_->RecordNewRequest(); | 32 tracking_->RecordNewRequest(); |
| 37 callback.Run(); | 33 callback.Run(); |
| 38 } | 34 } |
| 39 | 35 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 57 void TestServiceImpl::StartTrackingRequests( | 53 void TestServiceImpl::StartTrackingRequests( |
| 58 const mojo::Callback<void()>& callback) { | 54 const mojo::Callback<void()>& callback) { |
| 59 TestRequestTrackerPtr tracker; | 55 TestRequestTrackerPtr tracker; |
| 60 connection_->ConnectToService("mojo:test_request_tracker_app", &tracker); | 56 connection_->ConnectToService("mojo:test_request_tracker_app", &tracker); |
| 61 tracking_.reset( | 57 tracking_.reset( |
| 62 new TestRequestTrackerClientImpl(tracker.Pass(), Name_, callback)); | 58 new TestRequestTrackerClientImpl(tracker.Pass(), Name_, callback)); |
| 63 } | 59 } |
| 64 | 60 |
| 65 } // namespace test | 61 } // namespace test |
| 66 } // namespace mojo | 62 } // namespace mojo |
| OLD | NEW |