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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // currentThread will always be non-null in production, but can be null in C
hromium unit tests. | 79 // currentThread will always be non-null in production, but can be null in C
hromium unit tests. |
80 isolate()->AddCallCompletedCallback(&assertV8RecursionScope); | 80 isolate()->AddCallCompletedCallback(&assertV8RecursionScope); |
81 #endif | 81 #endif |
82 if (isMainThread()) | 82 if (isMainThread()) |
83 mainThreadPerIsolateData = this; | 83 mainThreadPerIsolateData = this; |
84 isolate()->SetUseCounterCallback(&useCounterCallback); | 84 isolate()->SetUseCounterCallback(&useCounterCallback); |
85 } | 85 } |
86 | 86 |
87 V8PerIsolateData::~V8PerIsolateData() | 87 V8PerIsolateData::~V8PerIsolateData() |
88 { | 88 { |
| 89 if (m_scriptRegexpScriptState) |
| 90 m_scriptRegexpScriptState->disposePerContextData(); |
89 if (isMainThread()) | 91 if (isMainThread()) |
90 mainThreadPerIsolateData = 0; | 92 mainThreadPerIsolateData = 0; |
91 } | 93 } |
92 | 94 |
93 v8::Isolate* V8PerIsolateData::mainThreadIsolate() | 95 v8::Isolate* V8PerIsolateData::mainThreadIsolate() |
94 { | 96 { |
95 ASSERT(isMainThread()); | 97 ASSERT(isMainThread()); |
96 ASSERT(mainThreadPerIsolateData); | 98 ASSERT(mainThreadPerIsolateData); |
97 return mainThreadPerIsolateData->isolate(); | 99 return mainThreadPerIsolateData->isolate(); |
98 } | 100 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 if (result != domTemplateMap.end()) | 151 if (result != domTemplateMap.end()) |
150 return result->value.Get(isolate()); | 152 return result->value.Get(isolate()); |
151 return v8::Local<v8::FunctionTemplate>(); | 153 return v8::Local<v8::FunctionTemplate>(); |
152 } | 154 } |
153 | 155 |
154 void V8PerIsolateData::setDOMTemplate(void* domTemplateKey, v8::Handle<v8::Funct
ionTemplate> templ) | 156 void V8PerIsolateData::setDOMTemplate(void* domTemplateKey, v8::Handle<v8::Funct
ionTemplate> templ) |
155 { | 157 { |
156 currentDOMTemplateMap().add(domTemplateKey, v8::Eternal<v8::FunctionTemplate
>(isolate(), v8::Local<v8::FunctionTemplate>(templ))); | 158 currentDOMTemplateMap().add(domTemplateKey, v8::Eternal<v8::FunctionTemplate
>(isolate(), v8::Local<v8::FunctionTemplate>(templ))); |
157 } | 159 } |
158 | 160 |
| 161 v8::Local<v8::Context> V8PerIsolateData::ensureScriptRegexpContext() |
| 162 { |
| 163 if (!m_scriptRegexpScriptState) { |
| 164 v8::Local<v8::Context> context(v8::Context::New(isolate())); |
| 165 m_scriptRegexpScriptState = ScriptState::create(context, DOMWrapperWorld
::create()); |
| 166 } |
| 167 return m_scriptRegexpScriptState->context(); |
| 168 } |
| 169 |
159 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V
alue> value) | 170 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V
alue> value) |
160 { | 171 { |
161 return hasInstance(info, value, m_domTemplateMapForMainWorld) | 172 return hasInstance(info, value, m_domTemplateMapForMainWorld) |
162 || hasInstance(info, value, m_domTemplateMapForNonMainWorld); | 173 || hasInstance(info, value, m_domTemplateMapForNonMainWorld); |
163 } | 174 } |
164 | 175 |
165 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V
alue> value, DOMTemplateMap& domTemplateMap) | 176 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V
alue> value, DOMTemplateMap& domTemplateMap) |
166 { | 177 { |
167 DOMTemplateMap::iterator result = domTemplateMap.find(info); | 178 DOMTemplateMap::iterator result = domTemplateMap.find(info); |
168 if (result == domTemplateMap.end()) | 179 if (result == domTemplateMap.end()) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 } | 220 } |
210 | 221 |
211 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate() | 222 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate() |
212 { | 223 { |
213 if (m_toStringTemplate.isEmpty()) | 224 if (m_toStringTemplate.isEmpty()) |
214 m_toStringTemplate.set(isolate(), v8::FunctionTemplate::New(isolate(), c
onstructorOfToString)); | 225 m_toStringTemplate.set(isolate(), v8::FunctionTemplate::New(isolate(), c
onstructorOfToString)); |
215 return m_toStringTemplate.newLocal(isolate()); | 226 return m_toStringTemplate.newLocal(isolate()); |
216 } | 227 } |
217 | 228 |
218 } // namespace blink | 229 } // namespace blink |
OLD | NEW |