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

Side by Side Diff: chrome/browser/extensions/settings/settings_storage_quota_enforcer.cc

Issue 11312228: Move extension_error_utils.* and url_pattern_set.* into (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hate Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/settings/settings_storage_quota_enforcer.h" 5 #include "chrome/browser/extensions/settings/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"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "chrome/common/extensions/api/extension_api.h" 12 #include "chrome/common/extensions/api/extension_api.h"
13 #include "chrome/common/extensions/extension_error_utils.h" 13 #include "extensions/common/error_utils.h"
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 namespace { 17 namespace {
18 18
19 const char* kQuotaExceededError = "* quota exceeded."; 19 const char* kQuotaExceededError = "* quota exceeded.";
20 20
21 // Resources there are a quota for. 21 // Resources there are a quota for.
22 enum Resource { 22 enum Resource {
23 QUOTA_BYTES, 23 QUOTA_BYTES,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 break; 69 break;
70 case MAX_ITEMS: 70 case MAX_ITEMS:
71 name = "MAX_ITEMS"; 71 name = "MAX_ITEMS";
72 UMA_HISTOGRAM_COUNTS_100( 72 UMA_HISTOGRAM_COUNTS_100(
73 "Extensions.SettingsQuotaExceeded.KeyCount", 1); 73 "Extensions.SettingsQuotaExceeded.KeyCount", 1);
74 break; 74 break;
75 default: 75 default:
76 NOTREACHED(); 76 NOTREACHED();
77 } 77 }
78 return ValueStore::MakeWriteResult( 78 return ValueStore::MakeWriteResult(
79 ExtensionErrorUtils::FormatErrorMessage(kQuotaExceededError, name)); 79 ErrorUtils::FormatErrorMessage(kQuotaExceededError, name));
80 } 80 }
81 81
82 } // namespace 82 } // namespace
83 83
84 SettingsStorageQuotaEnforcer::SettingsStorageQuotaEnforcer( 84 SettingsStorageQuotaEnforcer::SettingsStorageQuotaEnforcer(
85 const Limits& limits, ValueStore* delegate) 85 const Limits& limits, ValueStore* delegate)
86 : limits_(limits), delegate_(delegate), used_total_(0) { 86 : limits_(limits), delegate_(delegate), used_total_(0) {
87 ReadResult maybe_settings = delegate_->Get(); 87 ReadResult maybe_settings = delegate_->Get();
88 if (maybe_settings->HasError()) { 88 if (maybe_settings->HasError()) {
89 LOG(WARNING) << "Failed to get initial settings for quota: " << 89 LOG(WARNING) << "Failed to get initial settings for quota: " <<
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 return result.Pass(); 226 return result.Pass();
227 } 227 }
228 228
229 while (!used_per_setting_.empty()) { 229 while (!used_per_setting_.empty()) {
230 Free(&used_total_, &used_per_setting_, used_per_setting_.begin()->first); 230 Free(&used_total_, &used_per_setting_, used_per_setting_.begin()->first);
231 } 231 }
232 return result.Pass(); 232 return result.Pass();
233 } 233 }
234 234
235 } // namespace extensions 235 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/menu_manager.h ('k') | chrome/browser/extensions/user_script_master_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698