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

Side by Side Diff: webkit/browser/quota/storage_monitor.h

Issue 498273002: Rename storage-related export macros and build targets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « webkit/browser/quota/special_storage_policy.h ('k') | webkit/browser/quota/storage_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 WEBKIT_BROWSER_QUOTA_STORAGE_MONITOR_H_ 5 #ifndef WEBKIT_BROWSER_QUOTA_STORAGE_MONITOR_H_
6 #define WEBKIT_BROWSER_QUOTA_STORAGE_MONITOR_H_ 6 #define WEBKIT_BROWSER_QUOTA_STORAGE_MONITOR_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "webkit/browser/quota/storage_observer.h" 13 #include "webkit/browser/quota/storage_observer.h"
14 14
15 namespace content { 15 namespace content {
16 class StorageMonitorTestBase; 16 class StorageMonitorTestBase;
17 } 17 }
18 18
19 namespace storage { 19 namespace storage {
20 20
21 class QuotaManager; 21 class QuotaManager;
22 22
23 // This class dispatches storage events to observers of a common 23 // This class dispatches storage events to observers of a common
24 // StorageObserver::Filter. 24 // StorageObserver::Filter.
25 class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE StorageObserverList { 25 class STORAGE_EXPORT_PRIVATE StorageObserverList {
26 public: 26 public:
27 StorageObserverList(); 27 StorageObserverList();
28 virtual ~StorageObserverList(); 28 virtual ~StorageObserverList();
29 29
30 // Adds/removes an observer. 30 // Adds/removes an observer.
31 void AddObserver(StorageObserver* observer, 31 void AddObserver(StorageObserver* observer,
32 const StorageObserver::MonitorParams& params); 32 const StorageObserver::MonitorParams& params);
33 void RemoveObserver(StorageObserver* observer); 33 void RemoveObserver(StorageObserver* observer);
34 34
35 // Returns the number of observers. 35 // Returns the number of observers.
36 int ObserverCount() const; 36 int ObserverCount() const;
37 37
38 // Forwards a storage change to observers. The event may be dispatched 38 // Forwards a storage change to observers. The event may be dispatched
39 // immediately to an observer or after a delay, depending on the desired event 39 // immediately to an observer or after a delay, depending on the desired event
40 // rate of the observer. 40 // rate of the observer.
41 void OnStorageChange(const StorageObserver::Event& event); 41 void OnStorageChange(const StorageObserver::Event& event);
42 42
43 // Dispatch an event to observers that require it. 43 // Dispatch an event to observers that require it.
44 void MaybeDispatchEvent(const StorageObserver::Event& event); 44 void MaybeDispatchEvent(const StorageObserver::Event& event);
45 45
46 // Ensure the specified observer receives the next dispatched event. 46 // Ensure the specified observer receives the next dispatched event.
47 void ScheduleUpdateForObserver(StorageObserver* observer); 47 void ScheduleUpdateForObserver(StorageObserver* observer);
48 48
49 private: 49 private:
50 struct WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE ObserverState { 50 struct STORAGE_EXPORT_PRIVATE ObserverState {
51 GURL origin; 51 GURL origin;
52 base::TimeTicks last_notification_time; 52 base::TimeTicks last_notification_time;
53 base::TimeDelta rate; 53 base::TimeDelta rate;
54 bool requires_update; 54 bool requires_update;
55 55
56 ObserverState(); 56 ObserverState();
57 }; 57 };
58 typedef std::map<StorageObserver*, ObserverState> StorageObserverStateMap; 58 typedef std::map<StorageObserver*, ObserverState> StorageObserverStateMap;
59 59
60 void DispatchPendingEvent(); 60 void DispatchPendingEvent();
61 61
62 StorageObserverStateMap observers_; 62 StorageObserverStateMap observers_;
63 base::OneShotTimer<StorageObserverList> notification_timer_; 63 base::OneShotTimer<StorageObserverList> notification_timer_;
64 StorageObserver::Event pending_event_; 64 StorageObserver::Event pending_event_;
65 65
66 friend class content::StorageMonitorTestBase; 66 friend class content::StorageMonitorTestBase;
67 67
68 DISALLOW_COPY_AND_ASSIGN(StorageObserverList); 68 DISALLOW_COPY_AND_ASSIGN(StorageObserverList);
69 }; 69 };
70 70
71 71
72 // Manages the storage observers of a common host. Caches the usage and quota of 72 // Manages the storage observers of a common host. Caches the usage and quota of
73 // the host to avoid accumulating for every change. 73 // the host to avoid accumulating for every change.
74 class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE HostStorageObservers { 74 class STORAGE_EXPORT_PRIVATE HostStorageObservers {
75 public: 75 public:
76 explicit HostStorageObservers(QuotaManager* quota_manager); 76 explicit HostStorageObservers(QuotaManager* quota_manager);
77 virtual ~HostStorageObservers(); 77 virtual ~HostStorageObservers();
78 78
79 bool is_initialized() const { return initialized_; } 79 bool is_initialized() const { return initialized_; }
80 80
81 // Adds/removes an observer. 81 // Adds/removes an observer.
82 void AddObserver( 82 void AddObserver(
83 StorageObserver* observer, 83 StorageObserver* observer,
84 const StorageObserver::MonitorParams& params); 84 const StorageObserver::MonitorParams& params);
(...skipping 26 matching lines...) Expand all
111 111
112 base::WeakPtrFactory<HostStorageObservers> weak_factory_; 112 base::WeakPtrFactory<HostStorageObservers> weak_factory_;
113 113
114 friend class content::StorageMonitorTestBase; 114 friend class content::StorageMonitorTestBase;
115 115
116 DISALLOW_COPY_AND_ASSIGN(HostStorageObservers); 116 DISALLOW_COPY_AND_ASSIGN(HostStorageObservers);
117 }; 117 };
118 118
119 119
120 // Manages the observers of a common storage type. 120 // Manages the observers of a common storage type.
121 class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE StorageTypeObservers { 121 class STORAGE_EXPORT_PRIVATE StorageTypeObservers {
122 public: 122 public:
123 explicit StorageTypeObservers(QuotaManager* quota_manager); 123 explicit StorageTypeObservers(QuotaManager* quota_manager);
124 virtual ~StorageTypeObservers(); 124 virtual ~StorageTypeObservers();
125 125
126 // Adds and removes an observer. 126 // Adds and removes an observer.
127 void AddObserver(StorageObserver* observer, 127 void AddObserver(StorageObserver* observer,
128 const StorageObserver::MonitorParams& params); 128 const StorageObserver::MonitorParams& params);
129 void RemoveObserver(StorageObserver* observer); 129 void RemoveObserver(StorageObserver* observer);
130 void RemoveObserverForFilter(StorageObserver* observer, 130 void RemoveObserverForFilter(StorageObserver* observer,
131 const StorageObserver::Filter& filter); 131 const StorageObserver::Filter& filter);
132 132
133 // Returns the observers of a specific host. 133 // Returns the observers of a specific host.
134 const HostStorageObservers* GetHostObservers(const std::string& host) const; 134 const HostStorageObservers* GetHostObservers(const std::string& host) const;
135 135
136 // Handles a usage change. 136 // Handles a usage change.
137 void NotifyUsageChange(const StorageObserver::Filter& filter, int64 delta); 137 void NotifyUsageChange(const StorageObserver::Filter& filter, int64 delta);
138 138
139 private: 139 private:
140 typedef std::map<std::string, HostStorageObservers*> HostObserversMap; 140 typedef std::map<std::string, HostStorageObservers*> HostObserversMap;
141 141
142 QuotaManager* quota_manager_; 142 QuotaManager* quota_manager_;
143 HostObserversMap host_observers_map_; 143 HostObserversMap host_observers_map_;
144 144
145 DISALLOW_COPY_AND_ASSIGN(StorageTypeObservers); 145 DISALLOW_COPY_AND_ASSIGN(StorageTypeObservers);
146 }; 146 };
147 147
148 148
149 // Storage monitor manages observers and dispatches storage events to them. 149 // Storage monitor manages observers and dispatches storage events to them.
150 class WEBKIT_STORAGE_BROWSER_EXPORT_PRIVATE StorageMonitor { 150 class STORAGE_EXPORT_PRIVATE StorageMonitor {
151 public: 151 public:
152 explicit StorageMonitor(QuotaManager* quota_manager); 152 explicit StorageMonitor(QuotaManager* quota_manager);
153 virtual ~StorageMonitor(); 153 virtual ~StorageMonitor();
154 154
155 // Adds and removes an observer. 155 // Adds and removes an observer.
156 void AddObserver(StorageObserver* observer, 156 void AddObserver(StorageObserver* observer,
157 const StorageObserver::MonitorParams& params); 157 const StorageObserver::MonitorParams& params);
158 void RemoveObserver(StorageObserver* observer); 158 void RemoveObserver(StorageObserver* observer);
159 void RemoveObserverForFilter(StorageObserver* observer, 159 void RemoveObserverForFilter(StorageObserver* observer,
160 const StorageObserver::Filter& filter); 160 const StorageObserver::Filter& filter);
(...skipping 10 matching lines...) Expand all
171 171
172 QuotaManager* quota_manager_; 172 QuotaManager* quota_manager_;
173 StorageTypeObserversMap storage_type_observers_map_; 173 StorageTypeObserversMap storage_type_observers_map_;
174 174
175 DISALLOW_COPY_AND_ASSIGN(StorageMonitor); 175 DISALLOW_COPY_AND_ASSIGN(StorageMonitor);
176 }; 176 };
177 177
178 } // namespace storage 178 } // namespace storage
179 179
180 #endif // WEBKIT_BROWSER_QUOTA_STORAGE_MONITOR_H_ 180 #endif // WEBKIT_BROWSER_QUOTA_STORAGE_MONITOR_H_
OLDNEW
« no previous file with comments | « webkit/browser/quota/special_storage_policy.h ('k') | webkit/browser/quota/storage_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698