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..3d932a256ddabfc9d9b422d7830ce18e2c253a1b 100644 |
| --- a/third_party/WebKit/Source/bindings/core/v8/ScriptModule.h |
| +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptModule.h |
| @@ -22,21 +22,73 @@ 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& rhs) const { |
| + if (m_module.isHashTableDeletedValue() && |
|
yhirano
2017/03/30 07:35:09
isHashTableDeletedValue() && rhs.isHashTableDelete
kouhei (in TOK)
2017/04/04 05:19:26
Done.
|
| + rhs.m_module.isHashTableDeletedValue()) |
| + return true; |
| + |
|
yhirano
2017/03/30 07:35:09
if (isHashTableDeltedValue() || rhs.isHashTableDel
kouhei (in TOK)
2017/04/04 05:19:26
Done.
|
| + blink::SharedPersistent<v8::Module>* lhsp = m_module.get(); |
| + blink::SharedPersistent<v8::Module>* rhsp = rhs.m_module.get(); |
| + if (lhsp == rhsp) |
|
haraken
2017/03/30 13:20:14
Nit: Blink prefers a fully qualified name.
kouhei (in TOK)
2017/04/04 05:19:26
Done.
|
| + return true; |
| + if (!lhsp || !rhsp) |
| + return false; |
| + return *lhsp == *rhsp; |
| + } |
| + |
| 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 static_cast<unsigned>(key.m_identityHash); |
|
yhirano
2017/03/30 07:35:09
This cast is not needed.
kouhei (in TOK)
2017/04/04 05:19:26
Done.
|
| + } |
| + |
| + 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 |