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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef ATHENA_CONTENT_APP_ACTIVITY_REGISTRY_H_
6 #define ATHENA_CONTENT_APP_ACTIVITY_REGISTRY_H_
7
8 #include <vector>
9
10 #include "athena/activity/public/activity_view_model.h"
11 #include "athena/content/app_activity_proxy.h"
12
13 namespace aura {
14 class Window;
15 }
16
17 namespace content {
18 class BrowserContext;
19 }
20
21 namespace athena {
22
23 class AppActivity;
24
25 // This class keeps track of all existing |AppActivity|s and shuts down all of
26 // them when the application gets unloaded to save memory. It will then replace
27 // the |AppActivity| in the Activity list as proxy to allow restarting of the
28 // application.
29 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
30 public:
31 AppActivityRegistry(const std::string& app_id,
32 content::BrowserContext* browser_context);
33 virtual ~AppActivityRegistry();
34
35 // Register an |AppActivity| with this application.
36 void RegisterAppActivity(AppActivity* app_activity);
37
38 // Unregister a previously attached |AppActivity|.
39 // Note that detaching the last |AppActivity| will delete this object - unless
40 // the resource manager was trying to unload the application.
41 // Note furthermore that Detach can be called without ever being registered.
42 void UnregisterAppActivity(AppActivity* app_activity);
43
44 // Returns the number of activities/windows with this application.
45 int NumberOfActivities() const { return activity_list_.size(); }
46
47 // Unload all application associated activities to save resources.
48 void Unload();
49
50 // Returns true if the application is in the unloaded state.
51 bool IsUnloaded() { return unloaded_activity_proxy_ != NULL; }
52
53 content::BrowserContext* browser_context() { return browser_context_; }
54 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.
55
56 protected:
57 friend AppActivityProxy;
58
59 void ProxyDestroyed(AppActivityProxy* proxy);
60
61 // Called by the |AppActivityProxy| to restart the application upon user
62 // request.
63 void RestartApplication(AppActivityProxy* proxy);
64
65 private:
66 // Find the most recently used window of the application.
67 aura::Window* FindMruApplicationWindow();
68
69 // A list of all activities associated with this application.
70 std::vector<AppActivity*> activity_list_;
71
72 // The application id for this proxy.
73 std::string app_id_;
74
75 // The browser context of the user.
76 content::BrowserContext* browser_context_;
77
78 // When the activity is unloaded this is the AppActivityProxy. The object is
79 // owned the the ActivityManager.
80 AppActivityProxy* unloaded_activity_proxy_;
81
82 // The presentation values.
83 SkColor color_;
84 base::string16 title_;
85 gfx::ImageSkia image_;
86
87 DISALLOW_COPY_AND_ASSIGN(AppActivityRegistry);
88 };
89
90 } // namespace athena
91
92 #endif // ATHENA_CONTENT_APP_ACTIVITY_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698