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/cpp/application/application_connection.h" | 9 #include "mojo/public/cpp/application/application_connection.h" |
10 #include "mojo/public/cpp/utility/run_loop.h" | 10 #include "mojo/public/cpp/utility/run_loop.h" |
11 #include "mojo/services/test_service/test_service_impl.h" | 11 #include "mojo/services/test_service/test_service_impl.h" |
12 #include "mojo/services/test_service/test_time_service_impl.h" | 12 #include "mojo/services/test_service/test_time_service_impl.h" |
13 | 13 |
14 namespace mojo { | 14 namespace mojo { |
15 namespace test { | 15 namespace test { |
16 | 16 |
17 TestServiceApplication::TestServiceApplication() : ref_count_(0) { | 17 TestServiceApplication::TestServiceApplication() : ref_count_(0) { |
18 } | 18 } |
19 | 19 |
20 TestServiceApplication::~TestServiceApplication() { | 20 TestServiceApplication::~TestServiceApplication() { |
21 } | 21 } |
22 | 22 |
23 bool TestServiceApplication::ConfigureIncomingConnection( | 23 bool TestServiceApplication::ConfigureIncomingConnection( |
24 ApplicationConnection* connection) { | 24 ApplicationConnection* connection) { |
25 connection->AddService<TestServiceImpl>(this); | 25 connection->AddServiceFactory<TestService>(this); |
26 connection->AddService<TestTimeServiceImpl>(); | 26 connection->AddServiceFactory<TestTimeService>(this); |
27 return true; | 27 return true; |
28 } | 28 } |
29 | 29 |
| 30 void TestServiceApplication::Create(ApplicationConnection* connection, |
| 31 InterfaceRequest<TestService> request) { |
| 32 mojo::BindToRequest(new TestServiceImpl(connection, this), &request); |
| 33 } |
| 34 |
| 35 void TestServiceApplication::Create(ApplicationConnection* connection, |
| 36 InterfaceRequest<TestTimeService> request) { |
| 37 mojo::BindToRequest(new TestTimeServiceImpl(connection), &request); |
| 38 } |
| 39 |
30 void TestServiceApplication::AddRef() { | 40 void TestServiceApplication::AddRef() { |
31 assert(ref_count_ >= 0); | 41 assert(ref_count_ >= 0); |
32 ref_count_++; | 42 ref_count_++; |
33 } | 43 } |
34 | 44 |
35 void TestServiceApplication::ReleaseRef() { | 45 void TestServiceApplication::ReleaseRef() { |
36 assert(ref_count_ > 0); | 46 assert(ref_count_ > 0); |
37 ref_count_--; | 47 ref_count_--; |
38 if (ref_count_ <= 0) | 48 if (ref_count_ <= 0) |
39 RunLoop::current()->Quit(); | 49 RunLoop::current()->Quit(); |
40 } | 50 } |
41 | 51 |
42 } // namespace test | 52 } // namespace test |
43 | 53 |
44 // static | 54 // static |
45 ApplicationDelegate* ApplicationDelegate::Create() { | 55 ApplicationDelegate* ApplicationDelegate::Create() { |
46 return new mojo::test::TestServiceApplication(); | 56 return new mojo::test::TestServiceApplication(); |
47 } | 57 } |
48 | 58 |
49 } // namespace mojo | 59 } // namespace mojo |
OLD | NEW |