OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ATHENA_TEST_BASE_ACTIVITY_LIFETIME_TRACKER_H_ | 5 #ifndef ATHENA_TEST_BASE_ACTIVITY_LIFETIME_TRACKER_H_ |
6 #define ATHENA_TEST_BASE_ACTIVITY_LIFETIME_TRACKER_H_ | 6 #define ATHENA_TEST_BASE_ACTIVITY_LIFETIME_TRACKER_H_ |
7 | 7 |
8 #include "athena/activity/public/activity_manager_observer.h" | 8 #include "athena/activity/public/activity_manager_observer.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 | 10 |
11 namespace athena { | 11 namespace athena { |
12 class Activity; | 12 class Activity; |
13 | 13 |
14 // Listens for activities to be started / ended and will return them. | 14 // Listens for activities to be started / ended and will return them. |
15 class ActivityLifetimeTracker : public ActivityManagerObserver { | 15 class ActivityLifetimeTracker : public ActivityManagerObserver { |
16 public: | 16 public: |
17 ActivityLifetimeTracker(); | 17 ActivityLifetimeTracker(); |
18 ~ActivityLifetimeTracker() override; | 18 ~ActivityLifetimeTracker() override; |
19 | 19 |
20 // Called after an |activity| got created. | 20 // ActivityManagerObserver: |
21 void OnActivityStarted(Activity* activity) override; | 21 void OnActivityStarted(Activity* activity) override; |
22 | |
23 // Called before an |activity| gets destroyed. | |
24 void OnActivityEnding(Activity* activity) override; | 22 void OnActivityEnding(Activity* activity) override; |
| 23 void OnActivityOrderChanged() override; |
25 | 24 |
26 // Returns the newly created activity (if any) and resets its reference. | 25 // Returns the newly created activity (if any) and resets its reference. |
27 Activity* GetNewActivityAndReset(); | 26 Activity* GetNewActivityAndReset(); |
28 | 27 |
29 // Returns a deleted activity (if any) and resets its reference. | 28 // Returns a deleted activity (if any) and resets its reference. |
30 // Note that the pointer is void* since the Activity was deleted when | 29 // Note that the pointer is void* since the Activity was deleted when |
31 // requested. | 30 // requested. |
32 void* GetDeletedActivityAndReset(); | 31 void* GetDeletedActivityAndReset(); |
33 | 32 |
34 private: | 33 private: |
35 // The activity which got created if not nullptr. | 34 // The activity which got created if not nullptr. |
36 Activity* new_activity_; | 35 Activity* new_activity_; |
37 | 36 |
38 // An old activity which got unloaded if not nullptr. | 37 // An old activity which got unloaded if not nullptr. |
39 void* deleted_activity_; | 38 void* deleted_activity_; |
40 | 39 |
41 DISALLOW_COPY_AND_ASSIGN(ActivityLifetimeTracker); | 40 DISALLOW_COPY_AND_ASSIGN(ActivityLifetimeTracker); |
42 }; | 41 }; |
43 | 42 |
44 } // namespace athena | 43 } // namespace athena |
45 | 44 |
46 #endif // ATHENA_TEST_BASE_ACTIVITY_LIFETIME_TRACKER_H_ | 45 #endif // ATHENA_TEST_BASE_ACTIVITY_LIFETIME_TRACKER_H_ |
47 | 46 |
OLD | NEW |