| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "bindings/core/v8/ScriptPromiseProperty.h" | 6 #include "bindings/core/v8/ScriptPromiseProperty.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/DOMWrapperWorld.h" | 8 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 9 #include "bindings/core/v8/ScriptFunction.h" | 9 #include "bindings/core/v8/ScriptFunction.h" |
| 10 #include "bindings/core/v8/ScriptPromise.h" | 10 #include "bindings/core/v8/ScriptPromise.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 m_callCount++; | 74 m_callCount++; |
| 75 return ScriptValue(); | 75 return ScriptValue(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 ScriptValue& m_value; | 78 ScriptValue& m_value; |
| 79 size_t& m_callCount; | 79 size_t& m_callCount; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 class GarbageCollectedHolder : public GarbageCollectedScriptWrappable { | 82 class GarbageCollectedHolder : public GarbageCollectedScriptWrappable { |
| 83 public: | 83 public: |
| 84 typedef ScriptPromiseProperty<Member<GarbageCollectedScriptWrappable>, Membe
r<GarbageCollectedScriptWrappable>, Member<GarbageCollectedScriptWrappable> > Pr
operty; | 84 typedef ScriptPromiseProperty<Member<GarbageCollectedScriptWrappable>, Membe
r<GarbageCollectedScriptWrappable>, Member<GarbageCollectedScriptWrappable>> Pro
perty; |
| 85 GarbageCollectedHolder(ExecutionContext* executionContext) | 85 GarbageCollectedHolder(ExecutionContext* executionContext) |
| 86 : GarbageCollectedScriptWrappable("holder") | 86 : GarbageCollectedScriptWrappable("holder") |
| 87 , m_property(new Property(executionContext, toGarbageCollectedScriptWrap
pable(), Property::Ready)) { } | 87 , m_property(new Property(executionContext, toGarbageCollectedScriptWrap
pable(), Property::Ready)) { } |
| 88 | 88 |
| 89 Property* property() { return m_property; } | 89 Property* property() { return m_property; } |
| 90 GarbageCollectedScriptWrappable* toGarbageCollectedScriptWrappable() { retur
n this; } | 90 GarbageCollectedScriptWrappable* toGarbageCollectedScriptWrappable() { retur
n this; } |
| 91 | 91 |
| 92 virtual void trace(Visitor *visitor) override | 92 virtual void trace(Visitor *visitor) override |
| 93 { | 93 { |
| 94 GarbageCollectedScriptWrappable::trace(visitor); | 94 GarbageCollectedScriptWrappable::trace(visitor); |
| 95 visitor->trace(m_property); | 95 visitor->trace(m_property); |
| 96 } | 96 } |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 Member<Property> m_property; | 99 Member<Property> m_property; |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 class RefCountedHolder : public RefCountedScriptWrappable { | 102 class RefCountedHolder : public RefCountedScriptWrappable { |
| 103 public: | 103 public: |
| 104 // Do not resolve or reject the property with the holder itself. It leads | 104 // Do not resolve or reject the property with the holder itself. It leads |
| 105 // to a leak. | 105 // to a leak. |
| 106 typedef ScriptPromiseProperty<RefCountedScriptWrappable*, RefPtr<RefCountedS
criptWrappable>, RefPtr<RefCountedScriptWrappable> > Property; | 106 typedef ScriptPromiseProperty<RefCountedScriptWrappable*, RefPtr<RefCountedS
criptWrappable>, RefPtr<RefCountedScriptWrappable>> Property; |
| 107 static PassRefPtr<RefCountedHolder> create(ExecutionContext* executionContex
t) | 107 static PassRefPtr<RefCountedHolder> create(ExecutionContext* executionContex
t) |
| 108 { | 108 { |
| 109 return adoptRef(new RefCountedHolder(executionContext)); | 109 return adoptRef(new RefCountedHolder(executionContext)); |
| 110 } | 110 } |
| 111 Property* property() { return m_property; } | 111 Property* property() { return m_property; } |
| 112 RefCountedScriptWrappable* toRefCountedScriptWrappable() { return this; } | 112 RefCountedScriptWrappable* toRefCountedScriptWrappable() { return this; } |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 RefCountedHolder(ExecutionContext* executionContext) | 115 RefCountedHolder(ExecutionContext* executionContext) |
| 116 : RefCountedScriptWrappable("holder") | 116 : RefCountedScriptWrappable("holder") |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 { | 545 { |
| 546 test(String("hello"), "hello", __FILE__, __LINE__); | 546 test(String("hello"), "hello", __FILE__, __LINE__); |
| 547 } | 547 } |
| 548 | 548 |
| 549 TEST_F(ScriptPromisePropertyNonScriptWrappableResolutionTargetTest, ResolveWithI
nteger) | 549 TEST_F(ScriptPromisePropertyNonScriptWrappableResolutionTargetTest, ResolveWithI
nteger) |
| 550 { | 550 { |
| 551 test(-1, "-1", __FILE__, __LINE__); | 551 test(-1, "-1", __FILE__, __LINE__); |
| 552 } | 552 } |
| 553 | 553 |
| 554 } // namespace | 554 } // namespace |
| OLD | NEW |