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

Side by Side Diff: extensions/common/value_counter.cc

Issue 2252373002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/common/value_counter.h" 5 #include "extensions/common/value_counter.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 16 matching lines...) Expand all
27 ValueCounter::~ValueCounter() { 27 ValueCounter::~ValueCounter() {
28 } 28 }
29 29
30 bool ValueCounter::Add(const base::Value& value) { 30 bool ValueCounter::Add(const base::Value& value) {
31 for (const auto& entry : entries_) { 31 for (const auto& entry : entries_) {
32 if (entry->value->Equals(&value)) { 32 if (entry->value->Equals(&value)) {
33 ++entry->count; 33 ++entry->count;
34 return false; 34 return false;
35 } 35 }
36 } 36 }
37 entries_.push_back(base::WrapUnique(new Entry(value.CreateDeepCopy()))); 37 entries_.push_back(base::MakeUnique<Entry>(value.CreateDeepCopy()));
38 return true; 38 return true;
39 } 39 }
40 40
41 bool ValueCounter::Remove(const base::Value& value) { 41 bool ValueCounter::Remove(const base::Value& value) {
42 for (auto it = entries_.begin(); it != entries_.end(); ++it) { 42 for (auto it = entries_.begin(); it != entries_.end(); ++it) {
43 if ((*it)->value->Equals(&value)) { 43 if ((*it)->value->Equals(&value)) {
44 if (--(*it)->count == 0) { 44 if (--(*it)->count == 0) {
45 std::swap(*it, entries_.back()); 45 std::swap(*it, entries_.back());
46 entries_.pop_back(); 46 entries_.pop_back();
47 return true; // Removed the last entry. 47 return true; // Removed the last entry.
48 } 48 }
49 return false; // Removed, but no the last entry. 49 return false; // Removed, but no the last entry.
50 } 50 }
51 } 51 }
52 return false; // Nothing to remove. 52 return false; // Nothing to remove.
53 } 53 }
54 54
55 } // namespace extensions 55 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/permissions/settings_override_permission.cc ('k') | extensions/renderer/event_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698