OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_settings_storage_quota_enforcer.h" | 5 #include "chrome/browser/extensions/extension_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.h" | 10 #include "base/message_loop.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 max_keys_(max_keys), | 83 max_keys_(max_keys), |
84 delegate_(delegate), | 84 delegate_(delegate), |
85 used_total_(0) { | 85 used_total_(0) { |
86 Result maybe_initial_settings = delegate->Get(); | 86 Result maybe_initial_settings = delegate->Get(); |
87 if (maybe_initial_settings.HasError()) { | 87 if (maybe_initial_settings.HasError()) { |
88 LOG(WARNING) << "Failed to get initial settings for quota: " << | 88 LOG(WARNING) << "Failed to get initial settings for quota: " << |
89 maybe_initial_settings.GetError(); | 89 maybe_initial_settings.GetError(); |
90 return; | 90 return; |
91 } | 91 } |
92 | 92 |
93 DictionaryValue* initial_settings = maybe_initial_settings.GetSettings(); | 93 const DictionaryValue* initial_settings = |
| 94 maybe_initial_settings.GetSettings(); |
94 for (DictionaryValue::key_iterator it = initial_settings->begin_keys(); | 95 for (DictionaryValue::key_iterator it = initial_settings->begin_keys(); |
95 it != initial_settings->end_keys(); ++it) { | 96 it != initial_settings->end_keys(); ++it) { |
96 Value *value; | 97 Value *value; |
97 initial_settings->GetWithoutPathExpansion(*it, &value); | 98 initial_settings->GetWithoutPathExpansion(*it, &value); |
98 Allocate(*it, *value, &used_total_, &used_per_setting_); | 99 Allocate(*it, *value, &used_total_, &used_per_setting_); |
99 } | 100 } |
100 } | 101 } |
101 | 102 |
102 ExtensionSettingsStorageQuotaEnforcer::~ExtensionSettingsStorageQuotaEnforcer( | 103 ExtensionSettingsStorageQuotaEnforcer::~ExtensionSettingsStorageQuotaEnforcer( |
103 ) {} | 104 ) {} |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 Result result = delegate_->Clear(); | 204 Result result = delegate_->Clear(); |
204 if (result.HasError()) { | 205 if (result.HasError()) { |
205 return result; | 206 return result; |
206 } | 207 } |
207 | 208 |
208 while (!used_per_setting_.empty()) { | 209 while (!used_per_setting_.empty()) { |
209 Free(&used_total_, &used_per_setting_, used_per_setting_.begin()->first); | 210 Free(&used_total_, &used_per_setting_, used_per_setting_.begin()->first); |
210 } | 211 } |
211 return result; | 212 return result; |
212 } | 213 } |
OLD | NEW |