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

Unified Diff: athena/content/app_activity.cc

Issue 477523002: Athena: Adding basic resource management framework (un-/re-loading) of V2 applications (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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 c90daffa625e253e3498cdb11b9dd0ea6e9de7ca..a6a595a31ee12ea520ce0470fb57fa97e39bb838 100644
--- a/athena/content/app_activity.cc
+++ b/athena/content/app_activity.cc
@@ -5,9 +5,13 @@
#include "athena/content/app_activity.h"
#include "athena/activity/public/activity_manager.h"
+#include "athena/content/app_activity_registry.h"
+#include "athena/content/public/app_content_delegate.h"
+#include "athena/content/public/app_registry.h"
#include "content/public/browser/web_contents.h"
#include "extensions/shell/browser/shell_app_window.h"
#include "ui/views/controls/webview/webview.h"
+#include "ui/views/widget/widget.h"
namespace athena {
@@ -15,13 +19,14 @@ namespace athena {
AppActivity::AppActivity(extensions::ShellAppWindow* app_window)
: app_window_(app_window),
web_view_(NULL),
- current_state_(ACTIVITY_UNLOADED) {
- DCHECK(app_window_);
+ current_state_(ACTIVITY_UNLOADED),
+ app_activity_registry_(NULL) {
}
AppActivity::~AppActivity() {
- if (GetCurrentState() != ACTIVITY_UNLOADED)
- SetCurrentState(ACTIVITY_UNLOADED);
+ // If this activity is registered, we unregister it now.
+ if (app_activity_registry_)
+ app_activity_registry_->UnregisterAppActivity(this);
}
ActivityViewModel* AppActivity::GetActivityViewModel() {
@@ -29,35 +34,41 @@ ActivityViewModel* AppActivity::GetActivityViewModel() {
}
void AppActivity::SetCurrentState(Activity::ActivityState state) {
+ ActivityState current_state = state;
+ // Remember the last requested state now so that a call to GetCurrentState()
+ // returns the new state.
+ current_state_ = 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.
+ // Note: A reload from the unloaded state will be performed through the
+ // |AppActivityProxy| object and no further action isn't necessary here.
break;
case ACTIVITY_BACKGROUND_LOW_PRIORITY:
- DCHECK(ACTIVITY_VISIBLE == current_state_ ||
- ACTIVITY_INVISIBLE == current_state_);
+ 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_);
+ 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();
+ DCHECK_NE(ACTIVITY_UNLOADED, current_state);
+ // This will cause the application to shut down, close its windows and
+ // delete this object. Instead a |AppActivityProxy| will be created as
+ // place holder.
+ if (app_activity_registry_)
+ app_activity_registry_->Unload();
oshima 2014/08/15 15:15:59 Design question rather than code question: I gues
Mr4D (OOO till 08-26) 2014/08/18 16:09:32 Actually... I implemented it the way that each act
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;
@@ -82,6 +93,12 @@ Activity::ActivityMediaState AppActivity::GetMediaState() {
return Activity::ACTIVITY_MEDIA_STATE_NONE;
}
+aura::Window* AppActivity::GetWindow() {
+ if (!web_view_)
oshima 2014/08/15 15:15:59 nit: ? :
Mr4D (OOO till 08-26) 2014/08/18 16:09:32 Done.
+ return NULL;
+ return web_view_->GetWidget()->GetNativeWindow();
+}
+
void AppActivity::Init() {
}
@@ -130,4 +147,28 @@ void AppActivity::DidUpdateFaviconURL(
ActivityManager::Get()->UpdateActivity(this);
}
+void AppActivity::DidStartNavigationToPendingEntry(
+ const GURL& url,
+ content::NavigationController::ReloadType reload_type) {
+ if (!app_activity_registry_)
oshima 2014/08/15 15:15:59 can this be NULL in this callback?
Mr4D (OOO till 08-26) 2014/08/18 16:09:32 Yes upon first call the app_id is unknown since Ge
+ RegisterActivity();
+}
+
+// Register an |activity| with an application.
+// Note: This should only get called once for an |app_window| of the
+// |activity|.
+void AppActivity::RegisterActivity() {
+ if (app_activity_registry_)
+ return;
+ content::WebContents* web_contents = app_window_->GetAssociatedWebContents();
+ AppRegistry* app_registry = AppRegistry::Get();
+ // Get the application's registry.
+ app_activity_registry_ = app_registry->GetAppActivityRegistry(
+ app_registry->GetDelegate()->GetExtensionID(web_contents),
+ web_contents->GetBrowserContext());
+ DCHECK(app_activity_registry_);
+ // Register the activity.
+ app_activity_registry_->RegisterAppActivity(this);
+}
+
} // namespace athena

Powered by Google App Engine
This is Rietveld 408576698