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/application/public/cpp/application_connection.h"
10 #include "mojo/application/public/cpp/application_runner.h"
11 #include "mojo/public/c/system/main.h"
12 #include "mojo/services/test_service/test_service_impl.h"
13 #include "mojo/services/test_service/test_time_service_impl.h"
18 TestServiceApplication::TestServiceApplication()
19 : ref_count_(0), app_impl_(nullptr) {
22 TestServiceApplication::~TestServiceApplication() {
25 void TestServiceApplication::Initialize(ApplicationImpl
* app
) {
29 bool TestServiceApplication::ConfigureIncomingConnection(
30 ApplicationConnection
* connection
) {
31 connection
->AddService
<TestService
>(this);
32 connection
->AddService
<TestTimeService
>(this);
36 void TestServiceApplication::Create(ApplicationConnection
* connection
,
37 InterfaceRequest
<TestService
> request
) {
38 new TestServiceImpl(app_impl_
, this, request
.Pass());
42 void TestServiceApplication::Create(ApplicationConnection
* connection
,
43 InterfaceRequest
<TestTimeService
> request
) {
44 new TestTimeServiceImpl(app_impl_
, request
.Pass());
47 void TestServiceApplication::AddRef() {
48 assert(ref_count_
>= 0);
52 void TestServiceApplication::ReleaseRef() {
53 assert(ref_count_
> 0);
56 base::MessageLoop::current()->Quit();
62 MojoResult
MojoMain(MojoHandle shell_handle
) {
63 mojo::ApplicationRunner
runner(new mojo::test::TestServiceApplication
);
64 return runner
.Run(shell_handle
);