| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 static TextEncodingNameMap* textEncodingNameMap; | 106 static TextEncodingNameMap* textEncodingNameMap; |
| 107 static TextCodecMap* textCodecMap; | 107 static TextCodecMap* textCodecMap; |
| 108 | 108 |
| 109 namespace { | 109 namespace { |
| 110 static unsigned didExtendTextCodecMaps = 0; | 110 static unsigned didExtendTextCodecMaps = 0; |
| 111 | 111 |
| 112 ALWAYS_INLINE unsigned atomicDidExtendTextCodecMaps() { | 112 ALWAYS_INLINE unsigned atomicDidExtendTextCodecMaps() { |
| 113 return acquireLoad(&didExtendTextCodecMaps); | 113 return acquireLoad(&didExtendTextCodecMaps); |
| 114 } | 114 } |
| 115 | 115 |
| 116 ALWAYS_INLINE void atomicSetDidExtendTextCodemMaps() { | 116 ALWAYS_INLINE void atomicSetDidExtendTextCodecMaps() { |
| 117 releaseStore(&didExtendTextCodecMaps, 1); | 117 releaseStore(&didExtendTextCodecMaps, 1); |
| 118 } | 118 } |
| 119 } // namespace | 119 } // namespace |
| 120 | 120 |
| 121 static const char textEncodingNameBlacklist[][6] = {"UTF-7"}; | 121 static const char textEncodingNameBlacklist[][6] = {"UTF-7"}; |
| 122 | 122 |
| 123 #if ERROR_DISABLED | 123 #if ERROR_DISABLED |
| 124 | 124 |
| 125 static inline void checkExistingName(const char*, const char*) {} | 125 static inline void checkExistingName(const char*, const char*) {} |
| 126 | 126 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 if (!textEncodingNameMap) | 254 if (!textEncodingNameMap) |
| 255 buildBaseTextCodecMaps(); | 255 buildBaseTextCodecMaps(); |
| 256 | 256 |
| 257 MutexLocker lock(encodingRegistryMutex()); | 257 MutexLocker lock(encodingRegistryMutex()); |
| 258 | 258 |
| 259 if (const char* atomicName = textEncodingNameMap->get(name)) | 259 if (const char* atomicName = textEncodingNameMap->get(name)) |
| 260 return atomicName; | 260 return atomicName; |
| 261 if (atomicDidExtendTextCodecMaps()) | 261 if (atomicDidExtendTextCodecMaps()) |
| 262 return 0; | 262 return 0; |
| 263 extendTextCodecMaps(); | 263 extendTextCodecMaps(); |
| 264 atomicSetDidExtendTextCodemMaps(); | 264 atomicSetDidExtendTextCodecMaps(); |
| 265 return textEncodingNameMap->get(name); | 265 return textEncodingNameMap->get(name); |
| 266 } | 266 } |
| 267 | 267 |
| 268 template <typename CharacterType> | 268 template <typename CharacterType> |
| 269 const char* atomicCanonicalTextEncodingName(const CharacterType* characters, | 269 const char* atomicCanonicalTextEncodingName(const CharacterType* characters, |
| 270 size_t length) { | 270 size_t length) { |
| 271 char buffer[maxEncodingNameLength + 1]; | 271 char buffer[maxEncodingNameLength + 1]; |
| 272 size_t j = 0; | 272 size_t j = 0; |
| 273 for (size_t i = 0; i < length; ++i) { | 273 for (size_t i = 0; i < length; ++i) { |
| 274 char c = static_cast<char>(characters[i]); | 274 char c = static_cast<char>(characters[i]); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 MutexLocker lock(encodingRegistryMutex()); | 307 MutexLocker lock(encodingRegistryMutex()); |
| 308 | 308 |
| 309 TextEncodingNameMap::const_iterator it = textEncodingNameMap->begin(); | 309 TextEncodingNameMap::const_iterator it = textEncodingNameMap->begin(); |
| 310 TextEncodingNameMap::const_iterator end = textEncodingNameMap->end(); | 310 TextEncodingNameMap::const_iterator end = textEncodingNameMap->end(); |
| 311 for (; it != end; ++it) | 311 for (; it != end; ++it) |
| 312 fprintf(stderr, "'%s' => '%s'\n", it->key, it->value); | 312 fprintf(stderr, "'%s' => '%s'\n", it->key, it->value); |
| 313 } | 313 } |
| 314 #endif | 314 #endif |
| 315 | 315 |
| 316 } // namespace WTF | 316 } // namespace WTF |
| OLD | NEW |