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

Side by Side Diff: extensions/browser/app_window/app_window_geometry_cache.h

Issue 664933004: Standardize usage of virtual/override/final in extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_GEOMETRY_CACHE_H_ 5 #ifndef EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_GEOMETRY_CACHE_H_
6 #define EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_GEOMETRY_CACHE_H_ 6 #define EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_GEOMETRY_CACHE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 27 matching lines...) Expand all
38 static AppWindowGeometryCache* GetForContext( 38 static AppWindowGeometryCache* GetForContext(
39 content::BrowserContext* context, 39 content::BrowserContext* context,
40 bool create); 40 bool create);
41 41
42 static Factory* GetInstance(); 42 static Factory* GetInstance();
43 43
44 private: 44 private:
45 friend struct DefaultSingletonTraits<Factory>; 45 friend struct DefaultSingletonTraits<Factory>;
46 46
47 Factory(); 47 Factory();
48 virtual ~Factory(); 48 ~Factory() override;
49 49
50 // BrowserContextKeyedServiceFactory 50 // BrowserContextKeyedServiceFactory
51 virtual KeyedService* BuildServiceInstanceFor( 51 KeyedService* BuildServiceInstanceFor(
52 content::BrowserContext* context) const override; 52 content::BrowserContext* context) const override;
53 virtual bool ServiceIsNULLWhileTesting() const override; 53 bool ServiceIsNULLWhileTesting() const override;
54 virtual content::BrowserContext* GetBrowserContextToUse( 54 content::BrowserContext* GetBrowserContextToUse(
55 content::BrowserContext* context) const override; 55 content::BrowserContext* context) const override;
56 }; 56 };
57 57
58 class Observer { 58 class Observer {
59 public: 59 public:
60 virtual void OnGeometryCacheChanged(const std::string& extension_id, 60 virtual void OnGeometryCacheChanged(const std::string& extension_id,
61 const std::string& window_id, 61 const std::string& window_id,
62 const gfx::Rect& bounds) = 0; 62 const gfx::Rect& bounds) = 0;
63 63
64 protected: 64 protected:
65 virtual ~Observer() {} 65 virtual ~Observer() {}
66 }; 66 };
67 67
68 AppWindowGeometryCache(content::BrowserContext* context, 68 AppWindowGeometryCache(content::BrowserContext* context,
69 ExtensionPrefs* prefs); 69 ExtensionPrefs* prefs);
70 70
71 virtual ~AppWindowGeometryCache(); 71 ~AppWindowGeometryCache() override;
72 72
73 // Returns the instance for the given browsing context. 73 // Returns the instance for the given browsing context.
74 static AppWindowGeometryCache* Get(content::BrowserContext* context); 74 static AppWindowGeometryCache* Get(content::BrowserContext* context);
75 75
76 // Save the geometry and state associated with |extension_id| and |window_id|. 76 // Save the geometry and state associated with |extension_id| and |window_id|.
77 void SaveGeometry(const std::string& extension_id, 77 void SaveGeometry(const std::string& extension_id,
78 const std::string& window_id, 78 const std::string& window_id,
79 const gfx::Rect& bounds, 79 const gfx::Rect& bounds,
80 const gfx::Rect& screen_bounds, 80 const gfx::Rect& screen_bounds,
81 ui::WindowShowState state); 81 ui::WindowShowState state);
82 82
83 // Get any saved geometry and state associated with |extension_id| and 83 // Get any saved geometry and state associated with |extension_id| and
84 // |window_id|. If saved data exists, sets |bounds|, |screen_bounds| and 84 // |window_id|. If saved data exists, sets |bounds|, |screen_bounds| and
85 // |state| if not NULL and returns true. 85 // |state| if not NULL and returns true.
86 bool GetGeometry(const std::string& extension_id, 86 bool GetGeometry(const std::string& extension_id,
87 const std::string& window_id, 87 const std::string& window_id,
88 gfx::Rect* bounds, 88 gfx::Rect* bounds,
89 gfx::Rect* screen_bounds, 89 gfx::Rect* screen_bounds,
90 ui::WindowShowState* state); 90 ui::WindowShowState* state);
91 91
92 // KeyedService 92 // KeyedService
93 virtual void Shutdown() override; 93 void Shutdown() override;
94 94
95 void AddObserver(Observer* observer); 95 void AddObserver(Observer* observer);
96 void RemoveObserver(Observer* observer); 96 void RemoveObserver(Observer* observer);
97 97
98 // Maximum number of windows we'll cache the geometry for per app. 98 // Maximum number of windows we'll cache the geometry for per app.
99 static const size_t kMaxCachedWindows = 100; 99 static const size_t kMaxCachedWindows = 100;
100 100
101 protected: 101 protected:
102 friend class AppWindowGeometryCacheTest; 102 friend class AppWindowGeometryCacheTest;
103 103
(...skipping 10 matching lines...) Expand all
114 gfx::Rect bounds; 114 gfx::Rect bounds;
115 gfx::Rect screen_bounds; 115 gfx::Rect screen_bounds;
116 ui::WindowShowState window_state; 116 ui::WindowShowState window_state;
117 base::Time last_change; 117 base::Time last_change;
118 }; 118 };
119 119
120 // Data stored for each extension. 120 // Data stored for each extension.
121 typedef std::map<std::string, WindowData> ExtensionData; 121 typedef std::map<std::string, WindowData> ExtensionData;
122 122
123 // ExtensionRegistryObserver implementation. 123 // ExtensionRegistryObserver implementation.
124 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, 124 void OnExtensionLoaded(content::BrowserContext* browser_context,
125 const Extension* extension) override; 125 const Extension* extension) override;
126 virtual void OnExtensionUnloaded( 126 void OnExtensionUnloaded(content::BrowserContext* browser_context,
127 content::BrowserContext* browser_context, 127 const Extension* extension,
128 const Extension* extension, 128 UnloadedExtensionInfo::Reason reason) override;
129 UnloadedExtensionInfo::Reason reason) override;
130 129
131 void LoadGeometryFromStorage(const std::string& extension_id); 130 void LoadGeometryFromStorage(const std::string& extension_id);
132 void SyncToStorage(); 131 void SyncToStorage();
133 132
134 // Preferences storage. 133 // Preferences storage.
135 ExtensionPrefs* prefs_; 134 ExtensionPrefs* prefs_;
136 135
137 // Cached data. 136 // Cached data.
138 std::map<std::string, ExtensionData> cache_; 137 std::map<std::string, ExtensionData> cache_;
139 138
140 // Data that still needs saving. 139 // Data that still needs saving.
141 std::set<std::string> unsynced_extensions_; 140 std::set<std::string> unsynced_extensions_;
142 141
143 // The timer used to save the data. 142 // The timer used to save the data.
144 base::OneShotTimer<AppWindowGeometryCache> sync_timer_; 143 base::OneShotTimer<AppWindowGeometryCache> sync_timer_;
145 144
146 // The timeout value we'll use for |sync_timer_|. 145 // The timeout value we'll use for |sync_timer_|.
147 base::TimeDelta sync_delay_; 146 base::TimeDelta sync_delay_;
148 147
149 // Listen to extension load, unloaded notifications. 148 // Listen to extension load, unloaded notifications.
150 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 149 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
151 extension_registry_observer_; 150 extension_registry_observer_;
152 151
153 ObserverList<Observer> observers_; 152 ObserverList<Observer> observers_;
154 }; 153 };
155 154
156 } // namespace extensions 155 } // namespace extensions
157 156
158 #endif // EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_GEOMETRY_CACHE_H_ 157 #endif // EXTENSIONS_BROWSER_APP_WINDOW_APP_WINDOW_GEOMETRY_CACHE_H_
OLDNEW
« no previous file with comments | « extensions/browser/app_window/app_window_contents.h ('k') | extensions/browser/app_window/app_window_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698