Home | History | Annotate | Download | only in test_service
      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.
      4 
      5 #include "mojo/services/test_service/test_service_application.h"
      6 
      7 #include <assert.h>
      8 
      9 #include "mojo/public/cpp/utility/run_loop.h"
     10 #include "mojo/services/test_service/test_service_impl.h"
     11 
     12 namespace mojo {
     13 namespace test {
     14 
     15 TestServiceApplication::TestServiceApplication() : ref_count_(0) {
     16 }
     17 
     18 TestServiceApplication::~TestServiceApplication() {
     19 }
     20 
     21 void TestServiceApplication::Initialize() {
     22   AddService<TestServiceImpl>(this);
     23 }
     24 
     25 void TestServiceApplication::AddRef() {
     26   assert(ref_count_ >= 0);
     27   ref_count_++;
     28 }
     29 
     30 void TestServiceApplication::ReleaseRef() {
     31   assert(ref_count_ > 0);
     32   ref_count_--;
     33   if (ref_count_ <= 0)
     34     RunLoop::current()->Quit();
     35 }
     36 
     37 }  // namespace test
     38 
     39 // static
     40 Application* Application::Create() {
     41   return new mojo::test::TestServiceApplication();
     42 }
     43 
     44 }  // namespace mojo
     45