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

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

Issue 2257793002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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/exo/wayland/server.cc ('k') | components/feedback/feedback_data_unittest.cc » ('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/memory/ptr_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 std::string anonymized = AnonymizeMACAddresses(input); 232 std::string anonymized = AnonymizeMACAddresses(input);
233 anonymized = AnonymizeCustomPatterns(std::move(anonymized)); 233 anonymized = AnonymizeCustomPatterns(std::move(anonymized));
234 return anonymized; 234 return anonymized;
235 } 235 }
236 236
237 RE2* AnonymizerTool::GetRegExp(const std::string& pattern) { 237 RE2* AnonymizerTool::GetRegExp(const std::string& pattern) {
238 if (regexp_cache_.find(pattern) == regexp_cache_.end()) { 238 if (regexp_cache_.find(pattern) == regexp_cache_.end()) {
239 RE2::Options options; 239 RE2::Options options;
240 // set_multiline of pcre is not supported by RE2, yet. 240 // set_multiline of pcre is not supported by RE2, yet.
241 options.set_dot_nl(true); // Dot matches a new line. 241 options.set_dot_nl(true); // Dot matches a new line.
242 std::unique_ptr<RE2> re = base::WrapUnique(new RE2(pattern, options)); 242 std::unique_ptr<RE2> re = base::MakeUnique<RE2>(pattern, options);
243 DCHECK_EQ(re2::RE2::NoError, re->error_code()) 243 DCHECK_EQ(re2::RE2::NoError, re->error_code())
244 << "Failed to parse:\n" << pattern << "\n" << re->error(); 244 << "Failed to parse:\n" << pattern << "\n" << re->error();
245 regexp_cache_[pattern] = std::move(re); 245 regexp_cache_[pattern] = std::move(re);
246 } 246 }
247 return regexp_cache_[pattern].get(); 247 return regexp_cache_[pattern].get();
248 } 248 }
249 249
250 std::string AnonymizerTool::AnonymizeMACAddresses(const std::string& input) { 250 std::string AnonymizerTool::AnonymizeMACAddresses(const std::string& input) {
251 // 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
252 // 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
364 } 364 }
365 365
366 skipped.AppendToString(&result); 366 skipped.AppendToString(&result);
367 result += replacement_id; 367 result += replacement_id;
368 } 368 }
369 text.AppendToString(&result); 369 text.AppendToString(&result);
370 return result; 370 return result;
371 } 371 }
372 372
373 } // namespace feedback 373 } // namespace feedback
OLDNEW
« no previous file with comments | « components/exo/wayland/server.cc ('k') | components/feedback/feedback_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698