Commit e89053db authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

Avoid const_cast in DOMDataStore.

It's never necessary to extract a non-const pointer from DOMDataStore::wrapper_map_,
so it can be keyed by WeakMember<cont ScriptWrappable>, which avoids the need to
const_cast.

Change-Id: Ib1e25bf312cf09cf7c117a0485c1c30c338474c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1884280
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Auto-Submit: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710094}
parent 653e60be
...@@ -173,8 +173,7 @@ class DOMDataStore final : public GarbageCollected<DOMDataStore> { ...@@ -173,8 +173,7 @@ class DOMDataStore final : public GarbageCollected<DOMDataStore> {
bool ContainsWrapper(const ScriptWrappable* object) { bool ContainsWrapper(const ScriptWrappable* object) {
if (is_main_world_) if (is_main_world_)
return object->ContainsWrapper(); return object->ContainsWrapper();
return wrapper_map_.find(const_cast<ScriptWrappable*>(object)) != return wrapper_map_.find(object) != wrapper_map_.end();
wrapper_map_.end();
} }
virtual void Trace(Visitor*); virtual void Trace(Visitor*);
...@@ -216,7 +215,7 @@ class DOMDataStore final : public GarbageCollected<DOMDataStore> { ...@@ -216,7 +215,7 @@ class DOMDataStore final : public GarbageCollected<DOMDataStore> {
bool is_main_world_; bool is_main_world_;
// Ephemeron map: WrappedReference will be kept alive as long as // Ephemeron map: WrappedReference will be kept alive as long as
// ScriptWrappable is alive. // ScriptWrappable is alive.
HeapHashMap<WeakMember<ScriptWrappable>, Member<WrappedReference>> HeapHashMap<WeakMember<const ScriptWrappable>, Member<WrappedReference>>
wrapper_map_; wrapper_map_;
DISALLOW_COPY_AND_ASSIGN(DOMDataStore); DISALLOW_COPY_AND_ASSIGN(DOMDataStore);
......
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