Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: mojo/application/app_lifetime_helper.h

Issue 1139673003: Make Mandoline shut down cleanly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix crash in surfaces if surfaceimpl outlives the app, and a double delete in browser Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698