Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1430)

Unified Diff: athena/content/app_activity.cc

Issue 358003002: Additions to Activities to allow resource management (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: athena/content/app_activity.cc
diff --git a/athena/content/app_activity.cc b/athena/content/app_activity.cc
index cd32be889deb4e4ed1f89eb2adb1d5685f94b6ec..4ce94fe21df63612c26e9e303fdc1d024ae00512 100644
--- a/athena/content/app_activity.cc
+++ b/athena/content/app_activity.cc
@@ -13,17 +13,80 @@ namespace athena {
// TODO(mukai): specifies the same accelerators of WebActivity.
AppActivity::AppActivity(apps::ShellAppWindow* app_window)
- : app_window_(app_window), web_view_(NULL) {
+ : app_window_(app_window),
+ web_view_(NULL),
+ current_state_(ACTIVITY_UNLOADED) {
DCHECK(app_window_);
}
AppActivity::~AppActivity() {
+ if (GetCurrentState() != ACTIVITY_UNLOADED)
+ SetCurrentState(ACTIVITY_UNLOADED);
}
ActivityViewModel* AppActivity::GetActivityViewModel() {
return this;
}
+void AppActivity::SetCurrentState(Activity::ActivityState state) {
+ switch (state) {
+ case ACTIVITY_VISIBLE:
+ // Fall through (for the moment).
+ case ACTIVITY_INVISIBLE:
+ // By clearing the overview mode image we allow the content to be shown.
+ overview_mode_image_ = gfx::ImageSkia();
+// TODO(skuhne): Find out how to reload an app from the extension system.
+// If this does not work, the eviction needs to take place at a higher level.
oshima 2014/07/11 23:45:44 indent. please remove the commented out code. you
Mr4D (OOO till 08-26) 2014/07/12 01:38:38 Done.
+// if (web_view_->IsContentEvicted()) {
+// DCHECK_EQ(ACTIVITY_UNLOAD, last_requested_state_);
+// web_view_->ReloadContent();
+// }
+ break;
+ case ACTIVITY_BACKGROUND_LOW_PRIORITY:
+ DCHECK(ACTIVITY_VISIBLE == current_state_ ||
+ ACTIVITY_INVISIBLE == current_state_);
+ // TODO(skuhne): Do this.
+ break;
+ case ACTIVITY_PERSISTENT:
+ DCHECK_EQ(ACTIVITY_BACKGROUND_LOW_PRIORITY, current_state_);
+ // TODO(skuhne): Do this.
+ break;
+ case ACTIVITY_UNLOADED:
+ DCHECK_NE(ACTIVITY_UNLOADED, current_state_);
+ // TODO(skuhne): Find out how to evict an app from the extension system.
+ // web_view_->EvictContent();
+ break;
+ }
+ // Remember the last requested state.
+ current_state_ = state;
+}
+
+Activity::ActivityState AppActivity::GetCurrentState() {
+ // TODO(skuhne): Check here also eviction status.
+ if (!web_view_) {
+ DCHECK_EQ(ACTIVITY_UNLOADED, current_state_);
+ return ACTIVITY_UNLOADED;
+ }
+ // TODO(skuhne): This should be controlled by an observer and should not
+ // reside here.
+ if (IsVisible() && current_state_ != ACTIVITY_VISIBLE)
+ SetCurrentState(ACTIVITY_VISIBLE);
+ // Note: If the activity is not visible it does not necessarily mean that it
+ // does not have GPU compositor resources (yet).
+ return current_state_;
+}
+
+bool AppActivity::IsVisible() {
+ return web_view_ && web_view_->IsDrawn();
+}
+
+Activity::ActivityMediaState AppActivity::GetMediaState() {
+ // TODO(skuhne): The function GetTabMediaStateForContents(WebContents),
+ // and the AudioStreamMonitor needs to be moved from Chrome into contents to
+ // make it more modular and so that we can use it from here.
+ return Activity::ACTIVITY_MEDIA_STATE_NONE;
+}
+
void AppActivity::Init() {
}
@@ -47,11 +110,21 @@ views::View* AppActivity::GetContentsView() {
app_window_->GetAssociatedWebContents();
web_view_ = new views::WebView(web_contents->GetBrowserContext());
web_view_->SetWebContents(web_contents);
+ SetCurrentState(ACTIVITY_INVISIBLE);
Observe(web_contents);
+ overview_mode_image_ = gfx::ImageSkia();
}
return web_view_;
}
+void AppActivity::CreateOverviewModeImage() {
+ // TODO(skuhne): Implement this!
+}
+
+gfx::ImageSkia AppActivity::GetOverviewModeImage() {
+ return overview_mode_image_;
+}
+
void AppActivity::TitleWasSet(content::NavigationEntry* entry,
bool explicit_set) {
ActivityManager::Get()->UpdateActivity(this);

Powered by Google App Engine
This is Rietveld 408576698