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
3 // found in the LICENSE file.
5 #ifndef ATHENA_ACTIVITY_PUBLIC_ACTIVITY_H_
6 #define ATHENA_ACTIVITY_PUBLIC_ACTIVITY_H_
10 #include "athena/athena_export.h"
14 class ActivityViewModel;
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|.
28 class ATHENA_EXPORT Activity {
30 // The state of an activity which could either be set or requested by e.g. the
31 // resource management system.
33 // The activity is allowed to have gpu compositor layers and can be visible.
35 // The activity does not have gpu compositing layers, will not be visible
36 // and will be treated as a background priority task.
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.
45 // Unloads the activity and can be called in any state - but unloaded.
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.
61 // The Activity retains ownership of the returned view-model.
62 virtual ActivityViewModel* GetActivityViewModel() = 0;
64 // Transition the activity into a new state.
65 virtual void SetCurrentState(ActivityState state) = 0;
67 // Returns the current state of the activity.
68 virtual ActivityState GetCurrentState() = 0;
70 // Returns if the activity is visible or not.
71 virtual bool IsVisible() = 0;
73 // Returns the current media state.
74 virtual ActivityMediaState GetMediaState() = 0;
79 #endif // ATHENA_ACTIVITY_PUBLIC_ACTIVITY_H_