| 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/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" | 
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" | 
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 174     StorageState() : next_threshold(0) {} | 174     StorageState() : next_threshold(0) {} | 
| 175   }; | 175   }; | 
| 176   typedef std::map<GURL, StorageState> OriginStorageStateMap; | 176   typedef std::map<GURL, StorageState> OriginStorageStateMap; | 
| 177 | 177 | 
| 178   virtual ~StorageEventObserver() { | 178   virtual ~StorageEventObserver() { | 
| 179     DCHECK(origin_state_map_.empty()); | 179     DCHECK(origin_state_map_.empty()); | 
| 180     StopObserving(); | 180     StopObserving(); | 
| 181   } | 181   } | 
| 182 | 182 | 
| 183   // storage::StorageObserver implementation. | 183   // storage::StorageObserver implementation. | 
| 184   virtual void OnStorageEvent(const Event& event) OVERRIDE { | 184   virtual void OnStorageEvent(const Event& event) override { | 
| 185     OriginStorageStateMap::iterator state = | 185     OriginStorageStateMap::iterator state = | 
| 186         origin_state_map_.find(event.filter.origin); | 186         origin_state_map_.find(event.filter.origin); | 
| 187     if (state == origin_state_map_.end()) | 187     if (state == origin_state_map_.end()) | 
| 188       return; | 188       return; | 
| 189 | 189 | 
| 190     if (event.usage >= state->second.next_threshold) { | 190     if (event.usage >= state->second.next_threshold) { | 
| 191       while (event.usage >= state->second.next_threshold) | 191       while (event.usage >= state->second.next_threshold) | 
| 192         state->second.next_threshold *= 2; | 192         state->second.next_threshold *= 2; | 
| 193 | 193 | 
| 194       BrowserThread::PostTask( | 194       BrowserThread::PostTask( | 
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 609 void ExtensionStorageMonitor::SetStorageNotificationEnabled( | 609 void ExtensionStorageMonitor::SetStorageNotificationEnabled( | 
| 610     const std::string& extension_id, | 610     const std::string& extension_id, | 
| 611     bool enable_notifications) { | 611     bool enable_notifications) { | 
| 612   extension_prefs_->UpdateExtensionPref( | 612   extension_prefs_->UpdateExtensionPref( | 
| 613       extension_id, | 613       extension_id, | 
| 614       kPrefDisableStorageNotifications, | 614       kPrefDisableStorageNotifications, | 
| 615       enable_notifications ? NULL : new base::FundamentalValue(true)); | 615       enable_notifications ? NULL : new base::FundamentalValue(true)); | 
| 616 } | 616 } | 
| 617 | 617 | 
| 618 }  // namespace extensions | 618 }  // namespace extensions | 
| OLD | NEW | 
|---|