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

Side by Side Diff: Source/bindings/tests/results/V8TestSerializedScriptValueInterface.cpp

Issue 94833002: Remove usage of deprecated V8 APIs from bindings code generator (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 static void readonlyValueAttributeGetterCallback(v8::Local<v8::String>, const v8 ::PropertyCallbackInfo<v8::Value>& info) 111 static void readonlyValueAttributeGetterCallback(v8::Local<v8::String>, const v8 ::PropertyCallbackInfo<v8::Value>& info)
112 { 112 {
113 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 113 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
114 TestSerializedScriptValueInterfaceV8Internal::readonlyValueAttributeGetter(i nfo); 114 TestSerializedScriptValueInterfaceV8Internal::readonlyValueAttributeGetter(i nfo);
115 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 115 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
116 } 116 }
117 117
118 static void dirtySerializedValueAttributeGetter(const v8::PropertyCallbackInfo<v 8::Value>& info) 118 static void dirtySerializedValueAttributeGetter(const v8::PropertyCallbackInfo<v 8::Value>& info)
119 { 119 {
120 v8::Handle<v8::String> propertyName = v8::String::NewSymbol("dirtySerialized Value"); 120 v8::Handle<v8::String> propertyName = v8::String::NewFromUtf8(info.GetIsolat e(), "dirtySerializedValue", v8::String::kInternalizedString);
121 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder()); 121 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder());
122 if (!imp->isValueDirty()) { 122 if (!imp->isValueDirty()) {
123 v8::Handle<v8::Value> jsValue = info.Holder()->GetHiddenValue(propertyNa me); 123 v8::Handle<v8::Value> jsValue = info.Holder()->GetHiddenValue(propertyNa me);
124 if (!jsValue.IsEmpty()) { 124 if (!jsValue.IsEmpty()) {
125 v8SetReturnValue(info, jsValue); 125 v8SetReturnValue(info, jsValue);
126 return; 126 return;
127 } 127 }
128 } 128 }
129 RefPtr<SerializedScriptValue> serialized = imp->dirtySerializedValue(); 129 RefPtr<SerializedScriptValue> serialized = imp->dirtySerializedValue();
130 ScriptValue jsValue = serialized ? serialized->deserialize() : v8::Handle<v8 ::Value>(v8::Null(info.GetIsolate())); 130 ScriptValue jsValue = serialized ? serialized->deserialize() : v8::Handle<v8 ::Value>(v8::Null(info.GetIsolate()));
131 info.Holder()->SetHiddenValue(propertyName, jsValue); 131 info.Holder()->SetHiddenValue(propertyName, jsValue);
132 v8SetReturnValue(info, jsValue); 132 v8SetReturnValue(info, jsValue);
133 } 133 }
134 134
135 static void dirtySerializedValueAttributeGetterCallback(v8::Local<v8::String>, c onst v8::PropertyCallbackInfo<v8::Value>& info) 135 static void dirtySerializedValueAttributeGetterCallback(v8::Local<v8::String>, c onst v8::PropertyCallbackInfo<v8::Value>& info)
136 { 136 {
137 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 137 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
138 TestSerializedScriptValueInterfaceV8Internal::dirtySerializedValueAttributeG etter(info); 138 TestSerializedScriptValueInterfaceV8Internal::dirtySerializedValueAttributeG etter(info);
139 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 139 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
140 } 140 }
141 141
142 static void dirtySerializedValueAttributeSetter(v8::Local<v8::Value> jsValue, co nst v8::PropertyCallbackInfo<void>& info) 142 static void dirtySerializedValueAttributeSetter(v8::Local<v8::Value> jsValue, co nst v8::PropertyCallbackInfo<void>& info)
143 { 143 {
144 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder()); 144 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder());
145 V8TRYCATCH_VOID(RefPtr<SerializedScriptValue>, cppValue, SerializedScriptVal ue::create(jsValue, info.GetIsolate())); 145 V8TRYCATCH_VOID(RefPtr<SerializedScriptValue>, cppValue, SerializedScriptVal ue::create(jsValue, info.GetIsolate()));
146 imp->setDirtySerializedValue(WTF::getPtr(cppValue)); 146 imp->setDirtySerializedValue(WTF::getPtr(cppValue));
147 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("dirtySerializedValue ")); // Invalidate the cached value. 147 info.Holder()->DeleteHiddenValue(v8::String::NewFromUtf8(info.GetIsolate(), "dirtySerializedValue", v8::String::kInternalizedString)); // Invalidate the cac hed value.
148 } 148 }
149 149
150 static void dirtySerializedValueAttributeSetterCallback(v8::Local<v8::String>, v 8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 150 static void dirtySerializedValueAttributeSetterCallback(v8::Local<v8::String>, v 8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
151 { 151 {
152 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 152 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
153 TestSerializedScriptValueInterfaceV8Internal::dirtySerializedValueAttributeS etter(jsValue, info); 153 TestSerializedScriptValueInterfaceV8Internal::dirtySerializedValueAttributeS etter(jsValue, info);
154 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 154 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
155 } 155 }
156 156
157 static void dirtyScriptValueAttributeGetter(const v8::PropertyCallbackInfo<v8::V alue>& info) 157 static void dirtyScriptValueAttributeGetter(const v8::PropertyCallbackInfo<v8::V alue>& info)
158 { 158 {
159 v8::Handle<v8::String> propertyName = v8::String::NewSymbol("dirtyScriptValu e"); 159 v8::Handle<v8::String> propertyName = v8::String::NewFromUtf8(info.GetIsolat e(), "dirtyScriptValue", v8::String::kInternalizedString);
160 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder()); 160 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder());
161 if (!imp->isValueDirty()) { 161 if (!imp->isValueDirty()) {
162 v8::Handle<v8::Value> jsValue = info.Holder()->GetHiddenValue(propertyNa me); 162 v8::Handle<v8::Value> jsValue = info.Holder()->GetHiddenValue(propertyNa me);
163 if (!jsValue.IsEmpty()) { 163 if (!jsValue.IsEmpty()) {
164 v8SetReturnValue(info, jsValue); 164 v8SetReturnValue(info, jsValue);
165 return; 165 return;
166 } 166 }
167 } 167 }
168 ScriptValue jsValue = imp->dirtyScriptValue(); 168 ScriptValue jsValue = imp->dirtyScriptValue();
169 info.Holder()->SetHiddenValue(propertyName, jsValue.v8Value()); 169 info.Holder()->SetHiddenValue(propertyName, jsValue.v8Value());
170 v8SetReturnValue(info, jsValue.v8Value()); 170 v8SetReturnValue(info, jsValue.v8Value());
171 } 171 }
172 172
173 static void dirtyScriptValueAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 173 static void dirtyScriptValueAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
174 { 174 {
175 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 175 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
176 TestSerializedScriptValueInterfaceV8Internal::dirtyScriptValueAttributeGette r(info); 176 TestSerializedScriptValueInterfaceV8Internal::dirtyScriptValueAttributeGette r(info);
177 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 177 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
178 } 178 }
179 179
180 static void dirtyScriptValueAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 180 static void dirtyScriptValueAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
181 { 181 {
182 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder()); 182 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder());
183 V8TRYCATCH_VOID(ScriptValue, cppValue, ScriptValue(jsValue, info.GetIsolate( ))); 183 V8TRYCATCH_VOID(ScriptValue, cppValue, ScriptValue(jsValue, info.GetIsolate( )));
184 imp->setDirtyScriptValue(cppValue); 184 imp->setDirtyScriptValue(cppValue);
185 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("dirtyScriptValue")); // Invalidate the cached value. 185 info.Holder()->DeleteHiddenValue(v8::String::NewFromUtf8(info.GetIsolate(), "dirtyScriptValue", v8::String::kInternalizedString)); // Invalidate the cached value.
186 } 186 }
187 187
188 static void dirtyScriptValueAttributeSetterCallback(v8::Local<v8::String>, v8::L ocal<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 188 static void dirtyScriptValueAttributeSetterCallback(v8::Local<v8::String>, v8::L ocal<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
189 { 189 {
190 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 190 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
191 TestSerializedScriptValueInterfaceV8Internal::dirtyScriptValueAttributeSette r(jsValue, info); 191 TestSerializedScriptValueInterfaceV8Internal::dirtyScriptValueAttributeSette r(jsValue, info);
192 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 192 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
193 } 193 }
194 194
195 static void cachedValueCallWithAttributeGetter(const v8::PropertyCallbackInfo<v8 ::Value>& info) 195 static void cachedValueCallWithAttributeGetter(const v8::PropertyCallbackInfo<v8 ::Value>& info)
196 { 196 {
197 v8::Handle<v8::String> propertyName = v8::String::NewSymbol("cachedValueCall With"); 197 v8::Handle<v8::String> propertyName = v8::String::NewFromUtf8(info.GetIsolat e(), "cachedValueCallWith", v8::String::kInternalizedString);
198 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder()); 198 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder());
199 if (!imp->isValueDirty()) { 199 if (!imp->isValueDirty()) {
200 v8::Handle<v8::Value> jsValue = info.Holder()->GetHiddenValue(propertyNa me); 200 v8::Handle<v8::Value> jsValue = info.Holder()->GetHiddenValue(propertyNa me);
201 if (!jsValue.IsEmpty()) { 201 if (!jsValue.IsEmpty()) {
202 v8SetReturnValue(info, jsValue); 202 v8SetReturnValue(info, jsValue);
203 return; 203 return;
204 } 204 }
205 } 205 }
206 ScriptState* currentState = ScriptState::current(); 206 ScriptState* currentState = ScriptState::current();
207 if (!currentState) 207 if (!currentState)
(...skipping 16 matching lines...) Expand all
224 { 224 {
225 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder()); 225 TestSerializedScriptValueInterface* imp = V8TestSerializedScriptValueInterfa ce::toNative(info.Holder());
226 V8TRYCATCH_VOID(RefPtr<SerializedScriptValue>, cppValue, SerializedScriptVal ue::create(jsValue, info.GetIsolate())); 226 V8TRYCATCH_VOID(RefPtr<SerializedScriptValue>, cppValue, SerializedScriptVal ue::create(jsValue, info.GetIsolate()));
227 ScriptState* currentState = ScriptState::current(); 227 ScriptState* currentState = ScriptState::current();
228 if (!currentState) 228 if (!currentState)
229 return; 229 return;
230 ScriptState& state = *currentState; 230 ScriptState& state = *currentState;
231 imp->setCachedValueCallWith(&state, WTF::getPtr(cppValue)); 231 imp->setCachedValueCallWith(&state, WTF::getPtr(cppValue));
232 if (state.hadException()) 232 if (state.hadException())
233 throwError(state.exception(), info.GetIsolate()); 233 throwError(state.exception(), info.GetIsolate());
234 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("cachedValueCallWith" )); // Invalidate the cached value. 234 info.Holder()->DeleteHiddenValue(v8::String::NewFromUtf8(info.GetIsolate(), "cachedValueCallWith", v8::String::kInternalizedString)); // Invalidate the cach ed value.
235 } 235 }
236 236
237 static void cachedValueCallWithAttributeSetterCallback(v8::Local<v8::String>, v8 ::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 237 static void cachedValueCallWithAttributeSetterCallback(v8::Local<v8::String>, v8 ::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
238 { 238 {
239 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 239 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
240 TestSerializedScriptValueInterfaceV8Internal::cachedValueCallWithAttributeSe tter(jsValue, info); 240 TestSerializedScriptValueInterfaceV8Internal::cachedValueCallWithAttributeSe tter(jsValue, info);
241 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 241 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
242 } 242 }
243 243
244 } // namespace TestSerializedScriptValueInterfaceV8Internal 244 } // namespace TestSerializedScriptValueInterfaceV8Internal
(...skipping 16 matching lines...) Expand all
261 0, 0, 261 0, 0,
262 0, 0, 262 0, 0,
263 isolate, currentWorldType); 263 isolate, currentWorldType);
264 UNUSED_PARAM(defaultSignature); 264 UNUSED_PARAM(defaultSignature);
265 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT emplate(); 265 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT emplate();
266 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp eTemplate(); 266 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp eTemplate();
267 UNUSED_PARAM(instanceTemplate); 267 UNUSED_PARAM(instanceTemplate);
268 UNUSED_PARAM(prototypeTemplate); 268 UNUSED_PARAM(prototypeTemplate);
269 269
270 // Custom toString template 270 // Custom toString template
271 functionTemplate->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::c urrent()->toStringTemplate()); 271 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate());
272 return functionTemplate; 272 return functionTemplate;
273 } 273 }
274 274
275 v8::Handle<v8::FunctionTemplate> V8TestSerializedScriptValueInterface::GetTempla te(v8::Isolate* isolate, WrapperWorldType currentWorldType) 275 v8::Handle<v8::FunctionTemplate> V8TestSerializedScriptValueInterface::GetTempla te(v8::Isolate* isolate, WrapperWorldType currentWorldType)
276 { 276 {
277 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 277 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
278 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&wrapperTypeInfo); 278 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&wrapperTypeInfo);
279 if (result != data->templateMap(currentWorldType).end()) 279 if (result != data->templateMap(currentWorldType).end())
280 return result->value.newLocal(isolate); 280 return result->value.newLocal(isolate);
281 281
282 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); 282 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
283 v8::HandleScope handleScope(isolate); 283 v8::EscapableHandleScope handleScope(isolate);
284 v8::Handle<v8::FunctionTemplate> templ = 284 v8::Local<v8::FunctionTemplate> templ =
285 ConfigureV8TestSerializedScriptValueInterfaceTemplate(data->rawTemplate( &wrapperTypeInfo, currentWorldType), isolate, currentWorldType); 285 ConfigureV8TestSerializedScriptValueInterfaceTemplate(data->rawTemplate( &wrapperTypeInfo, currentWorldType), isolate, currentWorldType);
286 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ)); 286 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ));
287 return handleScope.Close(templ); 287 return handleScope.Escape(templ);
288 } 288 }
289 289
290 bool V8TestSerializedScriptValueInterface::hasInstance(v8::Handle<v8::Value> jsV alue, v8::Isolate* isolate, WrapperWorldType currentWorldType) 290 bool V8TestSerializedScriptValueInterface::hasInstance(v8::Handle<v8::Value> jsV alue, v8::Isolate* isolate, WrapperWorldType currentWorldType)
291 { 291 {
292 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, currentWorldType); 292 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, currentWorldType);
293 } 293 }
294 294
295 bool V8TestSerializedScriptValueInterface::hasInstanceInAnyWorld(v8::Handle<v8:: Value> jsValue, v8::Isolate* isolate) 295 bool V8TestSerializedScriptValueInterface::hasInstanceInAnyWorld(v8::Handle<v8:: Value> jsValue, v8::Isolate* isolate)
296 { 296 {
297 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, MainWorld) 297 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, MainWorld)
(...skipping 27 matching lines...) Expand all
325 } 325 }
326 326
327 template<> 327 template<>
328 v8::Handle<v8::Value> toV8NoInline(TestSerializedScriptValueInterface* impl, v8: :Handle<v8::Object> creationContext, v8::Isolate* isolate) 328 v8::Handle<v8::Value> toV8NoInline(TestSerializedScriptValueInterface* impl, v8: :Handle<v8::Object> creationContext, v8::Isolate* isolate)
329 { 329 {
330 return toV8(impl, creationContext, isolate); 330 return toV8(impl, creationContext, isolate);
331 } 331 }
332 332
333 } // namespace WebCore 333 } // namespace WebCore
334 #endif // ENABLE(Condition1) || ENABLE(Condition2) 334 #endif // ENABLE(Condition1) || ENABLE(Condition2)
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/V8TestOverloadedConstructors.cpp ('k') | Source/bindings/tests/results/V8TestTypedefs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698