OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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/application/app_lifetime_helper.h" |
| 6 |
| 7 #include "base/time/tick_clock.h" |
| 8 #include "third_party/mojo/src/mojo/public/cpp/application/application_impl.h" |
| 9 |
| 10 namespace mojo { |
| 11 |
| 12 ServiceRefcount::ServiceRefcount(AppLifetimeHelper* app_lifetime_helper) |
| 13 : app_lifetime_helper_(app_lifetime_helper) { |
| 14 } |
| 15 |
| 16 ServiceRefcount::~ServiceRefcount() { |
| 17 app_lifetime_helper_->Release(); |
| 18 } |
| 19 |
| 20 AppLifetimeHelper::AppLifetimeHelper() : ref_count_(0) { |
| 21 } |
| 22 |
| 23 AppLifetimeHelper::~AppLifetimeHelper() { |
| 24 } |
| 25 |
| 26 scoped_ptr<ServiceRefcount> AppLifetimeHelper::CreateServiceRefCount() { |
| 27 ref_count_++; |
| 28 return make_scoped_ptr(new ServiceRefcount(this)); |
| 29 } |
| 30 |
| 31 void AppLifetimeHelper::Release() { |
| 32 if (!--ref_count_) |
| 33 ApplicationImpl::Terminate(); |
| 34 } |
| 35 |
| 36 } // namespace mojo |
OLD | NEW |