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 #ifndef MOJO_APPLICATION_APP_LIFETIME_HELPER_H_ | |
6 #define MOJO_APPLICATION_APP_LIFETIME_HELPER_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 | |
11 namespace mojo { | |
12 | |
13 class AppLifetimeHelper; | |
14 | |
15 class ServiceRefcount { | |
16 public: | |
17 ServiceRefcount(AppLifetimeHelper* app_lifetime_helper); | |
Ben Goodger (Google)
2015/05/13 20:21:07
explicit
jam
2015/05/14 14:42:47
Done.
| |
18 ~ServiceRefcount(); | |
19 | |
20 private: | |
21 AppLifetimeHelper* app_lifetime_helper_; | |
22 | |
23 DISALLOW_COPY_AND_ASSIGN(ServiceRefcount); | |
24 }; | |
25 | |
26 // This is a helper class for apps to manage their lifetime. | |
27 // An app can contain an object of this class as a member variable. Each time it | |
28 // creates an instance of a service, it gives it a refcount using | |
29 // CreateServiceRefCount. The service implementation then keeps that object as a | |
30 // member variable. When all the service implemenations go away, the app will be | |
31 // quit with a call to mojo::ApplicationImpl::Terminate(). | |
32 class AppLifetimeHelper { | |
33 public: | |
34 AppLifetimeHelper(); | |
35 ~AppLifetimeHelper(); | |
36 | |
37 scoped_ptr<ServiceRefcount> CreateServiceRefCount(); | |
38 | |
39 private: | |
40 friend ServiceRefcount; | |
41 void Release(); | |
42 | |
43 int ref_count_; | |
44 DISALLOW_COPY_AND_ASSIGN(AppLifetimeHelper); | |
45 }; | |
46 | |
47 } // namespace mojo | |
48 | |
49 #endif // MOJO_APPLICATION_APP_LIFETIME_HELPER_H_ | |
OLD | NEW |