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> | |
46 | 45 |
47 namespace WTF { | 46 namespace WTF { |
48 | 47 |
49 const size_t maxEncodingNameLength = 63; | 48 const size_t maxEncodingNameLength = 63; |
50 | 49 |
51 // Hash for all-ASCII strings that does case folding. | 50 // Hash for all-ASCII strings that does case folding. |
52 struct TextEncodingNameHash { | 51 struct TextEncodingNameHash { |
53 static bool equal(const char* s1, const char* s2) | 52 static bool equal(const char* s1, const char* s2) |
54 { | 53 { |
55 char c1; | 54 char c1; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 { | 236 { |
238 TextCodecReplacement::registerEncodingNames(addToTextEncodingNameMap); | 237 TextCodecReplacement::registerEncodingNames(addToTextEncodingNameMap); |
239 TextCodecReplacement::registerCodecs(addToTextCodecMap); | 238 TextCodecReplacement::registerCodecs(addToTextCodecMap); |
240 | 239 |
241 TextCodecICU::registerEncodingNames(addToTextEncodingNameMap); | 240 TextCodecICU::registerEncodingNames(addToTextEncodingNameMap); |
242 TextCodecICU::registerCodecs(addToTextCodecMap); | 241 TextCodecICU::registerCodecs(addToTextCodecMap); |
243 | 242 |
244 pruneBlacklistedCodecs(); | 243 pruneBlacklistedCodecs(); |
245 } | 244 } |
246 | 245 |
247 std::unique_ptr<TextCodec> newTextCodec(const TextEncoding& encoding) | 246 PassOwnPtr<TextCodec> newTextCodec(const TextEncoding& encoding) |
248 { | 247 { |
249 MutexLocker lock(encodingRegistryMutex()); | 248 MutexLocker lock(encodingRegistryMutex()); |
250 | 249 |
251 | 250 |
252 ASSERT(textCodecMap); | 251 ASSERT(textCodecMap); |
253 TextCodecFactory factory = textCodecMap->get(encoding.name()); | 252 TextCodecFactory factory = textCodecMap->get(encoding.name()); |
254 ASSERT(factory.function); | 253 ASSERT(factory.function); |
255 return factory.function(encoding, factory.additionalData); | 254 return factory.function(encoding, factory.additionalData); |
256 } | 255 } |
257 | 256 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 MutexLocker lock(encodingRegistryMutex()); | 315 MutexLocker lock(encodingRegistryMutex()); |
317 | 316 |
318 TextEncodingNameMap::const_iterator it = textEncodingNameMap->begin(); | 317 TextEncodingNameMap::const_iterator it = textEncodingNameMap->begin(); |
319 TextEncodingNameMap::const_iterator end = textEncodingNameMap->end(); | 318 TextEncodingNameMap::const_iterator end = textEncodingNameMap->end(); |
320 for (; it != end; ++it) | 319 for (; it != end; ++it) |
321 fprintf(stderr, "'%s' => '%s'\n", it->key, it->value); | 320 fprintf(stderr, "'%s' => '%s'\n", it->key, it->value); |
322 } | 321 } |
323 #endif | 322 #endif |
324 | 323 |
325 } // namespace WTF | 324 } // namespace WTF |
OLD | NEW |