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

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

Issue 2142373002: Make v8AtomicString take a StringView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 "platform/heap/Handle.h" 50 #include "platform/heap/Handle.h"
51 #include "platform/text/CompressibleString.h" 51 #include "platform/text/CompressibleString.h"
52 #include "wtf/text/AtomicString.h" 52 #include "wtf/text/AtomicString.h"
53 #include "wtf/text/StringView.h"
53 #include <v8.h> 54 #include <v8.h>
54 55
55 namespace blink { 56 namespace blink {
56 57
57 class DOMWindow; 58 class DOMWindow;
58 class EventListener; 59 class EventListener;
59 class EventTarget; 60 class EventTarget;
60 class ExceptionState; 61 class ExceptionState;
61 class ExecutionContext; 62 class ExecutionContext;
62 class FlexibleArrayBufferView; 63 class FlexibleArrayBufferView;
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 return V8PerIsolateData::from(isolate)->getStringCache()->v8ExternalString(i solate, string.impl()); 415 return V8PerIsolateData::from(isolate)->getStringCache()->v8ExternalString(i solate, string.impl());
415 } 416 }
416 417
417 inline v8::Local<v8::String> v8String(v8::Isolate* isolate, const CompressibleSt ring& string) 418 inline v8::Local<v8::String> v8String(v8::Isolate* isolate, const CompressibleSt ring& string)
418 { 419 {
419 if (string.isNull()) 420 if (string.isNull())
420 return v8::String::Empty(isolate); 421 return v8::String::Empty(isolate);
421 return V8PerIsolateData::from(isolate)->getStringCache()->v8ExternalString(i solate, string); 422 return V8PerIsolateData::from(isolate)->getStringCache()->v8ExternalString(i solate, string);
422 } 423 }
423 424
424 inline v8::Local<v8::String> v8AtomicString(v8::Isolate* isolate, const char* st r, int length = -1) 425 inline v8::Local<v8::String> v8AtomicString(v8::Isolate* isolate, const StringVi ew& string)
425 { 426 {
426 ASSERT(isolate); 427 DCHECK(isolate);
427 v8::Local<v8::String> value; 428 if (string.is8Bit())
428 if (LIKELY(v8::String::NewFromUtf8(isolate, str, v8::NewStringType::kInterna lized, length).ToLocal(&value))) 429 return v8CallOrCrash(v8::String::NewFromOneByte(isolate, reinterpret_cas t<const uint8_t*>(string.characters8()), v8::NewStringType::kInternalized, stati c_cast<int>(string.length())));
esprehn 2016/07/13 00:48:53 v8CallOrCrash is a call to FromJust() which contai
429 return value; 430 return v8CallOrCrash(v8::String::NewFromTwoByte(isolate, reinterpret_cast<co nst uint16_t*>(string.characters16()), v8::NewStringType::kInternalized, static_ cast<int>(string.length())));
430 // Immediately crashes when NewFromUtf8() fails because it only fails the 431 }
431 // given str is too long. 432
432 RELEASE_NOTREACHED(); 433 inline v8::Local<v8::String> v8StringFromUtf8(v8::Isolate* isolate, const char* bytes, int length)
433 return v8::String::Empty(isolate); 434 {
435 DCHECK(isolate);
436 return v8CallOrCrash(v8::String::NewFromUtf8(isolate, bytes, v8::NewStringTy pe::kNormal));
434 } 437 }
435 438
436 inline v8::Local<v8::Value> v8Undefined() 439 inline v8::Local<v8::Value> v8Undefined()
437 { 440 {
438 return v8::Local<v8::Value>(); 441 return v8::Local<v8::Value>();
439 } 442 }
440 443
441 // Conversion flags, used in toIntXX/toUIntXX. 444 // Conversion flags, used in toIntXX/toUIntXX.
442 enum IntegerConversionConfiguration { 445 enum IntegerConversionConfiguration {
443 NormalConversion, 446 NormalConversion,
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 typedef void (*InstallTemplateFunction)(v8::Isolate*, const DOMWrapperWorld&, v8 ::Local<v8::FunctionTemplate> interfaceTemplate); 973 typedef void (*InstallTemplateFunction)(v8::Isolate*, const DOMWrapperWorld&, v8 ::Local<v8::FunctionTemplate> interfaceTemplate);
971 974
972 // Freeze a V8 object. The type of the first parameter and the return value is 975 // Freeze a V8 object. The type of the first parameter and the return value is
973 // intentionally v8::Value so that this function can wrap toV8(). 976 // intentionally v8::Value so that this function can wrap toV8().
974 // If the argument isn't an object, this will crash. 977 // If the argument isn't an object, this will crash.
975 CORE_EXPORT v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value>, v8::Isolat e*); 978 CORE_EXPORT v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value>, v8::Isolat e*);
976 979
977 } // namespace blink 980 } // namespace blink
978 981
979 #endif // V8Binding_h 982 #endif // V8Binding_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698