Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / athena / activity / public / activity.h
blobb5513bc3581fae5c84d146a6099996a8f82ef369
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_
8 #include <string>
10 #include "athena/athena_export.h"
12 namespace aura {
13 class Window;
16 namespace content {
17 class WebContents;
20 namespace athena {
22 class ActivityViewModel;
24 // This class is a high level abstraction of an activity (which could be either
25 // a web page or a V1/V2 app/extension). Through this class the activity can
26 // be controlled (e.g. loaded / unloaded).
27 // An Activity gets created with state |ACTIVITY_UNLOADED|.
28 // Requesting |ACTIVITY_VISIBLE| or |ACTIVITY_INVISIBLE| will load it.
29 // Once an activity was |ACTIVITY_INVISIBLE| for a while it can be transitioned
30 // into |ACTIVITY_BACKGROUND_LOW_PRIORITY| to surrender more resources. After
31 // more time it can be transitions to |ACTIVITY_PERSISTENT| in which it only
32 // has it's runtime state left. At any time it can be transitioned back to one
33 // of the higher levels or unloaded via |ACTIVITY_UNLOADED|.
34 // Note that the resource manager will also query the media state before
35 // deciding if an activity can put into a lower state then |ACTIVITY_INVISIBLE|.
36 class ATHENA_EXPORT Activity {
37 public:
38 // The state of an activity which could either be set or requested by e.g. the
39 // resource management system.
40 enum ActivityState {
41 // The activity is allowed to have gpu compositor layers and can be visible.
42 ACTIVITY_VISIBLE,
43 // The activity does not have gpu compositing layers, will not be visible
44 // and will be treated as a background priority task.
45 // By transitioning from VISIBLE to INVISIBLE, a screen shot of the current
46 // web content will be taken and replaces the "active content".
47 ACTIVITY_INVISIBLE,
48 // The activity should surrender additional resources. This has only an
49 // effect when the activity is in a loaded state (Visible, Active, Hidden).
50 ACTIVITY_BACKGROUND_LOW_PRIORITY,
51 // The activity will only keep a minimum set of resources to get back to the
52 // running state. It will get stalled however. Note that it is not possible
53 // to get into this state from the |ACTIVITY_UNLOADED| state.
54 ACTIVITY_PERSISTENT,
55 // Unloads the activity and can be called in any state - but unloaded.
56 ACTIVITY_UNLOADED
59 // This enum declares the media state the activity is in.
60 // TODO(skuhne): Move the |TabMediaState| out of chrome and combine it in a
61 // media library within content and then use that enum instead.
62 enum ActivityMediaState {
63 ACTIVITY_MEDIA_STATE_NONE,
64 ACTIVITY_MEDIA_STATE_RECORDING, // Audio/Video being recorded by activity.
65 ACTIVITY_MEDIA_STATE_CAPTURING, // Activity is being captured.
66 ACTIVITY_MEDIA_STATE_AUDIO_PLAYING // Audible audio is playing in activity.
69 // Shows and activates an activity.
70 static void Show(Activity* activity);
72 // Deletes an activity.
73 static void Delete(Activity* activity);
75 // The Activity retains ownership of the returned view-model.
76 virtual ActivityViewModel* GetActivityViewModel() = 0;
78 // Transition the activity into a new state.
79 virtual void SetCurrentState(ActivityState state) = 0;
81 // Returns the current state of the activity.
82 virtual ActivityState GetCurrentState() = 0;
84 // Returns if the activity is visible or not.
85 virtual bool IsVisible() = 0;
87 // Returns the current media state.
88 virtual ActivityMediaState GetMediaState() = 0;
90 // Returns the window for the activity. This can be used to determine the
91 // stacking order of this activity against others.
92 // TODO(oshima): Consider returning base::Window window instead,
93 // which has Show/ShowInactive and other control methods.
94 virtual aura::Window* GetWindow() = 0;
96 // Returns the web contents used to draw the content of the activity.
97 // This may return nullptr if the web content is not available.
98 virtual content::WebContents* GetWebContents() = 0;
100 protected:
101 virtual ~Activity() {}
104 } // namespace athena
106 #endif // ATHENA_ACTIVITY_PUBLIC_ACTIVITY_H_