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

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

Issue 2285743003: Use StringView for v8String(). (Closed)
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/V8Binding.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8Binding.h b/third_party/WebKit/Source/bindings/core/v8/V8Binding.h
index b903b47d4f250286850a375f4398486d782c5edc..3d5ea9e20f91f19ec507c2cf2548f142e2cfce26 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8Binding.h
+++ b/third_party/WebKit/Source/bindings/core/v8/V8Binding.h
@@ -397,14 +397,17 @@ inline String toCoreStringWithUndefinedOrNullCheck(v8::Local<v8::Value> value)
}
// Convert a string to a V8 string.
-// Return a V8 external string that shares the underlying buffer with the given
-// WebCore string. The reference counting mechanism is used to keep the
-// underlying buffer alive while the string is still live in the V8 engine.
-inline v8::Local<v8::String> v8String(v8::Isolate* isolate, const String& string)
+
+inline v8::Local<v8::String> v8String(v8::Isolate* isolate, const StringView& string)
{
+ DCHECK(isolate);
if (string.isNull())
return v8::String::Empty(isolate);
- return V8PerIsolateData::from(isolate)->getStringCache()->v8ExternalString(isolate, string.impl());
+ if (StringImpl* impl = string.sharedImpl())
+ return V8PerIsolateData::from(isolate)->getStringCache()->v8ExternalString(isolate, impl);
+ if (string.is8Bit())
+ return v8::String::NewFromOneByte(isolate, reinterpret_cast<const uint8_t*>(string.characters8()), v8::NewStringType::kNormal, static_cast<int>(string.length())).ToLocalChecked();
haraken 2016/08/27 01:21:46 Don't you want to use: V8PerIsolateData::from(i
esprehn 2016/08/27 02:18:57 Hmm? There's no such thing as string.impl() on a S
esprehn 2016/08/27 02:24:03 ex. https://cs.chromium.org/chromium/src/third_p
+ return v8::String::NewFromTwoByte(isolate, reinterpret_cast<const uint16_t*>(string.characters16()), v8::NewStringType::kNormal, static_cast<int>(string.length())).ToLocalChecked();
}
inline v8::Local<v8::Value> v8StringOrNull(v8::Isolate* isolate, const AtomicString& string)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698