| 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_application.h" | 5 #include "mojo/services/test_service/test_service_application.h" |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 | 8 |
| 9 #include "mojo/public/c/system/main.h" | 9 #include "mojo/public/c/system/main.h" |
| 10 #include "mojo/public/cpp/application/application_connection.h" | 10 #include "mojo/public/cpp/application/application_connection.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 bool TestServiceApplication::ConfigureIncomingConnection( | 25 bool TestServiceApplication::ConfigureIncomingConnection( |
| 26 ApplicationConnection* connection) { | 26 ApplicationConnection* connection) { |
| 27 connection->AddService<TestService>(this); | 27 connection->AddService<TestService>(this); |
| 28 connection->AddService<TestTimeService>(this); | 28 connection->AddService<TestTimeService>(this); |
| 29 return true; | 29 return true; |
| 30 } | 30 } |
| 31 | 31 |
| 32 void TestServiceApplication::Create(ApplicationConnection* connection, | 32 void TestServiceApplication::Create(ApplicationConnection* connection, |
| 33 InterfaceRequest<TestService> request) { | 33 InterfaceRequest<TestService> request) { |
| 34 BindToRequest(new TestServiceImpl(connection, this), &request); | 34 BindToRequest(new TestServiceImpl(connection, this), &request); |
| 35 AddRef(); |
| 35 } | 36 } |
| 36 | 37 |
| 37 void TestServiceApplication::Create(ApplicationConnection* connection, | 38 void TestServiceApplication::Create(ApplicationConnection* connection, |
| 38 InterfaceRequest<TestTimeService> request) { | 39 InterfaceRequest<TestTimeService> request) { |
| 39 BindToRequest(new TestTimeServiceImpl(connection), &request); | 40 new TestTimeServiceImpl(connection, request.Pass()); |
| 40 } | 41 } |
| 41 | 42 |
| 42 void TestServiceApplication::AddRef() { | 43 void TestServiceApplication::AddRef() { |
| 43 assert(ref_count_ >= 0); | 44 assert(ref_count_ >= 0); |
| 44 ref_count_++; | 45 ref_count_++; |
| 45 } | 46 } |
| 46 | 47 |
| 47 void TestServiceApplication::ReleaseRef() { | 48 void TestServiceApplication::ReleaseRef() { |
| 48 assert(ref_count_ > 0); | 49 assert(ref_count_ > 0); |
| 49 ref_count_--; | 50 ref_count_--; |
| 50 if (ref_count_ <= 0) | 51 if (ref_count_ <= 0) |
| 51 RunLoop::current()->Quit(); | 52 RunLoop::current()->Quit(); |
| 52 } | 53 } |
| 53 | 54 |
| 54 } // namespace test | 55 } // namespace test |
| 55 } // namespace mojo | 56 } // namespace mojo |
| 56 | 57 |
| 57 MojoResult MojoMain(MojoHandle shell_handle) { | 58 MojoResult MojoMain(MojoHandle shell_handle) { |
| 58 mojo::ApplicationRunner runner(new mojo::test::TestServiceApplication); | 59 mojo::ApplicationRunner runner(new mojo::test::TestServiceApplication); |
| 59 return runner.Run(shell_handle); | 60 return runner.Run(shell_handle); |
| 60 } | 61 } |
| OLD | NEW |