Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/ScriptModule.h |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptModule.h b/third_party/WebKit/Source/bindings/core/v8/ScriptModule.h |
| index fc51232d7f5d635423021db752bd6d01bb9ff217..2b4d1040ad0b5b8d8a85e81624d7c64072ef1f06 100644 |
| --- a/third_party/WebKit/Source/bindings/core/v8/ScriptModule.h |
| +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptModule.h |
| @@ -22,21 +22,79 @@ class CORE_EXPORT ScriptModule final { |
| const String& source, |
| const String& fileName); |
| + // TODO(kouhei): Remove copy ctor |
| ScriptModule() {} |
| - ScriptModule(const ScriptModule& module) : m_module(module.m_module) {} |
| + ScriptModule(WTF::HashTableDeletedValueType) |
| + : m_module(WTF::HashTableDeletedValue) {} |
| ~ScriptModule(); |
| bool instantiate(ScriptState*); |
| void evaluate(ScriptState*); |
| + bool isHashTableDeletedValue() const { |
| + return m_module.isHashTableDeletedValue(); |
| + } |
| + |
| + bool operator==(const blink::ScriptModule& other) const { |
| + if (isHashTableDeletedValue() && other.isHashTableDeletedValue()) |
| + return true; |
| + |
| + if (isHashTableDeletedValue() || other.isHashTableDeletedValue()) |
| + return false; |
| + |
| + blink::SharedPersistent<v8::Module>* left = m_module.get(); |
| + blink::SharedPersistent<v8::Module>* right = other.m_module.get(); |
| + if (left == right) |
| + return true; |
| + if (!left || !right) |
| + return false; |
| + return *left == *right; |
| + } |
| + |
| + bool operator!=(const blink::ScriptModule& other) const { |
| + return !(*this == other); |
| + } |
| + |
| bool isNull() const { return m_module->isEmpty(); } |
| private: |
| ScriptModule(v8::Isolate*, v8::Local<v8::Module>); |
| RefPtr<SharedPersistent<v8::Module>> m_module; |
| + unsigned m_identityHash = 0; |
| + |
| + friend struct ScriptModuleHash; |
| +}; |
| + |
| +struct ScriptModuleHash { |
| + STATIC_ONLY(ScriptModuleHash); |
| + |
| + public: |
| + static unsigned hash(const blink::ScriptModule& key) { |
| + return key.m_identityHash; |
|
haraken
2017/04/04 05:26:06
Why can't we simply use key.m_module.get() for the
kouhei (in TOK)
2017/04/04 05:54:32
Discussed offline.
No, because ScriptModule::resol
|
| + } |
| + |
| + static bool equal(const blink::ScriptModule& a, |
| + const blink::ScriptModule& b) { |
| + return a == b; |
| + } |
| + |
| + static constexpr bool safeToCompareToEmptyOrDeleted = true; |
| }; |
| } // namespace blink |
| +namespace WTF { |
| + |
| +template <> |
| +struct DefaultHash<blink::ScriptModule> { |
| + using Hash = blink::ScriptModuleHash; |
| +}; |
| + |
| +template <> |
| +struct HashTraits<blink::ScriptModule> |
| + : public SimpleClassHashTraits<blink::ScriptModule> {}; |
| + |
| +} // namespace WTF |
| + |
| #endif // ScriptModule_h |