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

Unified Diff: chrome/browser/download/download_query.cc

Issue 10387190: Migrate chrome/browser/download/download_query.cc to RE2 regex engine (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_query.cc
diff --git a/chrome/browser/download/download_query.cc b/chrome/browser/download/download_query.cc
index c2049d21dd05c2ebec94d887eada5932d4deec97..90538ce8c6906199e02ecc038ec59245b203c8cc 100644
--- a/chrome/browser/download/download_query.cc
+++ b/chrome/browser/download/download_query.cc
@@ -21,7 +21,7 @@
#include "base/values.h"
#include "content/public/browser/download_item.h"
#include "googleurl/src/gurl.h"
-#include "unicode/regex.h"
+#include "re2/re2.h"
using content::DownloadDangerType;
using content::DownloadItem;
@@ -129,13 +129,10 @@ template <typename ValueType> DownloadQuery::FilterCallback BuildFilter(
// Returns true if |accessor.Run(item)| matches |pattern|.
static bool FindRegex(
- icu::RegexPattern* pattern,
+ RE2* pattern,
const base::Callback<std::string(const DownloadItem&)>& accessor,
const DownloadItem& item) {
- icu::UnicodeString input(accessor.Run(item).c_str());
- UErrorCode status = U_ZERO_ERROR;
- scoped_ptr<icu::RegexMatcher> matcher(pattern->matcher(input, status));
- return matcher->find() == TRUE; // Ugh, VS complains bool != UBool.
+ return RE2::PartialMatch(accessor.Run(item), *pattern);
}
// Helper for building a Callback to FindRegex().
@@ -144,11 +141,8 @@ DownloadQuery::FilterCallback BuildRegexFilter(
std::string (*accessor)(const DownloadItem&)) {
std::string regex_str;
if (!GetAs(regex_value, &regex_str)) return DownloadQuery::FilterCallback();
- UParseError re_err;
- UErrorCode re_status = U_ZERO_ERROR;
- scoped_ptr<icu::RegexPattern> pattern(icu::RegexPattern::compile(
- icu::UnicodeString::fromUTF8(regex_str.c_str()), re_err, re_status));
- if (!U_SUCCESS(re_status)) return DownloadQuery::FilterCallback();
+ scoped_ptr<RE2> pattern(new RE2(regex_str));
+ if (!pattern->ok()) return DownloadQuery::FilterCallback();
return base::Bind(&FindRegex, base::Owned(pattern.release()),
base::Bind(accessor));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698