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

Side by Side Diff: extensions/browser/api/storage/settings_storage_quota_enforcer.cc

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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
OLDNEW
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 <memory>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
11 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
12 #include "base/stl_util.h" 13 #include "base/stl_util.h"
13 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
14 #include "extensions/common/extension_api.h" 15 #include "extensions/common/extension_api.h"
15 16
16 namespace extensions { 17 namespace extensions {
17 18
18 namespace { 19 namespace {
19 20
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 66 }
66 CHECK(name); 67 CHECK(name);
67 return ValueStore::Status(ValueStore::QUOTA_EXCEEDED, 68 return ValueStore::Status(ValueStore::QUOTA_EXCEEDED,
68 base::StringPrintf("%s quota exceeded", name)); 69 base::StringPrintf("%s quota exceeded", name));
69 } 70 }
70 71
71 } // namespace 72 } // namespace
72 73
73 SettingsStorageQuotaEnforcer::SettingsStorageQuotaEnforcer( 74 SettingsStorageQuotaEnforcer::SettingsStorageQuotaEnforcer(
74 const Limits& limits, 75 const Limits& limits,
75 scoped_ptr<ValueStore> delegate) 76 std::unique_ptr<ValueStore> delegate)
76 : limits_(limits), 77 : limits_(limits),
77 delegate_(std::move(delegate)), 78 delegate_(std::move(delegate)),
78 used_total_(0), 79 used_total_(0),
79 usage_calculated_(false) {} 80 usage_calculated_(false) {}
80 81
81 SettingsStorageQuotaEnforcer::~SettingsStorageQuotaEnforcer() {} 82 SettingsStorageQuotaEnforcer::~SettingsStorageQuotaEnforcer() {}
82 83
83 size_t SettingsStorageQuotaEnforcer::GetBytesInUse(const std::string& key) { 84 size_t SettingsStorageQuotaEnforcer::GetBytesInUse(const std::string& key) {
84 LazyCalculateUsage(); 85 LazyCalculateUsage();
85 std::map<std::string, size_t>::iterator maybe_used = 86 std::map<std::string, size_t>::iterator maybe_used =
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 return; 254 return;
254 auto it = used_per_setting_.find(key); 255 auto it = used_per_setting_.find(key);
255 if (it == used_per_setting_.end()) 256 if (it == used_per_setting_.end())
256 return; 257 return;
257 DCHECK_GE(used_total_, it->second); 258 DCHECK_GE(used_total_, it->second);
258 used_total_ -= it->second; 259 used_total_ -= it->second;
259 used_per_setting_.erase(it); 260 used_per_setting_.erase(it);
260 } 261 }
261 262
262 } // namespace extensions 263 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/storage/settings_storage_quota_enforcer.h ('k') | extensions/browser/api/storage/settings_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698