OLD | NEW |
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 #include "chrome/browser/extensions/extension_storage_monitor.h" | 5 #include "chrome/browser/extensions/extension_storage_monitor.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 // If |next_threshold| is -1, it signifies that we should not enforce (and | 208 // If |next_threshold| is -1, it signifies that we should not enforce (and |
209 // only track) storage for this extension. | 209 // only track) storage for this extension. |
210 int64 next_threshold; | 210 int64 next_threshold; |
211 | 211 |
212 bool should_uma; | 212 bool should_uma; |
213 | 213 |
214 StorageState() : next_threshold(-1), should_uma(false) {} | 214 StorageState() : next_threshold(-1), should_uma(false) {} |
215 }; | 215 }; |
216 typedef std::map<GURL, StorageState> OriginStorageStateMap; | 216 typedef std::map<GURL, StorageState> OriginStorageStateMap; |
217 | 217 |
218 virtual ~StorageEventObserver() { | 218 ~StorageEventObserver() override { |
219 DCHECK(origin_state_map_.empty()); | 219 DCHECK(origin_state_map_.empty()); |
220 StopObserving(); | 220 StopObserving(); |
221 } | 221 } |
222 | 222 |
223 // storage::StorageObserver implementation. | 223 // storage::StorageObserver implementation. |
224 virtual void OnStorageEvent(const Event& event) override { | 224 void OnStorageEvent(const Event& event) override { |
225 OriginStorageStateMap::iterator iter = | 225 OriginStorageStateMap::iterator iter = |
226 origin_state_map_.find(event.filter.origin); | 226 origin_state_map_.find(event.filter.origin); |
227 if (iter == origin_state_map_.end()) | 227 if (iter == origin_state_map_.end()) |
228 return; | 228 return; |
229 StorageState& state = iter->second; | 229 StorageState& state = iter->second; |
230 | 230 |
231 if (state.should_uma) { | 231 if (state.should_uma) { |
232 if (event.filter.storage_type == storage::kStorageTypePersistent) { | 232 if (event.filter.storage_type == storage::kStorageTypePersistent) { |
233 UMA_HISTOGRAM_MEMORY_KB( | 233 UMA_HISTOGRAM_MEMORY_KB( |
234 "Extensions.HostedAppUnlimitedStoragePersistentStorageUsage", | 234 "Extensions.HostedAppUnlimitedStoragePersistentStorageUsage", |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 void ExtensionStorageMonitor::SetStorageNotificationEnabled( | 678 void ExtensionStorageMonitor::SetStorageNotificationEnabled( |
679 const std::string& extension_id, | 679 const std::string& extension_id, |
680 bool enable_notifications) { | 680 bool enable_notifications) { |
681 extension_prefs_->UpdateExtensionPref( | 681 extension_prefs_->UpdateExtensionPref( |
682 extension_id, | 682 extension_id, |
683 kPrefDisableStorageNotifications, | 683 kPrefDisableStorageNotifications, |
684 enable_notifications ? NULL : new base::FundamentalValue(true)); | 684 enable_notifications ? NULL : new base::FundamentalValue(true)); |
685 } | 685 } |
686 | 686 |
687 } // namespace extensions | 687 } // namespace extensions |
OLD | NEW |