Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "bindings/core/v8/V8PerContextData.h" | 31 #include "bindings/core/v8/V8PerContextData.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ConditionalFeatures.h" | 33 #include "bindings/core/v8/ConditionalFeatures.h" |
| 34 #include "bindings/core/v8/ScriptState.h" | 34 #include "bindings/core/v8/ScriptState.h" |
| 35 #include "bindings/core/v8/V8Binding.h" | 35 #include "bindings/core/v8/V8Binding.h" |
| 36 #include "bindings/core/v8/V8ObjectConstructor.h" | 36 #include "bindings/core/v8/V8ObjectConstructor.h" |
| 37 #include "core/dom/Modulator.h" | |
| 38 #include "platform/InstanceCounters.h" | 37 #include "platform/InstanceCounters.h" |
| 39 #include "wtf/PtrUtil.h" | 38 #include "wtf/PtrUtil.h" |
| 40 #include "wtf/StringExtras.h" | 39 #include "wtf/StringExtras.h" |
| 41 #include <memory> | 40 #include <memory> |
| 42 #include <stdlib.h> | 41 #include <stdlib.h> |
| 43 | 42 |
| 44 namespace blink { | 43 namespace blink { |
| 45 | 44 |
| 46 V8PerContextData::V8PerContextData(v8::Local<v8::Context> context) | 45 V8PerContextData::V8PerContextData(v8::Local<v8::Context> context) |
| 47 : m_isolate(context->GetIsolate()), | 46 : m_isolate(context->GetIsolate()), |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 66 | 65 |
| 67 if (isMainThread()) | 66 if (isMainThread()) |
| 68 InstanceCounters::incrementCounter( | 67 InstanceCounters::incrementCounter( |
| 69 InstanceCounters::V8PerContextDataCounter); | 68 InstanceCounters::V8PerContextDataCounter); |
| 70 } | 69 } |
| 71 | 70 |
| 72 V8PerContextData::~V8PerContextData() { | 71 V8PerContextData::~V8PerContextData() { |
| 73 if (isMainThread()) | 72 if (isMainThread()) |
| 74 InstanceCounters::decrementCounter( | 73 InstanceCounters::decrementCounter( |
| 75 InstanceCounters::V8PerContextDataCounter); | 74 InstanceCounters::V8PerContextDataCounter); |
| 75 m_dataMap.clear(); | |
|
haraken
2017/04/05 02:08:09
Is this needed?
jbroman
2017/04/05 21:07:00
+1; the destructor should suffice
adithyas
2017/04/05 21:45:35
Ok, removed.
| |
| 76 } | 76 } |
| 77 | 77 |
| 78 std::unique_ptr<V8PerContextData> V8PerContextData::create( | 78 std::unique_ptr<V8PerContextData> V8PerContextData::create( |
| 79 v8::Local<v8::Context> context) { | 79 v8::Local<v8::Context> context) { |
| 80 return WTF::wrapUnique(new V8PerContextData(context)); | 80 return WTF::wrapUnique(new V8PerContextData(context)); |
| 81 } | 81 } |
| 82 | 82 |
| 83 V8PerContextData* V8PerContextData::from(v8::Local<v8::Context> context) { | 83 V8PerContextData* V8PerContextData::from(v8::Local<v8::Context> context) { |
| 84 return ScriptState::from(context)->perContextData(); | 84 return ScriptState::from(context)->perContextData(); |
| 85 } | 85 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 *prototypeObject = prototypeForType(type); | 182 *prototypeObject = prototypeForType(type); |
| 183 DCHECK(!prototypeObject->IsEmpty()); | 183 DCHECK(!prototypeObject->IsEmpty()); |
| 184 return true; | 184 return true; |
| 185 } | 185 } |
| 186 | 186 |
| 187 void V8PerContextData::addCustomElementBinding( | 187 void V8PerContextData::addCustomElementBinding( |
| 188 std::unique_ptr<V0CustomElementBinding> binding) { | 188 std::unique_ptr<V0CustomElementBinding> binding) { |
| 189 m_customElementBindings.push_back(std::move(binding)); | 189 m_customElementBindings.push_back(std::move(binding)); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void V8PerContextData::setModulator(Modulator* modulator) { | 192 void V8PerContextData::addData(const char* key, Data* data) { |
| 193 DCHECK(!m_modulator); | 193 m_dataMap.set(key, data); |
| 194 DCHECK(modulator); | |
| 195 m_modulator = modulator; | |
| 196 } | 194 } |
| 197 | 195 |
| 198 void V8PerContextData::clearModulator() { | 196 void V8PerContextData::clearData(const char* key) { |
| 199 m_modulator = nullptr; | 197 m_dataMap.erase(key); |
| 198 } | |
| 199 | |
| 200 V8PerContextData::Data* V8PerContextData::getData(const char* key) { | |
| 201 return m_dataMap.at(key); | |
| 200 } | 202 } |
| 201 | 203 |
| 202 } // namespace blink | 204 } // namespace blink |
| OLD | NEW |