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

Unified Diff: apps/shell_window_geometry_cache.h

Issue 14636012: Move ShellWindowGeometryCache into apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 7 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
« no previous file with comments | « apps/apps.gypi ('k') | apps/shell_window_geometry_cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/shell_window_geometry_cache.h
diff --git a/chrome/browser/extensions/shell_window_geometry_cache.h b/apps/shell_window_geometry_cache.h
similarity index 73%
rename from chrome/browser/extensions/shell_window_geometry_cache.h
rename to apps/shell_window_geometry_cache.h
index 5648b0d4b7b802a8346d7e67330b700bc6856a07..5b5bb1d1270fd0ff78a771634e98eb9016e0b0b3 100644
--- a/chrome/browser/extensions/shell_window_geometry_cache.h
+++ b/apps/shell_window_geometry_cache.h
@@ -10,10 +10,12 @@
#include <string>
#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
+#include "base/memory/singleton.h"
#include "base/time.h"
#include "base/timer.h"
#include "base/values.h"
+#include "chrome/browser/profiles/profile_keyed_service.h"
+#include "chrome/browser/profiles/profile_keyed_service_factory.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "ui/base/ui_base_types.h"
@@ -22,21 +24,47 @@
class Profile;
namespace extensions {
-
class ExtensionPrefs;
+}
+
+namespace apps {
// A cache for persisted geometry of shell windows, both to not have to wait
// for IO when creating a new window, and to not cause IO on every window
// geometry change.
class ShellWindowGeometryCache
- : public base::SupportsWeakPtr<ShellWindowGeometryCache>,
+ : public ProfileKeyedService,
public content::NotificationObserver {
public:
+ class Factory : public ProfileKeyedServiceFactory {
+ public:
+ static ShellWindowGeometryCache* GetForContext(
+ content::BrowserContext* context,
+ bool create);
+
+ static Factory* GetInstance();
+ private:
+ friend struct DefaultSingletonTraits<Factory>;
+
+ Factory();
+ virtual ~Factory();
+
+ // ProfileKeyedServiceFactory
+ virtual ProfileKeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* context) const OVERRIDE;
+ virtual bool ServiceIsNULLWhileTesting() const OVERRIDE;
+ virtual content::BrowserContext* GetBrowserContextToUse(
+ content::BrowserContext* context) const OVERRIDE;
+ };
+
ShellWindowGeometryCache(Profile* profile,
- ExtensionPrefs* prefs);
+ extensions::ExtensionPrefs* prefs);
virtual ~ShellWindowGeometryCache();
+ // Returns the instance for the given browsing context.
+ static ShellWindowGeometryCache* Get(content::BrowserContext* context);
+
// Save the geometry and state associated with |extension_id| and |window_id|.
void SaveGeometry(const std::string& extension_id,
const std::string& window_id,
@@ -51,6 +79,9 @@ class ShellWindowGeometryCache
gfx::Rect* bounds,
ui::WindowShowState* state) const;
+ // ProfileKeyedService
+ virtual void Shutdown() OVERRIDE;
+
// Maximum number of windows we'll cache the geometry for per app.
static const size_t kMaxCachedWindows = 100;
@@ -84,7 +115,7 @@ class ShellWindowGeometryCache
void SyncToStorage();
// Preferences storage.
- ExtensionPrefs* prefs_;
+ extensions::ExtensionPrefs* prefs_;
// Cached data
std::map<std::string, ExtensionData> cache_;
@@ -101,6 +132,6 @@ class ShellWindowGeometryCache
content::NotificationRegistrar registrar_;
};
-} // namespace extensions
+} // namespace apps
#endif // CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_GEOMETRY_CACHE_H_
« no previous file with comments | « apps/apps.gypi ('k') | apps/shell_window_geometry_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698