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

Unified Diff: third_party/WebKit/public/platform/WebString.h

Issue 2469353003: Skip base::string16 if not necessary for WebString <-> ASCII conversion (Closed)
Patch Set: minor fix Created 4 years, 1 month 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 | « third_party/WebKit/Source/platform/exported/WebString.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/public/platform/WebString.h
diff --git a/third_party/WebKit/public/platform/WebString.h b/third_party/WebKit/public/platform/WebString.h
index d2ef01059e3acef7ae50c9ac991e2a8f79885ba8..6f6afb5471503a99d73913e96fddb5dfb2e8f2d0 100644
--- a/third_party/WebKit/public/platform/WebString.h
+++ b/third_party/WebKit/public/platform/WebString.h
@@ -100,6 +100,17 @@ class WebString {
return fromLatin1(reinterpret_cast<const WebLChar*>(s.data()), s.length());
}
+ // This asserts if the string contains non-ascii characters.
+ // Use this rather than calling base::UTF16ToASCII() which always incurs
+ // (likely unnecessary) string16 conversion.
+ BLINK_COMMON_EXPORT std::string ascii() const;
+
+ // Use this rather than calling base::IsStringASCII().
+ BLINK_COMMON_EXPORT bool containsOnlyASCII() const;
+
+ // Does same as fromLatin1 but asserts if the given string has non-ascii char.
+ BLINK_COMMON_EXPORT static WebString fromASCII(const std::string&);
+
template <int N>
WebString(const char (&data)[N]) {
assign(fromUTF8(data, N - 1));
« no previous file with comments | « third_party/WebKit/Source/platform/exported/WebString.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698