Changeset 287077 in webkit
- Timestamp:
- Dec 15, 2021, 9:10:36 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
platform/network/ProtectionSpaceBase.cpp (modified) (3 diffs)
-
platform/network/ProtectionSpaceBase.h (modified) (4 diffs)
-
platform/network/ProtectionSpaceHash.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r287076 r287077 1 2021-12-15 Chris Dumez <cdumez@apple.com> 2 3 http/tests/security/basic-auth-subresource.html and some other http auth tests are flaky 4 https://bugs.webkit.org/show_bug.cgi?id=234314 5 <rdar://85150486> 6 7 Reviewed by Darin Adler. 8 9 http/tests/security/basic-auth-subresource.html and some other http auth tests are flaky. 10 11 No new tests, I will be able to unskip those layout tests in internal once this lands. 12 13 * platform/network/ProtectionSpaceBase.cpp: 14 (WebCore::ProtectionSpaceBase::ProtectionSpaceBase): 15 (WebCore::ProtectionSpaceBase::host const): Deleted. 16 (WebCore::ProtectionSpaceBase::port const): Deleted. 17 (WebCore::ProtectionSpaceBase::serverType const): Deleted. 18 (WebCore::ProtectionSpaceBase::realm const): Deleted. 19 (WebCore::ProtectionSpaceBase::authenticationScheme const): Deleted. 20 * platform/network/ProtectionSpaceBase.h: 21 (WebCore::ProtectionSpaceBase::host const): 22 (WebCore::ProtectionSpaceBase::port const): 23 (WebCore::ProtectionSpaceBase::serverType const): 24 (WebCore::ProtectionSpaceBase::realm const): 25 (WebCore::ProtectionSpaceBase::authenticationScheme const): 26 Clean up / modernise the ProtectionSpaceBase class. 27 28 * platform/network/ProtectionSpaceHash.h: 29 (WebCore::ProtectionSpaceHash::hash): 30 - Use Hasher in ProtectionSpaceHash::hash() as it is less error-prone. I believe the 31 previous implementation was wrong because it was calling 32 `StringHasher::hashMemory(hashCodes, codeCount)` instead of 33 `StringHasher::hashMemory(hashCodes, codeCount * sizeof(unsigned))`. 34 This could have resulted in inefficiencies I believe since we were not hashing the 35 whole array memory. 36 - Fix ProtectionSpace<ProtectionSpace> so that emptyValueIsZero is false instead of 37 true. This was a bug since the ProtectionSpaceBase constructor initializes data 38 members to non-zero values. 39 1 40 2021-12-15 Gavin Phillips <gavin.p@apple.com> 2 41 -
trunk/Source/WebCore/platform/network/ProtectionSpaceBase.cpp
r279872 r287077 34 34 35 35 namespace WebCore { 36 37 // Need to enforce empty, non-null strings due to the pickiness of the String == String operator38 // combined with the semantics of the String(NSString*) constructor39 ProtectionSpaceBase::ProtectionSpaceBase()40 : m_host(emptyString())41 , m_port(0)42 , m_serverType(ProtectionSpaceServerHTTP)43 , m_realm(emptyString())44 , m_authenticationScheme(ProtectionSpaceAuthenticationSchemeDefault)45 , m_isHashTableDeletedValue(false)46 {47 }48 36 49 37 // Need to enforce empty, non-null strings due to the pickiness of the String == String operator … … 51 39 ProtectionSpaceBase::ProtectionSpaceBase(const String& host, int port, ProtectionSpaceServerType serverType, const String& realm, ProtectionSpaceAuthenticationScheme authenticationScheme) 52 40 : m_host(host.length() ? host : emptyString()) 41 , m_realm(realm.length() ? realm : emptyString()) 53 42 , m_port(port) 54 43 , m_serverType(serverType) 55 , m_realm(realm.length() ? realm : emptyString())56 44 , m_authenticationScheme(authenticationScheme) 57 , m_isHashTableDeletedValue(false)58 45 { 59 }60 61 const String& ProtectionSpaceBase::host() const62 {63 return m_host;64 }65 66 int ProtectionSpaceBase::port() const67 {68 return m_port;69 }70 71 ProtectionSpaceServerType ProtectionSpaceBase::serverType() const72 {73 return m_serverType;74 46 } 75 47 … … 80 52 m_serverType == ProtectionSpaceProxyFTP || 81 53 m_serverType == ProtectionSpaceProxySOCKS); 82 }83 84 const String& ProtectionSpaceBase::realm() const85 {86 return m_realm;87 }88 89 ProtectionSpaceAuthenticationScheme ProtectionSpaceBase::authenticationScheme() const90 {91 return m_authenticationScheme;92 54 } 93 55 -
trunk/Source/WebCore/platform/network/ProtectionSpaceBase.h
r279872 r287077 1 1 /* 2 * Copyright (C) 2007-202 0Apple Inc. All rights reserved.2 * Copyright (C) 2007-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 65 65 bool isHashTableDeletedValue() const { return m_isHashTableDeletedValue; } 66 66 67 WEBCORE_EXPORT const String& host() const;68 WEBCORE_EXPORT int port() const;69 WEBCORE_EXPORT ProtectionSpaceServerType serverType() const;67 const String& host() const { return m_host; } 68 int port() const { return m_port; } 69 ProtectionSpaceServerType serverType() const { return m_serverType; } 70 70 WEBCORE_EXPORT bool isProxy() const; 71 WEBCORE_EXPORT const String& realm() const;72 WEBCORE_EXPORT ProtectionSpaceAuthenticationScheme authenticationScheme() const;71 const String& realm() const { return m_realm; } 72 ProtectionSpaceAuthenticationScheme authenticationScheme() const { return m_authenticationScheme; } 73 73 74 74 WEBCORE_EXPORT bool receivesCredentialSecurely() const; … … 80 80 81 81 protected: 82 WEBCORE_EXPORT ProtectionSpaceBase();82 ProtectionSpaceBase() = default; 83 83 WEBCORE_EXPORT ProtectionSpaceBase(const String& host, int port, ProtectionSpaceServerType, const String& realm, ProtectionSpaceAuthenticationScheme); 84 84 … … 89 89 90 90 private: 91 String m_host; 92 int m_port; 93 ProtectionSpaceServerType m_serverType; 94 String m_realm; 95 ProtectionSpaceAuthenticationScheme m_authenticationScheme; 96 bool m_isHashTableDeletedValue; 91 // Need to enforce empty, non-null strings due to the pickiness of the String == String operator 92 // combined with the semantics of the String(NSString*) constructor 93 String m_host { emptyString() }; 94 String m_realm { emptyString() }; 95 96 int m_port { 0 }; 97 ProtectionSpaceServerType m_serverType { ProtectionSpaceServerHTTP }; 98 ProtectionSpaceAuthenticationScheme m_authenticationScheme { ProtectionSpaceAuthenticationSchemeDefault }; 99 bool m_isHashTableDeletedValue { false }; 97 100 }; 98 101 -
trunk/Source/WebCore/platform/network/ProtectionSpaceHash.h
r264488 r287077 1 1 /* 2 * Copyright (C) 2009 Apple Inc. All Rights Reserved.2 * Copyright (C) 2009-2021 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef ProtectionSpaceHash_h 27 #define ProtectionSpaceHash_h 26 #pragma once 28 27 29 28 #include "ProtectionSpace.h" 30 29 #include <wtf/HashTraits.h> 30 #include <wtf/Hasher.h> 31 31 32 32 namespace WebCore { … … 35 35 static unsigned hash(const ProtectionSpace& protectionSpace) 36 36 { 37 unsigned hashCodes[5] = { 38 protectionSpace.host().impl() ? protectionSpace.host().impl()->hash() : 0, 39 static_cast<unsigned>(protectionSpace.port()), 40 static_cast<unsigned>(protectionSpace.serverType()), 41 static_cast<unsigned>(protectionSpace.authenticationScheme()), 42 protectionSpace.realm().impl() ? protectionSpace.realm().impl()->hash() : 0 43 }; 44 45 unsigned codeCount = sizeof(hashCodes); 46 // Ignore realm for proxies. 47 if (protectionSpace.isProxy()) 48 codeCount -= sizeof(hashCodes[0]); 49 return StringHasher::hashMemory(hashCodes, codeCount); 37 Hasher hasher; 38 add(hasher, protectionSpace.host()); 39 add(hasher, protectionSpace.port()); 40 add(hasher, protectionSpace.serverType()); 41 add(hasher, protectionSpace.authenticationScheme()); 42 if (!protectionSpace.isProxy()) 43 add(hasher, protectionSpace.realm()); 44 return hasher.hash(); 50 45 } 51 46 52 47 static bool equal(const ProtectionSpace& a, const ProtectionSpace& b) { return a == b; } 53 static const bool safeToCompareToEmptyOrDeleted = false;48 static constexpr bool safeToCompareToEmptyOrDeleted = false; 54 49 }; 55 50 … … 58 53 namespace WTF { 59 54 60 template<> struct HashTraits<WebCore::ProtectionSpace> : SimpleClassHashTraits<WebCore::ProtectionSpace> { }; 55 template<> struct HashTraits<WebCore::ProtectionSpace> : SimpleClassHashTraits<WebCore::ProtectionSpace> { 56 static constexpr bool emptyValueIsZero = false; 57 }; 61 58 template<> struct DefaultHash<WebCore::ProtectionSpace> : WebCore::ProtectionSpaceHash { }; 62 59 63 60 } // namespace WTF 64 65 66 #endif // ProtectionSpaceHash_h
Note:
See TracChangeset
for help on using the changeset viewer.