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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/exported/WebString.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 BLINK_COMMON_EXPORT std::string latin1() const; 94 BLINK_COMMON_EXPORT std::string latin1() const;
95 95
96 BLINK_COMMON_EXPORT static WebString fromLatin1(const WebLChar* data, 96 BLINK_COMMON_EXPORT static WebString fromLatin1(const WebLChar* data,
97 size_t length); 97 size_t length);
98 98
99 static WebString fromLatin1(const std::string& s) { 99 static WebString fromLatin1(const std::string& s) {
100 return fromLatin1(reinterpret_cast<const WebLChar*>(s.data()), s.length()); 100 return fromLatin1(reinterpret_cast<const WebLChar*>(s.data()), s.length());
101 } 101 }
102 102
103 // This asserts if the string contains non-ascii characters.
104 // Use this rather than calling base::UTF16ToASCII() which always incurs
105 // (likely unnecessary) string16 conversion.
106 BLINK_COMMON_EXPORT std::string ascii() const;
107
108 // Use this rather than calling base::IsStringASCII().
109 BLINK_COMMON_EXPORT bool containsOnlyASCII() const;
110
111 // Does same as fromLatin1 but asserts if the given string has non-ascii char.
112 BLINK_COMMON_EXPORT static WebString fromASCII(const std::string&);
113
103 template <int N> 114 template <int N>
104 WebString(const char (&data)[N]) { 115 WebString(const char (&data)[N]) {
105 assign(fromUTF8(data, N - 1)); 116 assign(fromUTF8(data, N - 1));
106 } 117 }
107 118
108 template <int N> 119 template <int N>
109 WebString& operator=(const char (&data)[N]) { 120 WebString& operator=(const char (&data)[N]) {
110 assign(fromUTF8(data, N - 1)); 121 assign(fromUTF8(data, N - 1));
111 return *this; 122 return *this;
112 } 123 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 return a.equals(b); 195 return a.equals(b);
185 } 196 }
186 197
187 inline bool operator!=(const WebString& a, const WebString& b) { 198 inline bool operator!=(const WebString& a, const WebString& b) {
188 return !(a == b); 199 return !(a == b);
189 } 200 }
190 201
191 } // namespace blink 202 } // namespace blink
192 203
193 #endif 204 #endif
OLDNEW
« 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