| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 USING_FAST_MALLOC(V8PerIsolateData); | 52 USING_FAST_MALLOC(V8PerIsolateData); |
| 53 WTF_MAKE_NONCOPYABLE(V8PerIsolateData); | 53 WTF_MAKE_NONCOPYABLE(V8PerIsolateData); |
| 54 public: | 54 public: |
| 55 class EndOfScopeTask { | 55 class EndOfScopeTask { |
| 56 USING_FAST_MALLOC(EndOfScopeTask); | 56 USING_FAST_MALLOC(EndOfScopeTask); |
| 57 public: | 57 public: |
| 58 virtual ~EndOfScopeTask() { } | 58 virtual ~EndOfScopeTask() { } |
| 59 virtual void run() = 0; | 59 virtual void run() = 0; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // Disables the UseCounter. |
| 63 // UseCounter depends on the current context, but it's not available during |
| 64 // the initialization of v8::Context and the global object. So we need to |
| 65 // disable the UseCounter while the initialization of the context and global |
| 66 // object. |
| 67 // TODO(yukishiino): Come up with an idea to remove this hack. |
| 68 class UseCounterDisabledScope { |
| 69 STACK_ALLOCATED(); |
| 70 public: |
| 71 explicit UseCounterDisabledScope(V8PerIsolateData* perIsolateData) |
| 72 : m_perIsolateData(perIsolateData) |
| 73 , m_originalUseCounterDisabled(m_perIsolateData->m_useCounterDisable
d) |
| 74 { |
| 75 m_perIsolateData->m_useCounterDisabled = true; |
| 76 } |
| 77 ~UseCounterDisabledScope() |
| 78 { |
| 79 m_perIsolateData->m_useCounterDisabled = m_originalUseCounterDisable
d; |
| 80 } |
| 81 |
| 82 private: |
| 83 V8PerIsolateData* m_perIsolateData; |
| 84 const bool m_originalUseCounterDisabled; |
| 85 }; |
| 86 |
| 62 static v8::Isolate* initialize(); | 87 static v8::Isolate* initialize(); |
| 63 | 88 |
| 64 static V8PerIsolateData* from(v8::Isolate* isolate) | 89 static V8PerIsolateData* from(v8::Isolate* isolate) |
| 65 { | 90 { |
| 66 ASSERT(isolate); | 91 ASSERT(isolate); |
| 67 ASSERT(isolate->GetData(gin::kEmbedderBlink)); | 92 ASSERT(isolate->GetData(gin::kEmbedderBlink)); |
| 68 return static_cast<V8PerIsolateData*>(isolate->GetData(gin::kEmbedderBli
nk)); | 93 return static_cast<V8PerIsolateData*>(isolate->GetData(gin::kEmbedderBli
nk)); |
| 69 } | 94 } |
| 70 | 95 |
| 71 static void willBeDestroyed(v8::Isolate*); | 96 static void willBeDestroyed(v8::Isolate*); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 void runEndOfScopeTasks(); | 135 void runEndOfScopeTasks(); |
| 111 void clearEndOfScopeTasks(); | 136 void clearEndOfScopeTasks(); |
| 112 | 137 |
| 113 void setThreadDebugger(PassOwnPtr<ThreadDebugger>); | 138 void setThreadDebugger(PassOwnPtr<ThreadDebugger>); |
| 114 ThreadDebugger* threadDebugger(); | 139 ThreadDebugger* threadDebugger(); |
| 115 | 140 |
| 116 private: | 141 private: |
| 117 V8PerIsolateData(); | 142 V8PerIsolateData(); |
| 118 ~V8PerIsolateData(); | 143 ~V8PerIsolateData(); |
| 119 | 144 |
| 145 static void useCounterCallback(v8::Isolate*, v8::Isolate::UseCounterFeature)
; |
| 146 |
| 120 typedef HashMap<const void*, v8::Eternal<v8::FunctionTemplate>> V8FunctionTe
mplateMap; | 147 typedef HashMap<const void*, v8::Eternal<v8::FunctionTemplate>> V8FunctionTe
mplateMap; |
| 121 V8FunctionTemplateMap& selectInterfaceTemplateMap(const DOMWrapperWorld&); | 148 V8FunctionTemplateMap& selectInterfaceTemplateMap(const DOMWrapperWorld&); |
| 122 V8FunctionTemplateMap& selectOperationTemplateMap(const DOMWrapperWorld&); | 149 V8FunctionTemplateMap& selectOperationTemplateMap(const DOMWrapperWorld&); |
| 123 bool hasInstance(const WrapperTypeInfo* untrusted, v8::Local<v8::Value>, V8F
unctionTemplateMap&); | 150 bool hasInstance(const WrapperTypeInfo* untrusted, v8::Local<v8::Value>, V8F
unctionTemplateMap&); |
| 124 v8::Local<v8::Object> findInstanceInPrototypeChain(const WrapperTypeInfo*, v
8::Local<v8::Value>, V8FunctionTemplateMap&); | 151 v8::Local<v8::Object> findInstanceInPrototypeChain(const WrapperTypeInfo*, v
8::Local<v8::Value>, V8FunctionTemplateMap&); |
| 125 | 152 |
| 126 OwnPtr<gin::IsolateHolder> m_isolateHolder; | 153 OwnPtr<gin::IsolateHolder> m_isolateHolder; |
| 127 | 154 |
| 128 // m_interfaceTemplateMapFor{,Non}MainWorld holds function templates for | 155 // m_interfaceTemplateMapFor{,Non}MainWorld holds function templates for |
| 129 // the inerface objects. | 156 // the inerface objects. |
| 130 V8FunctionTemplateMap m_interfaceTemplateMapForMainWorld; | 157 V8FunctionTemplateMap m_interfaceTemplateMapForMainWorld; |
| 131 V8FunctionTemplateMap m_interfaceTemplateMapForNonMainWorld; | 158 V8FunctionTemplateMap m_interfaceTemplateMapForNonMainWorld; |
| 132 // m_operationTemplateMapFor{,Non}MainWorld holds function templates for | 159 // m_operationTemplateMapFor{,Non}MainWorld holds function templates for |
| 133 // the cross-origin accessible DOM operations. | 160 // the cross-origin accessible DOM operations. |
| 134 V8FunctionTemplateMap m_operationTemplateMapForMainWorld; | 161 V8FunctionTemplateMap m_operationTemplateMapForMainWorld; |
| 135 V8FunctionTemplateMap m_operationTemplateMapForNonMainWorld; | 162 V8FunctionTemplateMap m_operationTemplateMapForNonMainWorld; |
| 136 | 163 |
| 137 OwnPtr<StringCache> m_stringCache; | 164 OwnPtr<StringCache> m_stringCache; |
| 138 OwnPtr<V8HiddenValue> m_hiddenValue; | 165 OwnPtr<V8HiddenValue> m_hiddenValue; |
| 139 ScopedPersistent<v8::Value> m_liveRoot; | 166 ScopedPersistent<v8::Value> m_liveRoot; |
| 140 RefPtr<ScriptState> m_scriptRegexpScriptState; | 167 RefPtr<ScriptState> m_scriptRegexpScriptState; |
| 141 | 168 |
| 142 bool m_constructorMode; | 169 bool m_constructorMode; |
| 143 friend class ConstructorMode; | 170 friend class ConstructorMode; |
| 144 | 171 |
| 172 bool m_useCounterDisabled; |
| 173 friend class UseCounterDisabledScope; |
| 174 |
| 145 bool m_isHandlingRecursionLevelError; | 175 bool m_isHandlingRecursionLevelError; |
| 146 bool m_isReportingException; | 176 bool m_isReportingException; |
| 147 | 177 |
| 148 Vector<OwnPtr<EndOfScopeTask>> m_endOfScopeTasks; | 178 Vector<OwnPtr<EndOfScopeTask>> m_endOfScopeTasks; |
| 149 OwnPtr<ThreadDebugger> m_threadDebugger; | 179 OwnPtr<ThreadDebugger> m_threadDebugger; |
| 150 }; | 180 }; |
| 151 | 181 |
| 152 } // namespace blink | 182 } // namespace blink |
| 153 | 183 |
| 154 #endif // V8PerIsolateData_h | 184 #endif // V8PerIsolateData_h |
| OLD | NEW |