CFErrorRef ResourceError::cfError() const { if (m_isNull) { ASSERT(!m_platformError); return 0; } if (!m_platformError) { RetainPtr<CFMutableDictionaryRef> userInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); if (!m_localizedDescription.isEmpty()) { RetainPtr<CFStringRef> localizedDescriptionString(AdoptCF, m_localizedDescription.createCFString()); CFDictionarySetValue(userInfo.get(), kCFErrorLocalizedDescriptionKey, localizedDescriptionString.get()); } if (!m_failingURL.isEmpty()) { RetainPtr<CFStringRef> failingURLString(AdoptCF, m_failingURL.createCFString()); CFDictionarySetValue(userInfo.get(), failingURLStringKey, failingURLString.get()); RetainPtr<CFURLRef> url(AdoptCF, KURL(ParsedURLString, m_failingURL).createCFURL()); CFDictionarySetValue(userInfo.get(), failingURLKey, url.get()); } #if PLATFORM(WIN) if (m_certificate) wkSetSSLPeerCertificateData(userInfo.get(), m_certificate.get()); #endif RetainPtr<CFStringRef> domainString(AdoptCF, m_domain.createCFString()); m_platformError.adoptCF(CFErrorCreate(0, domainString.get(), m_errorCode, userInfo.get())); } return m_platformError.get(); }
const char * LabelHash::findLabel( char const * const domain, uint32 hashValue ) { std::string domainString(domain); TDomainMap::iterator domainIt = gs_allDomains.find(domainString); if(domainIt == gs_allDomains.end()) { // Domain not found return NULL; } // ---------- // Domain found, check for existing hash value THashToStringMap & domainLabels = (*domainIt).second; THashToStringMap::iterator hashIt = domainLabels.find(hashValue); if(hashIt != domainLabels.end()) { return (*hashIt).second.c_str(); } // ---------- // String not found return NULL; }
uint32 LabelHash::checkLabel( char const * const domain, char const * const label, uint32 hashValue ) { // First things first - make sure the label actually hashes to the given value uint32 actualHash = Crc::calculate(label); FATAL(actualHash != hashValue, ("LabelHash::checkLabel - Label [%s] hashes to [%d] and not [%d]\n",label,actualHash,hashValue)); // ---------- std::string domainString(domain); std::string labelString(label); // Find the hash-to-label map for the given domain, or // create a new one if there isn't one already. TDomainMap::iterator domainIt = gs_allDomains.find(domainString); if(domainIt == gs_allDomains.end()) { // Domain not found, create entry for it containing the label THashToStringMap newDomainMap; newDomainMap.insert( THashEntry(hashValue,labelString) ); gs_allDomains.insert( TDomainEntry(domainString,newDomainMap) ); } else { // Domain found, check for existing hash value THashToStringMap & domainLabels = (*domainIt).second; THashToStringMap::iterator labelIt = domainLabels.find(hashValue); if(labelIt == domainLabels.end()) { // Hash value not found, add it to the domain domainLabels.insert( THashEntry(hashValue,labelString) ); } else { // Hash value found, fatal if the string mapped to it doesn't match // the given string std::string & currentLabel = (*labelIt).second; FATAL( currentLabel != labelString, ("LabelHash::checkLabel - Found a hash collision for domain [%s], label [%s] - two labels hashed to the same value\n",domain,label)); } } // All is good, hash is OK. return hashValue; };