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 // An Activity gets created with state |ACTIVITY_UNLOADED|. |
| 20 // Requesting |ACTIVITY_VISIBLE| or |ACTIVITY_INVISIBLE| will load it. |
| 21 // Once an activity was |ACTIVITY_INVISIBLE| for a while it can be transitioned |
| 22 // into |ACTIVITY_BACKGROUND_LOW_PRIORITY| to surrender more resources. After |
| 23 // more time it can be transitions to |ACTIVITY_PERSISTENT| in which it only |
| 24 // has it's runtime state left. At any time it can be transitioned back to one |
| 25 // of the higher levels or unloaded via |ACTIVITY_UNLOADED|. |
| 26 // Note that the resource manager will also query the media state before |
| 27 // deciding if an activity can put into a lower state then |ACTIVITY_INVISIBLE|. |
16 class ATHENA_EXPORT Activity { | 28 class ATHENA_EXPORT Activity { |
17 public: | 29 public: |
| 30 // The state of an activity which could either be set or requested by e.g. the |
| 31 // resource management system. |
| 32 enum ActivityState { |
| 33 // The activity is allowed to have gpu compositor layers and can be visible. |
| 34 ACTIVITY_VISIBLE, |
| 35 // The activity does not have gpu compositing layers, will not be visible |
| 36 // and will be treated as a background priority task. |
| 37 ACTIVITY_INVISIBLE, |
| 38 // The activity should surrender additional resources. This has only an |
| 39 // effect when the activity is in a loaded state (Visible, Active, Hidden). |
| 40 ACTIVITY_BACKGROUND_LOW_PRIORITY, |
| 41 // The activity will only keep a minimum set of resources to get back to the |
| 42 // running state. It will get stalled however. Note that it is not possible |
| 43 // to get into this state from the |ACTIVITY_UNLOADED| state. |
| 44 ACTIVITY_PERSISTENT, |
| 45 // Unloads the activity and can be called in any state - but unloaded. |
| 46 ACTIVITY_UNLOADED |
| 47 }; |
| 48 |
| 49 // This enum declares the media state the activity is in. |
| 50 // TODO(skuhne): Move the |TabMediaState| out of chrome and combine it in a |
| 51 // media library within content and then use that enum instead. |
| 52 enum ActivityMediaState { |
| 53 ACTIVITY_MEDIA_STATE_NONE, |
| 54 ACTIVITY_MEDIA_STATE_RECORDING, // Audio/Video being recorded by activity. |
| 55 ACTIVITY_MEDIA_STATE_CAPTURING, // Activity is being captured. |
| 56 ACTIVITY_MEDIA_STATE_AUDIO_PLAYING // Audible audio is playing in activity. |
| 57 }; |
| 58 |
18 virtual ~Activity(); | 59 virtual ~Activity(); |
19 | 60 |
20 // The Activity retains ownership of the returned view-model. | 61 // The Activity retains ownership of the returned view-model. |
21 virtual ActivityViewModel* GetActivityViewModel() = 0; | 62 virtual ActivityViewModel* GetActivityViewModel() = 0; |
| 63 |
| 64 // Transition the activity into a new state. |
| 65 virtual void SetCurrentState(ActivityState state) = 0; |
| 66 |
| 67 // Returns the current state of the activity. |
| 68 virtual ActivityState GetCurrentState() = 0; |
| 69 |
| 70 // Returns if the activity is visible or not. |
| 71 virtual bool IsVisible() = 0; |
| 72 |
| 73 // Returns the current media state. |
| 74 virtual ActivityMediaState GetMediaState() = 0; |
22 }; | 75 }; |
23 | 76 |
24 } // namespace athena | 77 } // namespace athena |
25 | 78 |
26 #endif // ATHENA_ACTIVITY_PUBLIC_ACTIVITY_H_ | 79 #endif // ATHENA_ACTIVITY_PUBLIC_ACTIVITY_H_ |
OLD | NEW |