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

Unified Diff: athena/content/app_activity_registry.h

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_registry.h
diff --git a/athena/content/app_activity_registry.h b/athena/content/app_activity_registry.h
new file mode 100644
index 0000000000000000000000000000000000000000..3ef37168856691ae093827c4c518762915a812b6
--- /dev/null
+++ b/athena/content/app_activity_registry.h
@@ -0,0 +1,92 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ATHENA_CONTENT_APP_ACTIVITY_REGISTRY_H_
+#define ATHENA_CONTENT_APP_ACTIVITY_REGISTRY_H_
+
+#include <vector>
+
+#include "athena/activity/public/activity_view_model.h"
+#include "athena/content/app_activity_proxy.h"
+
+namespace aura {
+class Window;
+}
+
+namespace content {
+class BrowserContext;
+}
+
+namespace athena {
+
+class AppActivity;
+
+// This class keeps track of all existing |AppActivity|s and shuts down all of
+// them when the application gets unloaded to save memory. It will then replace
+// the |AppActivity| in the Activity list as proxy to allow restarting of the
+// application.
+class AppActivityRegistry {
oshima 2014/08/15 15:15:59 Isn't it possible to generalize this for both app
Mr4D (OOO till 08-26) 2014/08/18 16:09:32 Well... Maybe. As stated earlier in our chats, the
+ public:
+ AppActivityRegistry(const std::string& app_id,
+ content::BrowserContext* browser_context);
+ virtual ~AppActivityRegistry();
+
+ // Register an |AppActivity| with this application.
+ void RegisterAppActivity(AppActivity* app_activity);
+
+ // Unregister a previously attached |AppActivity|.
+ // Note that detaching the last |AppActivity| will delete this object - unless
+ // the resource manager was trying to unload the application.
+ // Note furthermore that Detach can be called without ever being registered.
+ void UnregisterAppActivity(AppActivity* app_activity);
+
+ // Returns the number of activities/windows with this application.
+ int NumberOfActivities() const { return activity_list_.size(); }
+
+ // Unload all application associated activities to save resources.
+ void Unload();
+
+ // Returns true if the application is in the unloaded state.
+ bool IsUnloaded() { return unloaded_activity_proxy_ != NULL; }
+
+ content::BrowserContext* browser_context() { return browser_context_; }
+ const std::string& app_id() { return app_id_; }
oshima 2014/08/15 15:15:59 const
Mr4D (OOO till 08-26) 2014/08/18 16:09:32 Done.
+
+ protected:
+ friend AppActivityProxy;
+
+ void ProxyDestroyed(AppActivityProxy* proxy);
+
+ // Called by the |AppActivityProxy| to restart the application upon user
+ // request.
+ void RestartApplication(AppActivityProxy* proxy);
+
+ private:
+ // Find the most recently used window of the application.
+ aura::Window* FindMruApplicationWindow();
+
+ // A list of all activities associated with this application.
+ std::vector<AppActivity*> activity_list_;
+
+ // The application id for this proxy.
+ std::string app_id_;
+
+ // The browser context of the user.
+ content::BrowserContext* browser_context_;
+
+ // When the activity is unloaded this is the AppActivityProxy. The object is
+ // owned the the ActivityManager.
+ AppActivityProxy* unloaded_activity_proxy_;
+
+ // The presentation values.
+ SkColor color_;
+ base::string16 title_;
+ gfx::ImageSkia image_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppActivityRegistry);
+};
+
+} // namespace athena
+
+#endif // ATHENA_CONTENT_APP_ACTIVITY_REGISTRY_H_

Powered by Google App Engine
This is Rietveld 408576698