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

Side by Side Diff: chrome/browser/extensions/shell_window_geometry_cache.h

Issue 10871086: First part of remembering platform app window geometry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comments Created 8 years, 3 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 (c) 2012 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 CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_GEOMETRY_CACHE_H_
6 #define CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_GEOMETRY_CACHE_H_
7
8 #include <map>
9 #include <set>
10 #include <string>
11
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/timer.h"
15 #include "base/values.h"
16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h"
18 #include "ui/gfx/rect.h"
19
20 class Profile;
21
22 namespace extensions {
23
24 class StateStore;
25
26 // A cache for persisted geometry of shell windows, both to not have to wait
27 // for IO when creating a new window, and to not cause IO on every window
28 // geometry change.
29 class ShellWindowGeometryCache
30 : public base::SupportsWeakPtr<ShellWindowGeometryCache>,
31 public content::NotificationObserver {
32 public:
33 ShellWindowGeometryCache(Profile* profile, StateStore* state_store);
34
35 virtual ~ShellWindowGeometryCache();
36
37 void SaveGeometry(const std::string& extension_id,
38 const std::string& window_id,
39 const gfx::Rect& bounds);
40
41 bool GetGeometry(const std::string& extension_id,
42 const std::string& window_id,
43 gfx::Rect* bounds) const;
44
45 private:
46 // content::NotificationObserver
47 virtual void Observe(int type,
48 const content::NotificationSource& source,
49 const content::NotificationDetails& details) OVERRIDE;
50
51 void OnExtensionLoaded(const std::string& extension_id);
52 void OnExtensionUnloaded(const std::string& extension_id);
53
54 void GeometryFromStorage(const std::string& extension_id,
55 scoped_ptr<base::Value> value);
56
57 void SyncToStorage();
58
59 friend class ShellWindowGeometryCacheTest;
60
61 // State store.
62 StateStore* store_;
63
64 // Cached data
65 std::map<std::string, std::map<std::string, gfx::Rect> > cache_;
66
67 // Data that still needs saving
68 std::set<std::string> unsynced_extensions_;
69
70 // The timer used to save the data
71 base::OneShotTimer<ShellWindowGeometryCache> sync_timer_;
72
73 content::NotificationRegistrar registrar_;
74 };
75
76 } // namespace extensions
77
78 #endif // CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_GEOMETRY_CACHE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_system.cc ('k') | chrome/browser/extensions/shell_window_geometry_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698