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

Side by Side Diff: components/subresource_filter/core/common/test_ruleset_creator.h

Issue 2793993002: [subresource_filter] Replace KMP by std::search. (Closed)
Patch Set: Address comments from csharrison@ Created 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_TEST_RULESET_CREATOR_H_ 5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_TEST_RULESET_CREATOR_H_
6 #define COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_TEST_RULESET_CREATOR_H_ 6 #define COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_TEST_RULESET_CREATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // Similar to CreateRulesetToDisallowURLsWithPathSuffix, but the resulting 78 // Similar to CreateRulesetToDisallowURLsWithPathSuffix, but the resulting
79 // ruleset consists of |num_of_suffixes| rules, each of them disallowing URLs 79 // ruleset consists of |num_of_suffixes| rules, each of them disallowing URLs
80 // with suffixes of the form |suffix|_k, 0 <= k < |num_of_suffixes|. 80 // with suffixes of the form |suffix|_k, 0 <= k < |num_of_suffixes|.
81 void CreateRulesetToDisallowURLsWithManySuffixes( 81 void CreateRulesetToDisallowURLsWithManySuffixes(
82 base::StringPiece suffix, 82 base::StringPiece suffix,
83 int num_of_suffixes, 83 int num_of_suffixes,
84 TestRulesetPair* test_ruleset_pair); 84 TestRulesetPair* test_ruleset_pair);
85 85
86 void CreateRulesetWithRules(const std::vector<proto::UrlRule>& rules, 86 void CreateRulesetWithRules(const std::vector<proto::UrlRule>& rules,
87 TestRulesetPair* test_ruleset_pair); 87 TestRulesetPair* test_ruleset_pair);
88 void CreateRulesetWithRules(const std::vector<proto::UrlRule>& rules,
engedy 2017/04/05 10:55:10 nit: CreateUnindexedRulesetWithRulest for consiste
pkalinnikov 2017/04/05 13:29:21 Done.
89 TestRuleset* test_unindexed_ruleset);
88 90
89 // Returns a unique |path| that is valid for the lifetime of this instance. 91 // Returns a unique |path| that is valid for the lifetime of this instance.
90 // No file at |path| will be automatically created. 92 // No file at |path| will be automatically created.
91 void GetUniqueTemporaryPath(base::FilePath* path); 93 void GetUniqueTemporaryPath(base::FilePath* path);
92 94
93 private: 95 private:
94 // Writes the |ruleset_contents| to a temporary file, and initializes 96 // Writes the |ruleset_contents| to a temporary file, and initializes
95 // |ruleset| to have the same |contents|, and the |path| to this file. 97 // |ruleset| to have the same |contents|, and the |path| to this file.
96 void CreateTestRulesetFromContents(std::vector<uint8_t> ruleset_contents, 98 void CreateTestRulesetFromContents(std::vector<uint8_t> ruleset_contents,
97 TestRuleset* ruleset); 99 TestRuleset* ruleset);
98 100
99 base::ScopedTempDir scoped_temp_dir_; 101 base::ScopedTempDir scoped_temp_dir_;
100 int next_unique_file_suffix = 1; 102 int next_unique_file_suffix = 1;
101 103
102 DISALLOW_COPY_AND_ASSIGN(TestRulesetCreator); 104 DISALLOW_COPY_AND_ASSIGN(TestRulesetCreator);
103 }; 105 };
104 106
105 } // namespace testing 107 } // namespace testing
106 } // namespace subresource_filter 108 } // namespace subresource_filter
107 109
108 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_TEST_RULESET_CREATOR_H_ 110 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_TEST_RULESET_CREATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698