Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.h

Issue 1858613002: bindings: Makes the window object be the inner global object. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 class UseCounterDisabledScope {
68 STACK_ALLOCATED();
69 public:
70 explicit UseCounterDisabledScope(V8PerIsolateData* perIsolateData)
71 : m_perIsolateData(perIsolateData)
72 , m_originalUseCounterDisabled(m_perIsolateData->m_useCounterDisable d)
73 {
74 m_perIsolateData->m_useCounterDisabled = true;
75 }
76 ~UseCounterDisabledScope()
77 {
78 m_perIsolateData->m_useCounterDisabled = m_originalUseCounterDisable d;
79 }
80
81 private:
82 V8PerIsolateData* m_perIsolateData;
83 const bool m_originalUseCounterDisabled;
84 };
85
62 static v8::Isolate* initialize(); 86 static v8::Isolate* initialize();
63 87
64 static V8PerIsolateData* from(v8::Isolate* isolate) 88 static V8PerIsolateData* from(v8::Isolate* isolate)
65 { 89 {
66 ASSERT(isolate); 90 ASSERT(isolate);
67 ASSERT(isolate->GetData(gin::kEmbedderBlink)); 91 ASSERT(isolate->GetData(gin::kEmbedderBlink));
68 return static_cast<V8PerIsolateData*>(isolate->GetData(gin::kEmbedderBli nk)); 92 return static_cast<V8PerIsolateData*>(isolate->GetData(gin::kEmbedderBli nk));
69 } 93 }
70 94
71 static void willBeDestroyed(v8::Isolate*); 95 static void willBeDestroyed(v8::Isolate*);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 void runEndOfScopeTasks(); 134 void runEndOfScopeTasks();
111 void clearEndOfScopeTasks(); 135 void clearEndOfScopeTasks();
112 136
113 void setThreadDebugger(PassOwnPtr<ThreadDebugger>); 137 void setThreadDebugger(PassOwnPtr<ThreadDebugger>);
114 ThreadDebugger* threadDebugger(); 138 ThreadDebugger* threadDebugger();
115 139
116 private: 140 private:
117 V8PerIsolateData(); 141 V8PerIsolateData();
118 ~V8PerIsolateData(); 142 ~V8PerIsolateData();
119 143
144 static void useCounterCallback(v8::Isolate*, v8::Isolate::UseCounterFeature) ;
145
120 typedef HashMap<const void*, v8::Eternal<v8::FunctionTemplate>> V8FunctionTe mplateMap; 146 typedef HashMap<const void*, v8::Eternal<v8::FunctionTemplate>> V8FunctionTe mplateMap;
121 V8FunctionTemplateMap& selectInterfaceTemplateMap(const DOMWrapperWorld&); 147 V8FunctionTemplateMap& selectInterfaceTemplateMap(const DOMWrapperWorld&);
122 V8FunctionTemplateMap& selectOperationTemplateMap(const DOMWrapperWorld&); 148 V8FunctionTemplateMap& selectOperationTemplateMap(const DOMWrapperWorld&);
123 bool hasInstance(const WrapperTypeInfo* untrusted, v8::Local<v8::Value>, V8F unctionTemplateMap&); 149 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&); 150 v8::Local<v8::Object> findInstanceInPrototypeChain(const WrapperTypeInfo*, v 8::Local<v8::Value>, V8FunctionTemplateMap&);
125 151
126 OwnPtr<gin::IsolateHolder> m_isolateHolder; 152 OwnPtr<gin::IsolateHolder> m_isolateHolder;
127 153
128 // m_interfaceTemplateMapFor{,Non}MainWorld holds function templates for 154 // m_interfaceTemplateMapFor{,Non}MainWorld holds function templates for
129 // the inerface objects. 155 // the inerface objects.
130 V8FunctionTemplateMap m_interfaceTemplateMapForMainWorld; 156 V8FunctionTemplateMap m_interfaceTemplateMapForMainWorld;
131 V8FunctionTemplateMap m_interfaceTemplateMapForNonMainWorld; 157 V8FunctionTemplateMap m_interfaceTemplateMapForNonMainWorld;
132 // m_operationTemplateMapFor{,Non}MainWorld holds function templates for 158 // m_operationTemplateMapFor{,Non}MainWorld holds function templates for
133 // the cross-origin accessible DOM operations. 159 // the cross-origin accessible DOM operations.
134 V8FunctionTemplateMap m_operationTemplateMapForMainWorld; 160 V8FunctionTemplateMap m_operationTemplateMapForMainWorld;
135 V8FunctionTemplateMap m_operationTemplateMapForNonMainWorld; 161 V8FunctionTemplateMap m_operationTemplateMapForNonMainWorld;
136 162
137 OwnPtr<StringCache> m_stringCache; 163 OwnPtr<StringCache> m_stringCache;
138 OwnPtr<V8HiddenValue> m_hiddenValue; 164 OwnPtr<V8HiddenValue> m_hiddenValue;
139 ScopedPersistent<v8::Value> m_liveRoot; 165 ScopedPersistent<v8::Value> m_liveRoot;
140 RefPtr<ScriptState> m_scriptRegexpScriptState; 166 RefPtr<ScriptState> m_scriptRegexpScriptState;
141 167
142 bool m_constructorMode; 168 bool m_constructorMode;
143 friend class ConstructorMode; 169 friend class ConstructorMode;
144 170
171 bool m_useCounterDisabled;
172 friend class UseCounterDisabledScope;
173
145 bool m_isHandlingRecursionLevelError; 174 bool m_isHandlingRecursionLevelError;
146 bool m_isReportingException; 175 bool m_isReportingException;
147 176
148 Vector<OwnPtr<EndOfScopeTask>> m_endOfScopeTasks; 177 Vector<OwnPtr<EndOfScopeTask>> m_endOfScopeTasks;
149 OwnPtr<ThreadDebugger> m_threadDebugger; 178 OwnPtr<ThreadDebugger> m_threadDebugger;
150 }; 179 };
151 180
152 } // namespace blink 181 } // namespace blink
153 182
154 #endif // V8PerIsolateData_h 183 #endif // V8PerIsolateData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698