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

Side by Side Diff: components/feedback/anonymizer_tool.cc

Issue 1918083002: Convert //components/[f-n]* 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
« no previous file with comments | « components/feedback/anonymizer_tool.h ('k') | components/feedback/feedback_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/feedback/anonymizer_tool.h" 5 #include "components/feedback/anonymizer_tool.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h"
9 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
11 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
12 #include "third_party/re2/src/re2/re2.h" 13 #include "third_party/re2/src/re2/re2.h"
13 14
14 using re2::RE2; 15 using re2::RE2;
15 16
16 namespace feedback { 17 namespace feedback {
17 18
18 namespace { 19 namespace {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 std::string anonymized = AnonymizeMACAddresses(input); 232 std::string anonymized = AnonymizeMACAddresses(input);
232 anonymized = AnonymizeCustomPatterns(std::move(anonymized)); 233 anonymized = AnonymizeCustomPatterns(std::move(anonymized));
233 return anonymized; 234 return anonymized;
234 } 235 }
235 236
236 RE2* AnonymizerTool::GetRegExp(const std::string& pattern) { 237 RE2* AnonymizerTool::GetRegExp(const std::string& pattern) {
237 if (regexp_cache_.find(pattern) == regexp_cache_.end()) { 238 if (regexp_cache_.find(pattern) == regexp_cache_.end()) {
238 RE2::Options options; 239 RE2::Options options;
239 // set_multiline of pcre is not supported by RE2, yet. 240 // set_multiline of pcre is not supported by RE2, yet.
240 options.set_dot_nl(true); // Dot matches a new line. 241 options.set_dot_nl(true); // Dot matches a new line.
241 scoped_ptr<RE2> re = make_scoped_ptr(new RE2(pattern, options)); 242 std::unique_ptr<RE2> re = base::WrapUnique(new RE2(pattern, options));
242 DCHECK_EQ(re2::RE2::NoError, re->error_code()) 243 DCHECK_EQ(re2::RE2::NoError, re->error_code())
243 << "Failed to parse:\n" << pattern << "\n" << re->error(); 244 << "Failed to parse:\n" << pattern << "\n" << re->error();
244 regexp_cache_[pattern] = std::move(re); 245 regexp_cache_[pattern] = std::move(re);
245 } 246 }
246 return regexp_cache_[pattern].get(); 247 return regexp_cache_[pattern].get();
247 } 248 }
248 249
249 std::string AnonymizerTool::AnonymizeMACAddresses(const std::string& input) { 250 std::string AnonymizerTool::AnonymizeMACAddresses(const std::string& input) {
250 // This regular expression finds the next MAC address. It splits the data into 251 // This regular expression finds the next MAC address. It splits the data into
251 // an OUI (Organizationally Unique Identifier) part and a NIC (Network 252 // an OUI (Organizationally Unique Identifier) part and a NIC (Network
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 364 }
364 365
365 skipped.AppendToString(&result); 366 skipped.AppendToString(&result);
366 result += replacement_id; 367 result += replacement_id;
367 } 368 }
368 text.AppendToString(&result); 369 text.AppendToString(&result);
369 return result; 370 return result;
370 } 371 }
371 372
372 } // namespace feedback 373 } // namespace feedback
OLDNEW
« no previous file with comments | « components/feedback/anonymizer_tool.h ('k') | components/feedback/feedback_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698