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
3 // found in the LICENSE file.
5 #include "mojo/services/test_service/test_service_application.h"
9 #include "mojo/public/c/system/main.h"
10 #include "mojo/public/cpp/application/application_connection.h"
11 #include "mojo/public/cpp/application/application_runner.h"
12 #include "mojo/public/cpp/utility/run_loop.h"
13 #include "mojo/services/test_service/test_service_impl.h"
14 #include "mojo/services/test_service/test_time_service_impl.h"
19 TestServiceApplication::TestServiceApplication() : ref_count_(0) {
22 TestServiceApplication::~TestServiceApplication() {
25 bool TestServiceApplication::ConfigureIncomingConnection(
26 ApplicationConnection
* connection
) {
27 connection
->AddService
<TestService
>(this);
28 connection
->AddService
<TestTimeService
>(this);
32 void TestServiceApplication::Create(ApplicationConnection
* connection
,
33 InterfaceRequest
<TestService
> request
) {
34 BindToRequest(new TestServiceImpl(connection
, this), &request
);
37 void TestServiceApplication::Create(ApplicationConnection
* connection
,
38 InterfaceRequest
<TestTimeService
> request
) {
39 BindToRequest(new TestTimeServiceImpl(connection
), &request
);
42 void TestServiceApplication::AddRef() {
43 assert(ref_count_
>= 0);
47 void TestServiceApplication::ReleaseRef() {
48 assert(ref_count_
> 0);
51 RunLoop::current()->Quit();
57 MojoResult
MojoMain(MojoHandle shell_handle
) {
58 mojo::ApplicationRunner
runner(new mojo::test::TestServiceApplication
);
59 return runner
.Run(shell_handle
);