diff options
Diffstat (limited to 'mojo/services/test_service/test_service_application.cc')
-rw-r--r-- | mojo/services/test_service/test_service_application.cc | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/mojo/services/test_service/test_service_application.cc b/mojo/services/test_service/test_service_application.cc index c2754c2..3737823 100644 --- a/mojo/services/test_service/test_service_application.cc +++ b/mojo/services/test_service/test_service_application.cc @@ -2,28 +2,38 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "mojo/public/cpp/application/application.h" -#include "mojo/public/cpp/system/macros.h" +#include "mojo/services/test_service/test_service_application.h" + +#include <assert.h> + +#include "mojo/public/cpp/utility/run_loop.h" #include "mojo/services/test_service/test_service_impl.h" namespace mojo { namespace test { -namespace { -class TestServiceApplication : public Application { - public: - TestServiceApplication() {} - virtual ~TestServiceApplication() {} +TestServiceApplication::TestServiceApplication() : ref_count_(0) { +} - virtual void Initialize() MOJO_OVERRIDE { - AddService<TestServiceImpl>(); - } +TestServiceApplication::~TestServiceApplication() { +} - private: - MOJO_DISALLOW_COPY_AND_ASSIGN(TestServiceApplication); -}; +void TestServiceApplication::Initialize() { + AddService<TestServiceImpl>(this); +} + +void TestServiceApplication::AddRef() { + assert(ref_count_ >= 0); + ref_count_++; +} + +void TestServiceApplication::ReleaseRef() { + assert(ref_count_ > 0); + ref_count_--; + if (ref_count_ <= 0) + RunLoop::current()->Quit(); +} -} // namespace } // namespace test // static |