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

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

Issue 2812833003: Revert of [SharedArrayBuffer] Prevent SharedArrayBuffer being used in Web APIs (Closed)
Patch Set: Created 3 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 * Copyright (C) 2012 Ericsson AB. All rights reserved. 3 * Copyright (C) 2012 Ericsson AB. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 29 matching lines...) Expand all
40 #include "bindings/core/v8/ScriptState.h" 40 #include "bindings/core/v8/ScriptState.h"
41 #include "bindings/core/v8/ScriptValue.h" 41 #include "bindings/core/v8/ScriptValue.h"
42 #include "bindings/core/v8/ScriptWrappable.h" 42 #include "bindings/core/v8/ScriptWrappable.h"
43 #include "bindings/core/v8/V8BindingMacros.h" 43 #include "bindings/core/v8/V8BindingMacros.h"
44 #include "bindings/core/v8/V8PerIsolateData.h" 44 #include "bindings/core/v8/V8PerIsolateData.h"
45 #include "bindings/core/v8/V8ScriptRunner.h" 45 #include "bindings/core/v8/V8ScriptRunner.h"
46 #include "bindings/core/v8/V8StringResource.h" 46 #include "bindings/core/v8/V8StringResource.h"
47 #include "bindings/core/v8/V8ThrowException.h" 47 #include "bindings/core/v8/V8ThrowException.h"
48 #include "bindings/core/v8/V8ValueCache.h" 48 #include "bindings/core/v8/V8ValueCache.h"
49 #include "core/CoreExport.h" 49 #include "core/CoreExport.h"
50 #include "core/dom/NotShared.h"
51 #include "platform/heap/Handle.h" 50 #include "platform/heap/Handle.h"
52 #include "platform/wtf/text/AtomicString.h" 51 #include "platform/wtf/text/AtomicString.h"
53 #include "platform/wtf/text/StringView.h" 52 #include "platform/wtf/text/StringView.h"
54 #include "v8/include/v8.h" 53 #include "v8/include/v8.h"
55 54
56 namespace blink { 55 namespace blink {
57 56
58 class DOMWindow; 57 class DOMWindow;
59 class EventListener; 58 class EventListener;
60 class EventTarget; 59 class EventTarget;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 V8SetReturnValue(callback_info, ToV8(impl, callback_info.Holder(), 209 V8SetReturnValue(callback_info, ToV8(impl, callback_info.Holder(),
211 callback_info.GetIsolate())); 210 callback_info.GetIsolate()));
212 } 211 }
213 212
214 template <typename CallbackInfo, typename T> 213 template <typename CallbackInfo, typename T>
215 inline void V8SetReturnValue(const CallbackInfo& callback_info, 214 inline void V8SetReturnValue(const CallbackInfo& callback_info,
216 PassRefPtr<T> impl) { 215 PassRefPtr<T> impl) {
217 V8SetReturnValue(callback_info, impl.Get()); 216 V8SetReturnValue(callback_info, impl.Get());
218 } 217 }
219 218
220 template <typename CallbackInfo, typename T>
221 inline void V8SetReturnValue(const CallbackInfo& callbackInfo,
222 NotShared<T> notShared) {
223 V8SetReturnValue(callbackInfo, notShared.View());
224 }
225
226 template <typename CallbackInfo> 219 template <typename CallbackInfo>
227 inline void V8SetReturnValueForMainWorld(const CallbackInfo& callback_info, 220 inline void V8SetReturnValueForMainWorld(const CallbackInfo& callback_info,
228 ScriptWrappable* impl) { 221 ScriptWrappable* impl) {
229 ASSERT(DOMWrapperWorld::Current(callback_info.GetIsolate()).IsMainWorld()); 222 ASSERT(DOMWrapperWorld::Current(callback_info.GetIsolate()).IsMainWorld());
230 if (UNLIKELY(!impl)) { 223 if (UNLIKELY(!impl)) {
231 V8SetReturnValueNull(callback_info); 224 V8SetReturnValueNull(callback_info);
232 return; 225 return;
233 } 226 }
234 if (DOMDataStore::SetReturnValueForMainWorld(callback_info.GetReturnValue(), 227 if (DOMDataStore::SetReturnValueForMainWorld(callback_info.GetReturnValue(),
235 impl)) 228 impl))
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 V8SetReturnValueFast(callback_info, impl.Get(), wrappable); 327 V8SetReturnValueFast(callback_info, impl.Get(), wrappable);
335 } 328 }
336 329
337 template <typename CallbackInfo, typename T> 330 template <typename CallbackInfo, typename T>
338 inline void V8SetReturnValueFast(const CallbackInfo& callback_info, 331 inline void V8SetReturnValueFast(const CallbackInfo& callback_info,
339 const v8::Local<T> handle, 332 const v8::Local<T> handle,
340 const ScriptWrappable*) { 333 const ScriptWrappable*) {
341 V8SetReturnValue(callback_info, handle); 334 V8SetReturnValue(callback_info, handle);
342 } 335 }
343 336
344 template <typename CallbackInfo, typename T>
345 inline void V8SetReturnValueFast(const CallbackInfo& callbackInfo,
346 NotShared<T> notShared,
347 const ScriptWrappable* wrappable) {
348 V8SetReturnValueFast(callbackInfo, notShared.View(), wrappable);
349 }
350
351 // Convert v8::String to a WTF::String. If the V8 string is not already 337 // Convert v8::String to a WTF::String. If the V8 string is not already
352 // an external string then it is transformed into an external string at this 338 // an external string then it is transformed into an external string at this
353 // point to avoid repeated conversions. 339 // point to avoid repeated conversions.
354 inline String ToCoreString(v8::Local<v8::String> value) { 340 inline String ToCoreString(v8::Local<v8::String> value) {
355 return V8StringToWebCoreString<String>(value, kExternalize); 341 return V8StringToWebCoreString<String>(value, kExternalize);
356 } 342 }
357 343
358 inline String ToCoreStringWithNullCheck(v8::Local<v8::String> value) { 344 inline String ToCoreStringWithNullCheck(v8::Local<v8::String> value) {
359 if (value.IsEmpty() || value->IsNull()) 345 if (value.IsEmpty() || value->IsNull())
360 return String(); 346 return String();
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 1156
1171 // Freeze a V8 object. The type of the first parameter and the return value is 1157 // Freeze a V8 object. The type of the first parameter and the return value is
1172 // intentionally v8::Value so that this function can wrap ToV8(). 1158 // intentionally v8::Value so that this function can wrap ToV8().
1173 // If the argument isn't an object, this will crash. 1159 // If the argument isn't an object, this will crash.
1174 CORE_EXPORT v8::Local<v8::Value> FreezeV8Object(v8::Local<v8::Value>, 1160 CORE_EXPORT v8::Local<v8::Value> FreezeV8Object(v8::Local<v8::Value>,
1175 v8::Isolate*); 1161 v8::Isolate*);
1176 1162
1177 CORE_EXPORT v8::Local<v8::Value> FromJSONString(v8::Isolate*, 1163 CORE_EXPORT v8::Local<v8::Value> FromJSONString(v8::Isolate*,
1178 const String& stringified_json, 1164 const String& stringified_json,
1179 ExceptionState&); 1165 ExceptionState&);
1180
1181 // Ensure that a typed array value is not backed by a SharedArrayBuffer. If it
1182 // is, an exception will be thrown. The return value will use the NotShared
1183 // wrapper type.
1184 template <typename NotSharedType>
1185 NotSharedType ToNotShared(v8::Isolate* isolate,
1186 v8::Local<v8::Value> value,
1187 ExceptionState& exception_state) {
1188 using DOMTypedArray = typename NotSharedType::TypedArrayType;
1189 DOMTypedArray* dom_typed_array =
1190 V8TypeOf<DOMTypedArray>::Type::toImplWithTypeCheck(isolate, value);
1191 if (dom_typed_array && dom_typed_array->IsShared()) {
1192 exception_state.ThrowTypeError(
1193 "The provided ArrayBufferView value must not be shared.");
1194 return NotSharedType();
1195 }
1196 return NotSharedType(dom_typed_array);
1197 }
1198
1199 } // namespace blink 1166 } // namespace blink
1200 1167
1201 #endif // V8Binding_h 1168 #endif // V8Binding_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ToV8.h ('k') | third_party/WebKit/Source/bindings/scripts/v8_attributes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698