Changeset 71069 in webkit
- Timestamp:
- Nov 1, 2010 4:12:55 PM (13 years ago)
- Location:
- trunk/WebKit2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit2/ChangeLog
r71060 r71069 1 2010-11-01 Anders Carlsson <andersca@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 Add ArgumentCoder specialization for WTF::CString 6 https://bugs.webkit.org/show_bug.cgi?id=48796 7 8 * Platform/CoreIPC/ArgumentCoders.h: 9 1 10 2010-11-01 Anders Carlsson <andersca@apple.com> 2 11 -
trunk/WebKit2/Platform/CoreIPC/ArgumentCoders.h
r68677 r71069 34 34 #include <wtf/Vector.h> 35 35 #include <wtf/text/AtomicString.h> 36 #include <wtf/text/CString.h> 36 37 #include <wtf/text/WTFString.h> 37 38 … … 195 196 }; 196 197 197 template<> struct ArgumentCoder< String> {198 static void encode(ArgumentEncoder* encoder, const String& string)198 template<> struct ArgumentCoder<CString> { 199 static void encode(ArgumentEncoder* encoder, const CString& string) 199 200 { 200 201 // Special case the null string. … … 206 207 uint32_t length = string.length(); 207 208 encoder->encode(length); 208 encoder->encodeBytes(reinterpret_cast<const uint8_t*>(string. characters()), length * sizeof(UChar));209 } 210 211 static bool decode(ArgumentDecoder* decoder, String& s)209 encoder->encodeBytes(reinterpret_cast<const uint8_t*>(string.data()), length); 210 } 211 212 static bool decode(ArgumentDecoder* decoder, CString& result) 212 213 { 213 214 uint32_t length; … … 217 218 if (length == std::numeric_limits<uint32_t>::max()) { 218 219 // This is the null string. 219 s = String(); 220 result = CString(); 221 return true; 222 } 223 224 // Before allocating the string, make sure that the decoder buffer is big enough. 225 if (!decoder->bufferIsLargeEnoughToContain<char>(length)) { 226 decoder->markInvalid(); 227 return false; 228 } 229 230 char* buffer; 231 CString string = CString::newUninitialized(length, buffer); 232 if (!decoder->decodeBytes(reinterpret_cast<uint8_t*>(buffer), length)) 233 return false; 234 235 result = string; 236 return true; 237 } 238 }; 239 240 template<> struct ArgumentCoder<String> { 241 static void encode(ArgumentEncoder* encoder, const String& string) 242 { 243 // Special case the null string. 244 if (string.isNull()) { 245 encoder->encodeUInt32(std::numeric_limits<uint32_t>::max()); 246 return; 247 } 248 249 uint32_t length = string.length(); 250 encoder->encode(length); 251 encoder->encodeBytes(reinterpret_cast<const uint8_t*>(string.characters()), length * sizeof(UChar)); 252 } 253 254 static bool decode(ArgumentDecoder* decoder, String& result) 255 { 256 uint32_t length; 257 if (!decoder->decode(length)) 258 return false; 259 260 if (length == std::numeric_limits<uint32_t>::max()) { 261 // This is the null string. 262 result = String(); 220 263 return true; 221 264 } … … 232 275 return false; 233 276 234 s= string;277 result = string; 235 278 return true; 236 279 }
Note: See TracChangeset
for help on using the changeset viewer.