| 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 "extensions/browser/api/storage/settings_storage_quota_enforcer.h" | 5 #include "extensions/browser/api/storage/settings_storage_quota_enforcer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 void Free( | 50 void Free( |
| 51 size_t* used_total, | 51 size_t* used_total, |
| 52 std::map<std::string, size_t>* used_per_setting, | 52 std::map<std::string, size_t>* used_per_setting, |
| 53 const std::string& key) { | 53 const std::string& key) { |
| 54 *used_total -= (*used_per_setting)[key]; | 54 *used_total -= (*used_per_setting)[key]; |
| 55 used_per_setting->erase(key); | 55 used_per_setting->erase(key); |
| 56 } | 56 } |
| 57 | 57 |
| 58 scoped_ptr<ValueStore::Error> QuotaExceededError(Resource resource, | 58 scoped_ptr<ValueStore::Error> QuotaExceededError(Resource resource, |
| 59 scoped_ptr<std::string> key) { | 59 scoped_ptr<std::string> key) { |
| 60 const char* name = NULL; | 60 const char* name = nullptr; |
| 61 // TODO(kalman): These hisograms are both silly and untracked. Fix. | 61 // TODO(kalman): These hisograms are both silly and untracked. Fix. |
| 62 switch (resource) { | 62 switch (resource) { |
| 63 case QUOTA_BYTES: | 63 case QUOTA_BYTES: |
| 64 name = "QUOTA_BYTES"; | 64 name = "QUOTA_BYTES"; |
| 65 UMA_HISTOGRAM_COUNTS_100( | 65 UMA_HISTOGRAM_COUNTS_100( |
| 66 "Extensions.SettingsQuotaExceeded.TotalBytes", 1); | 66 "Extensions.SettingsQuotaExceeded.TotalBytes", 1); |
| 67 break; | 67 break; |
| 68 case QUOTA_BYTES_PER_ITEM: | 68 case QUOTA_BYTES_PER_ITEM: |
| 69 name = "QUOTA_BYTES_PER_ITEM"; | 69 name = "QUOTA_BYTES_PER_ITEM"; |
| 70 UMA_HISTOGRAM_COUNTS_100( | 70 UMA_HISTOGRAM_COUNTS_100( |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 } | 264 } |
| 265 | 265 |
| 266 for (base::DictionaryValue::Iterator it(maybe_settings->settings()); | 266 for (base::DictionaryValue::Iterator it(maybe_settings->settings()); |
| 267 !it.IsAtEnd(); | 267 !it.IsAtEnd(); |
| 268 it.Advance()) { | 268 it.Advance()) { |
| 269 Allocate(it.key(), it.value(), &used_total_, &used_per_setting_); | 269 Allocate(it.key(), it.value(), &used_total_, &used_per_setting_); |
| 270 } | 270 } |
| 271 } | 271 } |
| 272 | 272 |
| 273 } // namespace extensions | 273 } // namespace extensions |
| OLD | NEW |