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" | |
38 #include "wtf/MainThread.h" | 37 #include "wtf/MainThread.h" |
39 | 38 |
40 namespace WebCore { | 39 namespace WebCore { |
41 | 40 |
42 static V8PerIsolateData* mainThreadPerIsolateData = 0; | 41 static V8PerIsolateData* mainThreadPerIsolateData = 0; |
43 | 42 |
44 V8PerIsolateData::V8PerIsolateData(v8::Isolate* isolate) | 43 V8PerIsolateData::V8PerIsolateData(v8::Isolate* isolate) |
45 : m_isolate(isolate) | 44 : m_isolate(isolate) |
46 , m_isolateHolder(adoptPtr(new gin::IsolateHolder(m_isolate, v8ArrayBufferAl
locator()))) | 45 , m_isolateHolder(adoptPtr(new gin::IsolateHolder(m_isolate, v8ArrayBufferAl
locator()))) |
47 , m_stringCache(adoptPtr(new StringCache())) | 46 , m_stringCache(adoptPtr(new StringCache())) |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return v8::Local<v8::FunctionTemplate>(); | 121 return v8::Local<v8::FunctionTemplate>(); |
123 } | 122 } |
124 | 123 |
125 void V8PerIsolateData::setDOMTemplate(void* domTemplateKey, v8::Handle<v8::Funct
ionTemplate> templ) | 124 void V8PerIsolateData::setDOMTemplate(void* domTemplateKey, v8::Handle<v8::Funct
ionTemplate> templ) |
126 { | 125 { |
127 currentDOMTemplateMap().add(domTemplateKey, v8::Eternal<v8::FunctionTemplate
>(m_isolate, v8::Local<v8::FunctionTemplate>(templ))); | 126 currentDOMTemplateMap().add(domTemplateKey, v8::Eternal<v8::FunctionTemplate
>(m_isolate, v8::Local<v8::FunctionTemplate>(templ))); |
128 } | 127 } |
129 | 128 |
130 v8::Local<v8::Context> V8PerIsolateData::ensureDomInJSContext() | 129 v8::Local<v8::Context> V8PerIsolateData::ensureDomInJSContext() |
131 { | 130 { |
132 if (!m_domInJSPerContextData) { | 131 if (!m_domInJSPerContextData) |
133 m_domInJSPerContextData = V8PerContextData::create(v8::Context::New(m_is
olate), DOMWrapperWorld::create()); | 132 m_domInJSPerContextData = V8PerContextData::create(v8::Context::New(m_is
olate), DOMWrapperWorld::create()); |
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(); | 133 return m_domInJSPerContextData->context(); |
138 } | 134 } |
139 | 135 |
140 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V
alue> value) | 136 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V
alue> value) |
141 { | 137 { |
142 return hasInstance(info, value, m_domTemplateMapForMainWorld) | 138 return hasInstance(info, value, m_domTemplateMapForMainWorld) |
143 || hasInstance(info, value, m_domTemplateMapForNonMainWorld); | 139 || hasInstance(info, value, m_domTemplateMapForNonMainWorld); |
144 } | 140 } |
145 | 141 |
146 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V
alue> value, DOMTemplateMap& domTemplateMap) | 142 bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::V
alue> value, DOMTemplateMap& domTemplateMap) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 186 } |
191 | 187 |
192 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate() | 188 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate() |
193 { | 189 { |
194 if (m_toStringTemplate.isEmpty()) | 190 if (m_toStringTemplate.isEmpty()) |
195 m_toStringTemplate.set(m_isolate, v8::FunctionTemplate::New(m_isolate, c
onstructorOfToString)); | 191 m_toStringTemplate.set(m_isolate, v8::FunctionTemplate::New(m_isolate, c
onstructorOfToString)); |
196 return m_toStringTemplate.newLocal(m_isolate); | 192 return m_toStringTemplate.newLocal(m_isolate); |
197 } | 193 } |
198 | 194 |
199 } // namespace WebCore | 195 } // namespace WebCore |
OLD | NEW |