Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / mojo / services / test_service / test_service_application.cc
blob2c1569c89cb3c69557ff01c5655558fb2cd080f7
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"
7 #include <assert.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"
15 namespace mojo {
16 namespace test {
18 TestServiceApplication::TestServiceApplication()
19 : ref_count_(0), app_impl_(nullptr) {
22 TestServiceApplication::~TestServiceApplication() {
25 void TestServiceApplication::Initialize(ApplicationImpl* app) {
26 app_impl_ = app;
29 bool TestServiceApplication::ConfigureIncomingConnection(
30 ApplicationConnection* connection) {
31 connection->AddService<TestService>(this);
32 connection->AddService<TestTimeService>(this);
33 return true;
36 void TestServiceApplication::Create(ApplicationConnection* connection,
37 InterfaceRequest<TestService> request) {
38 new TestServiceImpl(app_impl_, this, request.Pass());
39 AddRef();
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);
49 ref_count_++;
52 void TestServiceApplication::ReleaseRef() {
53 assert(ref_count_ > 0);
54 ref_count_--;
55 if (ref_count_ <= 0)
56 base::MessageLoop::current()->Quit();
59 } // namespace test
60 } // namespace mojo
62 MojoResult MojoMain(MojoHandle shell_handle) {
63 mojo::ApplicationRunner runner(new mojo::test::TestServiceApplication);
64 return runner.Run(shell_handle);