Index: mojo/services/test_service/test_service_application.cc |
diff --git a/mojo/services/test_service/test_service_application.cc b/mojo/services/test_service/test_service_application.cc |
index c2754c21f41d0ac8f519adb6ce45e8dba268a643..3737823c9d2947b78a8f9179eee970395033c85c 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 |