OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007-2009 Torch Mobile, Inc. | 3 * Copyright (C) 2007-2009 Torch Mobile, Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "wtf/StringExtras.h" | 35 #include "wtf/StringExtras.h" |
36 #include "wtf/ThreadingPrimitives.h" | 36 #include "wtf/ThreadingPrimitives.h" |
37 #include "wtf/text/CString.h" | 37 #include "wtf/text/CString.h" |
38 #include "wtf/text/TextCodecICU.h" | 38 #include "wtf/text/TextCodecICU.h" |
39 #include "wtf/text/TextCodecLatin1.h" | 39 #include "wtf/text/TextCodecLatin1.h" |
40 #include "wtf/text/TextCodecReplacement.h" | 40 #include "wtf/text/TextCodecReplacement.h" |
41 #include "wtf/text/TextCodecUTF16.h" | 41 #include "wtf/text/TextCodecUTF16.h" |
42 #include "wtf/text/TextCodecUTF8.h" | 42 #include "wtf/text/TextCodecUTF8.h" |
43 #include "wtf/text/TextCodecUserDefined.h" | 43 #include "wtf/text/TextCodecUserDefined.h" |
44 #include "wtf/text/TextEncoding.h" | 44 #include "wtf/text/TextEncoding.h" |
| 45 #include <memory> |
45 | 46 |
46 namespace WTF { | 47 namespace WTF { |
47 | 48 |
48 const size_t maxEncodingNameLength = 63; | 49 const size_t maxEncodingNameLength = 63; |
49 | 50 |
50 // Hash for all-ASCII strings that does case folding. | 51 // Hash for all-ASCII strings that does case folding. |
51 struct TextEncodingNameHash { | 52 struct TextEncodingNameHash { |
52 static bool equal(const char* s1, const char* s2) | 53 static bool equal(const char* s1, const char* s2) |
53 { | 54 { |
54 char c1; | 55 char c1; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 { | 237 { |
237 TextCodecReplacement::registerEncodingNames(addToTextEncodingNameMap); | 238 TextCodecReplacement::registerEncodingNames(addToTextEncodingNameMap); |
238 TextCodecReplacement::registerCodecs(addToTextCodecMap); | 239 TextCodecReplacement::registerCodecs(addToTextCodecMap); |
239 | 240 |
240 TextCodecICU::registerEncodingNames(addToTextEncodingNameMap); | 241 TextCodecICU::registerEncodingNames(addToTextEncodingNameMap); |
241 TextCodecICU::registerCodecs(addToTextCodecMap); | 242 TextCodecICU::registerCodecs(addToTextCodecMap); |
242 | 243 |
243 pruneBlacklistedCodecs(); | 244 pruneBlacklistedCodecs(); |
244 } | 245 } |
245 | 246 |
246 PassOwnPtr<TextCodec> newTextCodec(const TextEncoding& encoding) | 247 std::unique_ptr<TextCodec> newTextCodec(const TextEncoding& encoding) |
247 { | 248 { |
248 MutexLocker lock(encodingRegistryMutex()); | 249 MutexLocker lock(encodingRegistryMutex()); |
249 | 250 |
250 | 251 |
251 ASSERT(textCodecMap); | 252 ASSERT(textCodecMap); |
252 TextCodecFactory factory = textCodecMap->get(encoding.name()); | 253 TextCodecFactory factory = textCodecMap->get(encoding.name()); |
253 ASSERT(factory.function); | 254 ASSERT(factory.function); |
254 return factory.function(encoding, factory.additionalData); | 255 return factory.function(encoding, factory.additionalData); |
255 } | 256 } |
256 | 257 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 MutexLocker lock(encodingRegistryMutex()); | 316 MutexLocker lock(encodingRegistryMutex()); |
316 | 317 |
317 TextEncodingNameMap::const_iterator it = textEncodingNameMap->begin(); | 318 TextEncodingNameMap::const_iterator it = textEncodingNameMap->begin(); |
318 TextEncodingNameMap::const_iterator end = textEncodingNameMap->end(); | 319 TextEncodingNameMap::const_iterator end = textEncodingNameMap->end(); |
319 for (; it != end; ++it) | 320 for (; it != end; ++it) |
320 fprintf(stderr, "'%s' => '%s'\n", it->key, it->value); | 321 fprintf(stderr, "'%s' => '%s'\n", it->key, it->value); |
321 } | 322 } |
322 #endif | 323 #endif |
323 | 324 |
324 } // namespace WTF | 325 } // namespace WTF |
OLD | NEW |