Chromium Code Reviews| Index: components/feedback/anonymizer_tool.h |
| diff --git a/components/feedback/anonymizer_tool.h b/components/feedback/anonymizer_tool.h |
| index 54a690fe9fa677eeb3ebb3a0a4d2b533d7a1d89f..554d89342b7119410acc641aa64e52d030d59f1e 100644 |
| --- a/components/feedback/anonymizer_tool.h |
| +++ b/components/feedback/anonymizer_tool.h |
| @@ -10,9 +10,23 @@ |
| #include <vector> |
| #include <base/macros.h> |
| +#include <base/memory/scoped_ptr.h> |
| + |
| +namespace re2 { |
| +class RE2; |
| +} |
| namespace feedback { |
| +struct CustomPatternWithoutContext { |
|
vasilii
2016/01/08 17:02:26
Does moving to cc work for you?
battre
2016/01/11 09:02:20
This is used in the unit test.
|
| + // A string literal used in anonymized tests. Matches to the |pattern| are |
| + // replaced with <|alias|: 1>, <|alias|: 2>, ... |
| + const char* alias; |
| + // A RE2 regexp with exactly one capture group. Matches will be replaced by |
| + // the alias reference described above. |
| + const char* pattern; |
| +}; |
| + |
| class AnonymizerTool { |
| public: |
| AnonymizerTool(); |
| @@ -23,14 +37,20 @@ class AnonymizerTool { |
| std::string Anonymize(const std::string& input); |
| private: |
| + re2::RE2* GetRegExp(const std::string& pattern); |
|
vasilii
2016/01/08 17:02:26
friend declaration first, then methods.
battre
2016/01/11 09:02:20
Done.
|
| + |
| friend class AnonymizerToolTest; |
| std::string AnonymizeMACAddresses(const std::string& input); |
| std::string AnonymizeCustomPatterns(std::string input); |
| - static std::string AnonymizeCustomPattern( |
| + std::string AnonymizeCustomPatternWithContext( |
| const std::string& input, |
| const std::string& pattern, |
| std::map<std::string, std::string>* identifier_space); |
| + std::string AnonymizeCustomPatternWithoutContext( |
| + const std::string& input, |
| + const CustomPatternWithoutContext& pattern, |
| + std::map<std::string, std::string>* identifier_space); |
| // Map of MAC addresses discovered in anonymized strings to anonymized |
| // representations. 11:22:33:44:55:66 gets anonymized to 11:22:33:00:00:01, |
| @@ -40,9 +60,13 @@ class AnonymizerTool { |
| std::map<std::string, std::string> mac_addresses_; |
| // Like mac addresses, identifiers in custom patterns are anonymized. |
| - // custom_patterns_[i] contains a map of original identifier to anonymized |
| - // identifier for custom pattern number i. |
| - std::vector<std::map<std::string, std::string>> custom_patterns_; |
| + // custom_patterns_with_context_[i] contains a map of original identifier to |
| + // anonymized identifier for custom pattern number i. |
| + std::vector<std::map<std::string, std::string>> custom_patterns_with_context_; |
| + std::vector<std::map<std::string, std::string>> |
| + custom_patterns_without_context_; |
| + |
| + std::map<std::string, scoped_ptr<re2::RE2>> regexp_cache_; |
|
vasilii
2016/01/08 17:02:26
Comment
battre
2016/01/11 09:02:20
Done.
|
| DISALLOW_COPY_AND_ASSIGN(AnonymizerTool); |
| }; |