Commit 1cd35197 authored by Marijn Kruisselbrink's avatar Marijn Kruisselbrink Committed by Commit Bot

Remove DefaultHash<scoped_refptr<const SecurityOrigin>>.

The existance of this DefaultHash implementation is potentially problematic
for several reasons:

- DefaultHash<scoped_refptr<T>> exists as well, making it very easy to end up
  with ODR violations where different translation units end up with different
  types for a HashSet<scoped_refptr<const SecurityOrigin>>.
- It is not obvious what "equality" the hash implements, since there are at
  least two equally valid definitions of equality for origins ("same origin"
  vs "same origin-domain").

Currently no code is actually using this hash, but our upcoming DOMStorage
onion souping will want a hash that implements same origin equality, so
for that this also changes the implementation to implement that version of
equality.

Bug: 781870
Change-Id: I79d8820194b51cb81ba4bf0684e65cba575dba82
Reviewed-on: https://chromium-review.googlesource.com/1229357Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592536}
parent 5b5e2d9d
......@@ -46,7 +46,6 @@
#include "third_party/blink/renderer/modules/webdatabase/sqlite/sqlite_file_system.h"
#include "third_party/blink/renderer/platform/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin_hash.h"
#include "third_party/blink/renderer/platform/wtf/assertions.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
......
......@@ -27,7 +27,6 @@
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_loading_log.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin_hash.h"
#include "third_party/blink/renderer/platform/wtf/assertions.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/cstring.h"
......
......@@ -36,6 +36,10 @@
namespace blink {
// This Hash implements the "same origin" equality relation between two origins.
// As such it ignores the domain that might or might not be set on the origin.
// If you need "same origin-domain" equality you'll need to use a different hash
// function.
struct SecurityOriginHash {
STATIC_ONLY(SecurityOriginHash);
static unsigned GetHash(const SecurityOrigin* origin) {
......@@ -53,19 +57,7 @@ struct SecurityOriginHash {
if (!a || !b)
return a == b;
if (a == b)
return true;
if (!a->IsSameSchemeHostPort(b))
return false;
if (a->DomainWasSetInDOM() != b->DomainWasSetInDOM())
return false;
if (a->DomainWasSetInDOM() && a->Domain() != b->Domain())
return false;
return true;
return a->IsSameSchemeHostPort(b);
}
static bool Equal(const SecurityOrigin* a,
const scoped_refptr<const SecurityOrigin>& b) {
......@@ -85,13 +77,4 @@ struct SecurityOriginHash {
} // namespace blink
namespace WTF {
template <>
struct DefaultHash<scoped_refptr<const blink::SecurityOrigin>> {
typedef blink::SecurityOriginHash Hash;
};
} // namespace WTF
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_WEBORIGIN_SECURITY_ORIGIN_HASH_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment