Changeset 207871 in webkit
- Timestamp:
- Oct 26, 2016 1:08:11 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207869 r207871 1 2016-10-26 Youenn Fablet <youenn@apple.com> 2 3 Make CachedResourceLoader originsMatch check more efficient 4 https://bugs.webkit.org/show_bug.cgi?id=163938 5 6 Reviewed by Darin Adler. 7 8 No change of behavior. 9 10 * loader/cache/CachedResourceLoader.cpp: 11 (WebCore::CachedResourceLoader::shouldUpdateCachedResourceWithCurrentRequest): 12 (WebCore::originsMatch): Moved to SecurityOrigin.cpp. 13 * page/SecurityOrigin.cpp: 14 (WebCore::areOriginsMatching): Helper routine to check whether origins are matching. 15 (WebCore::originsMatch): Ensuring string comparison provides the same result as this function. 16 * page/SecurityOrigin.h: 17 (WebCore::SecurityOrigin::protocol): 18 (WebCore::SecurityOrigin::host): 19 (WebCore::SecurityOrigin::domain): 20 1 21 2016-10-25 Yusuke Suzuki <utatane.tea@gmail.com> 2 22 -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp
r207817 r207871 552 552 } 553 553 554 static inline bool originsMatch(const CachedResourceRequest& request, const CachedResource& resource)555 {556 if (request.origin() == resource.origin())557 return true;558 if (!request.origin() || !resource.origin())559 return false;560 // We use string comparison as this is how they are serialized as HTTP Origin header value.561 // This is in particular useful for unique origins that are serialized as "null"562 return request.origin()->toString() == resource.origin()->toString();563 }564 565 554 bool CachedResourceLoader::shouldUpdateCachedResourceWithCurrentRequest(const CachedResource& resource, const CachedResourceRequest& request) 566 555 { … … 596 585 } 597 586 598 if (resource.options().mode != request.options().mode || !originsMatch(request , resource))587 if (resource.options().mode != request.options().mode || !originsMatch(request.origin(), resource.origin())) 599 588 return true; 600 589 -
trunk/Source/WebCore/page/SecurityOrigin.cpp
r207769 r207871 463 463 } 464 464 465 static inline bool areOriginsMatching(const SecurityOrigin& origin1, const SecurityOrigin& origin2) 466 { 467 if (origin1.isUnique() || origin2.isUnique()) 468 return origin1.isUnique() == origin2.isUnique(); 469 470 if (origin1.protocol() != origin2.protocol()) 471 return false; 472 473 if (origin1.protocol() == "file") 474 return true; 475 476 if (origin1.host() != origin2.host()) 477 return false; 478 479 return origin1.port() == origin2.port(); 480 } 481 482 // This function mimics the result of string comparison of serialized origins 483 bool originsMatch(const SecurityOrigin& origin1, const SecurityOrigin& origin2) 484 { 485 if (&origin1 == &origin2) 486 return true; 487 488 bool result = areOriginsMatching(origin1, origin2); 489 ASSERT(result == (origin1.toString() == origin2.toString())); 490 return result; 491 } 492 493 bool originsMatch(const SecurityOrigin* origin1, const SecurityOrigin* origin2) 494 { 495 if (!origin1 || !origin2) 496 return origin1 == origin2; 497 498 return originsMatch(*origin1, *origin2); 499 } 500 465 501 Ref<SecurityOrigin> SecurityOrigin::createFromString(const String& originString) 466 502 { … … 471 507 472 508 RefPtr<SecurityOrigin> SecurityOrigin::maybeCreateFromDatabaseIdentifier(const String& databaseIdentifier) 473 { 509 { 474 510 // Make sure there's a first separator 475 511 size_t separator1 = databaseIdentifier.find(separatorCharacter); 476 512 if (separator1 == notFound) 477 513 return nullptr; 478 514 479 515 // Make sure there's a second separator 480 516 size_t separator2 = databaseIdentifier.reverseFind(separatorCharacter); -
trunk/Source/WebCore/page/SecurityOrigin.h
r207769 r207871 85 85 bool domainWasSetInDOM() const { return m_domainWasSetInDOM; } 86 86 87 Stringprotocol() const { return m_protocol; }88 Stringhost() const { return m_host; }89 Stringdomain() const { return m_domain; }87 const String& protocol() const { return m_protocol; } 88 const String& host() const { return m_host; } 89 const String& domain() const { return m_domain; } 90 90 Optional<uint16_t> port() const { return m_port; } 91 91 … … 236 236 }; 237 237 238 // Returns true if the Origin header values serialized from these two origins would be the same. 239 bool originsMatch(const SecurityOrigin&, const SecurityOrigin&); 240 bool originsMatch(const SecurityOrigin*, const SecurityOrigin*); 241 238 242 } // namespace WebCore
Note: See TracChangeset
for help on using the changeset viewer.