Chromium Code Reviews| 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_ACTIVITY_PUBLIC_ACTIVITY_H_ | 5 #ifndef ATHENA_ACTIVITY_PUBLIC_ACTIVITY_H_ |
| 6 #define ATHENA_ACTIVITY_PUBLIC_ACTIVITY_H_ | 6 #define ATHENA_ACTIVITY_PUBLIC_ACTIVITY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "athena/athena_export.h" | 10 #include "athena/athena_export.h" |
| 11 | 11 |
| 12 namespace athena { | 12 namespace athena { |
| 13 | 13 |
| 14 class ActivityViewModel; | 14 class ActivityViewModel; |
| 15 | 15 |
| 16 // This class is a high level abstraction of an activity (which could be either | |
| 17 // a web page or a V1/V2 app/extension). Through this class the activity can | |
| 18 // be controlled (e.g. loaded / unloaded). | |
| 19 // When an Activity gets created, it has the state "ACTIVITY_STATE_UNLOADED". | |
| 20 // To load the activity the |ACTIVITY_LOAD| state transition needs to be called. | |
| 21 // Destroying an Activity will call "ACTIVITY_UNLOAD" if required. | |
| 22 // An invisible activity uses less resources then a visible one and progressing | |
| 23 // through subsequent state transitions (HIDE -> DEEP_SLEEP_1 -> DEEP_SLEEP_2) | |
| 24 // will reduce the resources even more. | |
| 25 // An Activity which uses other media then the screen - like e.g. audio - can | |
| 26 // remain |ACTIVITY_STATE_ACTIVE| not allowing to release any further resources. | |
| 16 class ATHENA_EXPORT Activity { | 27 class ATHENA_EXPORT Activity { |
| 17 public: | 28 public: |
| 29 // The state the activity is in. | |
| 30 enum ActivityState { | |
| 31 // The activity is not loaded/running. | |
| 32 ACTIVITY_STATE_UNLOADED, | |
| 33 // The activity is visible on a screen. | |
| 34 ACTIVITY_STATE_VISIBLE, | |
| 35 // The activity is not visible, but it is active e.g. by streaming audio. | |
| 36 ACTIVITY_STATE_BACKGROUND_ACTIVE, | |
| 37 // The activity is hidden but still active by playing audio. | |
| 38 ACTIVITY_STATE_HIDDEN, | |
| 39 // The activity has given up some resources which increases time to regain a | |
| 40 // visible state. | |
| 41 ACTIVITY_STATE_DEEP_SLEEP_1, | |
| 42 // The activity has given up all re-creatable resources and might take a | |
| 43 // considerable time to regain a visible state. | |
| 44 ACTIVITY_STATE_DEEP_SLEEP_2 | |
| 45 }; | |
|
oshima
2014/07/11 18:02:59
As per discussion, I'd recommend to start with hou
Mr4D (OOO till 08-26)
2014/07/11 22:38:08
Changed as discussed
| |
| 46 | |
| 47 // The state an activity should be in as requested by e.g. the resource | |
| 48 // management system. | |
| 49 enum ActivityStateTransition { | |
| 50 // (Re-)load the activity for the first time or after eviction. Note that | |
| 51 // a visibility change does not necessarily trigger a reload. | |
| 52 ACTIVITY_LOAD, | |
| 53 // The activity should surrender additional resources. This has only an | |
| 54 // effect when the activity is in a loaded state (Visible, Active, Hidden). | |
| 55 ACTIVITY_DEEP_SLEEP_1, | |
| 56 // The activity should surrender all re-creatable resources. This has only | |
| 57 // an effect when the activity is currently in ACTIVITY_DEEP_SLEEP_1. | |
| 58 ACTIVITY_DEEP_SLEEP_2, | |
| 59 // Unloads the activity and can be called in any state - but unloaded. | |
| 60 ACTIVITY_UNLOAD | |
| 61 }; | |
| 62 | |
| 18 virtual ~Activity(); | 63 virtual ~Activity(); |
| 19 | 64 |
| 20 // The Activity retains ownership of the returned view-model. | 65 // The Activity retains ownership of the returned view-model. |
| 21 virtual ActivityViewModel* GetActivityViewModel() = 0; | 66 virtual ActivityViewModel* GetActivityViewModel() = 0; |
| 67 | |
| 68 // Transition the activity into a new state. | |
| 69 virtual void SetCurrentState(ActivityStateTransition state) = 0; | |
| 70 | |
| 71 // Returns the current state of the activity. | |
| 72 virtual ActivityState GetCurrentState() = 0; | |
| 22 }; | 73 }; |
| 23 | 74 |
| 24 } // namespace athena | 75 } // namespace athena |
| 25 | 76 |
| 26 #endif // ATHENA_ACTIVITY_PUBLIC_ACTIVITY_H_ | 77 #endif // ATHENA_ACTIVITY_PUBLIC_ACTIVITY_H_ |
| OLD | NEW |