OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "bindings/v8/V8PerIsolateData.h" | 27 #include "bindings/v8/V8PerIsolateData.h" |
28 | 28 |
29 #include "bindings/v8/DOMDataStore.h" | 29 #include "bindings/v8/DOMDataStore.h" |
30 #include "bindings/v8/ScriptGCEvent.h" | 30 #include "bindings/v8/ScriptGCEvent.h" |
31 #include "bindings/v8/ScriptProfiler.h" | 31 #include "bindings/v8/ScriptProfiler.h" |
32 #include "bindings/v8/V8Binding.h" | 32 #include "bindings/v8/V8Binding.h" |
33 #include "bindings/v8/V8HiddenValue.h" | 33 #include "bindings/v8/V8HiddenValue.h" |
34 #include "bindings/v8/V8ObjectConstructor.h" | 34 #include "bindings/v8/V8ObjectConstructor.h" |
35 #include "bindings/v8/V8PerContextData.h" | 35 #include "bindings/v8/V8PerContextData.h" |
36 #include "bindings/v8/V8ScriptRunner.h" | 36 #include "bindings/v8/V8ScriptRunner.h" |
| 37 #include "wtf/LeakAnnotations.h" |
37 #include "wtf/MainThread.h" | 38 #include "wtf/MainThread.h" |
38 | 39 |
39 namespace WebCore { | 40 namespace WebCore { |
40 | 41 |
41 static V8PerIsolateData* mainThreadPerIsolateData = 0; | 42 static V8PerIsolateData* mainThreadPerIsolateData = 0; |
42 | 43 |
43 V8PerIsolateData::V8PerIsolateData(v8::Isolate* isolate) | 44 V8PerIsolateData::V8PerIsolateData(v8::Isolate* isolate) |
44 : m_isolate(isolate) | 45 : m_isolate(isolate) |
45 , m_isolateHolder(adoptPtr(new gin::IsolateHolder(m_isolate, v8ArrayBufferAl
locator()))) | 46 , m_isolateHolder(adoptPtr(new gin::IsolateHolder(m_isolate, v8ArrayBufferAl
locator()))) |
46 , m_stringCache(adoptPtr(new StringCache())) | 47 , m_stringCache(adoptPtr(new StringCache())) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 if (result != domTemplateMap.end()) | 120 if (result != domTemplateMap.end()) |
120 return result->value.Get(m_isolate); | 121 return result->value.Get(m_isolate); |
121 return v8::Local<v8::FunctionTemplate>(); | 122 return v8::Local<v8::FunctionTemplate>(); |
122 } | 123 } |
123 | 124 |
124 void V8PerIsolateData::setDOMTemplate(void* domTemplateKey, v8::Handle<v8::Funct
ionTemplate> templ) | 125 void V8PerIsolateData::setDOMTemplate(void* domTemplateKey, v8::Handle<v8::Funct
ionTemplate> templ) |
125 { | 126 { |
126 currentDOMTemplateMap().add(domTemplateKey, v8::Eternal<v8::FunctionTemplate
>(m_isolate, v8::Local<v8::FunctionTemplate>(templ))); | 127 currentDOMTemplateMap().add(domTemplateKey, v8::Eternal<v8::FunctionTemplate
>(m_isolate, v8::Local<v8::FunctionTemplate>(templ))); |
127 } | 128 } |
128 | 129 |
129 v8::Local<v8::Context> V8PerIsolateData::ensureRegexContext() | 130 v8::Local<v8::Context> V8PerIsolateData::ensureDomInJSContext() |
130 { | 131 { |
131 if (!m_perContextDataForRegex) | 132 if (!m_domInJSPerContextData) { |
132 m_perContextDataForRegex = V8PerContextData::create(v8::Context::New(m_i
solate), DOMWrapperWorld::create()); | 133 m_domInJSPerContextData = V8PerContextData::create(v8::Context::New(m_is
olate), DOMWrapperWorld::create()); |
133 return m_perContextDataForRegex->context(); | 134 // The V8PerContextData is collected via a weak reference callback from
the V8Context, which is expected to not always shutdown cleanly. |
| 135 WTF_ANNOTATE_LEAKING_OBJECT_PTR(m_domInJSPerContextData.get()); |
| 136 } |
| 137 return m_domInJSPerContextData->context(); |
134 } | 138 } |
135 | 139 |
136 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V
alue> value) | 140 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V
alue> value) |
137 { | 141 { |
138 return hasInstance(info, value, m_domTemplateMapForMainWorld) | 142 return hasInstance(info, value, m_domTemplateMapForMainWorld) |
139 || hasInstance(info, value, m_domTemplateMapForNonMainWorld); | 143 || hasInstance(info, value, m_domTemplateMapForNonMainWorld); |
140 } | 144 } |
141 | 145 |
142 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V
alue> value, DOMTemplateMap& domTemplateMap) | 146 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V
alue> value, DOMTemplateMap& domTemplateMap) |
143 { | 147 { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 190 } |
187 | 191 |
188 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate() | 192 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate() |
189 { | 193 { |
190 if (m_toStringTemplate.isEmpty()) | 194 if (m_toStringTemplate.isEmpty()) |
191 m_toStringTemplate.set(m_isolate, v8::FunctionTemplate::New(m_isolate, c
onstructorOfToString)); | 195 m_toStringTemplate.set(m_isolate, v8::FunctionTemplate::New(m_isolate, c
onstructorOfToString)); |
192 return m_toStringTemplate.newLocal(m_isolate); | 196 return m_toStringTemplate.newLocal(m_isolate); |
193 } | 197 } |
194 | 198 |
195 } // namespace WebCore | 199 } // namespace WebCore |
OLD | NEW |