diff options
author | mek@chromium.org <mek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-13 00:49:24 +0000 |
---|---|---|
committer | mek@chromium.org <mek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-13 00:49:24 +0000 |
commit | af3920fcabff07c0444502b822999d0816499260 (patch) | |
tree | ff4f4ea5203f9d0015d983f39016c21ec42798e8 /chrome/browser/extensions/shell_window_geometry_cache.h | |
parent | 9b95e77da76e47d5d7016142af5f317d477839e8 (diff) | |
download | chromium_src-af3920fcabff07c0444502b822999d0816499260.zip chromium_src-af3920fcabff07c0444502b822999d0816499260.tar.gz chromium_src-af3920fcabff07c0444502b822999d0816499260.tar.bz2 |
Move ShellWindowGeometryCache's data store to Preferences.
BUG=165337
Review URL: https://chromiumcodereview.appspot.com/11530015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/shell_window_geometry_cache.h')
-rw-r--r-- | chrome/browser/extensions/shell_window_geometry_cache.h | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/chrome/browser/extensions/shell_window_geometry_cache.h b/chrome/browser/extensions/shell_window_geometry_cache.h index 0d5edd2..744077c 100644 --- a/chrome/browser/extensions/shell_window_geometry_cache.h +++ b/chrome/browser/extensions/shell_window_geometry_cache.h @@ -11,6 +11,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" +#include "base/time.h" #include "base/timer.h" #include "base/values.h" #include "content/public/browser/notification_observer.h" @@ -21,7 +22,7 @@ class Profile; namespace extensions { -class StateStore; +class ExtensionPrefs; // 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 @@ -30,7 +31,8 @@ class ShellWindowGeometryCache : public base::SupportsWeakPtr<ShellWindowGeometryCache>, public content::NotificationObserver { public: - ShellWindowGeometryCache(Profile* profile, StateStore* state_store); + ShellWindowGeometryCache(Profile* profile, + ExtensionPrefs* prefs); virtual ~ShellWindowGeometryCache(); @@ -42,6 +44,9 @@ class ShellWindowGeometryCache const std::string& window_id, gfx::Rect* bounds) const; + // Maximum number of windows we'll cache the geometry for per app. + static const size_t kMaxCachedWindows = 100; + protected: friend class ShellWindowGeometryCacheTest; @@ -51,6 +56,15 @@ class ShellWindowGeometryCache void SetSyncDelayForTests(int timeout_ms); private: + // Data stored for each window. + struct WindowData { + gfx::Rect bounds; + base::Time last_change; + }; + + // Data stored for each extension. + typedef std::map<std::string, WindowData> ExtensionData; + // content::NotificationObserver virtual void Observe(int type, const content::NotificationSource& source, @@ -58,17 +72,13 @@ class ShellWindowGeometryCache void OnExtensionLoaded(const std::string& extension_id); void OnExtensionUnloaded(const std::string& extension_id); - - void GeometryFromStorage(const std::string& extension_id, - scoped_ptr<base::Value> value); - void SyncToStorage(); - // State store. - StateStore* store_; + // Preferences storage. + ExtensionPrefs* prefs_; // Cached data - std::map<std::string, std::map<std::string, gfx::Rect> > cache_; + std::map<std::string, ExtensionData> cache_; // Data that still needs saving std::set<std::string> unsynced_extensions_; |