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

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: Created 6 years, 6 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 e25d9f32150ee89bbdd5fc35b51fe32404376099..26ad239ec24c5b873656e6e4107e78e2a867d91b 100644
--- a/athena/content/app_activity.cc
+++ b/athena/content/app_activity.cc
@@ -13,17 +13,81 @@ 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),
+ last_requested_state_(ACTIVITY_UNLOAD) {
DCHECK(app_window_);
}
AppActivity::~AppActivity() {
+ if (GetCurrentState() != ACTIVITY_STATE_UNLOADED)
+ SetCurrentState(ACTIVITY_UNLOAD);
}
ActivityViewModel* AppActivity::GetActivityViewModel() {
return this;
}
+void WebActivity::SetCurrentState(ActivityStateTranstion state) {
+ switch (state) {
+ case ACTIVITY_LOAD:
+ // 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.
+// if (web_view_->IsContentEvicted()) {
+// DCHECK_EQ(ACTIVITY_UNLOAD, last_requested_state_);
+// web_view_->ReloadContent();
+// }
+ break;
+ case ACTIVITY_DEEP_SLEEP_1:
+ DCHECK_EQ(ACTIVITY_LOAD, last_requested_state_);
+ // TODO(skuhne): Do this. As soon as the new resource management is
+ // agreed upon - or remove otherwise.
+ break;
+ case ACTIVITY_DEEP_SLEEP_2:
+ DCHECK_EQ(ACTIVITY_DEEP_SLEEP_1, last_requested_state_);
+ // TODO(skuhne): Do this. As soon as the new resource management is
+ // agreed upon - or remove otherwise.
+ break;
+ case ACTIVITY_UNLOAD:
+ DCHECK_NE(ACTIVITY_UNLOAD, last_requested_state_);
+// TODO(skuhne): Find out how to evict an app from the extension system.
+// web_view_->EvictContent();
+ break;
+ }
+ // Remember the last requested state.
+ last_requested_state_ = state;
+}
+
+ActivityState WebActivity::GetCurrentState() {
+ if (!web_view_) {
+ DCHECK_EQ(ACTIVITY_UNLOAD, last_requested_state_);
+ return ACTIVITY_STATE_UNLOADED;
+ }
+
+ switch(last_requested_state_) {
+ case ACTIVITY_LOAD:
+ if (web_view_->IsDrawn())
+ return ACTIVITY_STATE_VISIBLE;
+ /*
+ // TODO(skuhne): AudioStreamMonitor is currently a part of Chrome and
+ // needs to be moved some levels up.
+ AudioStreamMonitor* const audio_stream_monitor =
+ AudioStreamMonitor::FromWebContents(contents);
+ if (audio_stream_monitor && audio_stream_monitor->WasRecentlyAudible())
+ return ACTIVITY_STATE_ACTIVE;
+ */
+ return ACTIVITY_STATE_HIDDEN;
+ case ACTIVITY_DEEP_SLEEP_1:
+ return ACTIVITY_DEEP_SLEEP_1;
+ case ACTIVITY_DEEP_SLEEP_2:
+ return ACTIVITY_DEEP_SLEEP_2;
+ case ACTIVITY_UNLOAD:
+ return ACTIVITY_STATE_UNLOADED;
+ }
+}
+
void AppActivity::Init() {
}
@@ -42,7 +106,9 @@ views::View* AppActivity::GetContentsView() {
app_window_->GetAssociatedWebContents();
web_view_ = new views::WebView(web_contents->GetBrowserContext());
web_view_->SetWebContents(web_contents);
+ SetCurrentState(ACTIVITY_LOAD);
Observe(web_contents);
+ overview_mode_image_ = gfx::ImageSkia();
}
return web_view_;
}
@@ -57,4 +123,12 @@ void AppActivity::DidUpdateFaviconURL(
ActivityManager::Get()->UpdateActivity(this);
}
+void AppActivity::CreateOverviewModeImage() {
+ // TODO(skuhne): Implement this!
+}
+
+const gfx::ImageSkia AppActivity::GetOverviewModeImage() {
+ return overview_mode_image_;
+}
+
} // namespace athena

Powered by Google App Engine
This is Rietveld 408576698