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

Unified Diff: third_party/WebKit/Source/core/inspector/v8/V8StringUtil.cpp

Issue 1650283002: DevTools: remove DOM and Bindings dependencies from inspector/v8. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for landing Created 4 years, 11 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
Index: third_party/WebKit/Source/core/inspector/v8/V8StringUtil.cpp
diff --git a/third_party/WebKit/Source/core/inspector/v8/V8StringUtil.cpp b/third_party/WebKit/Source/core/inspector/v8/V8StringUtil.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8c2d1504172d6a78b39f1aed796e85bd67265061
--- /dev/null
+++ b/third_party/WebKit/Source/core/inspector/v8/V8StringUtil.cpp
@@ -0,0 +1,36 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/inspector/v8/V8StringUtil.h"
+
+namespace blink {
+
+v8::Local<v8::String> toV8String(v8::Isolate* isolate, const String& string)
+{
+ return v8::String::NewFromUtf8(isolate, string.utf8().data(), v8::NewStringType::kNormal).ToLocalChecked();
+}
+
+v8::Local<v8::String> toV8StringInternalized(v8::Isolate* isolate, const String& string)
+{
+ return v8::String::NewFromUtf8(isolate, string.utf8().data(), v8::NewStringType::kInternalized).ToLocalChecked();
+}
+
+String toWTFString(v8::Local<v8::String> value)
+{
+ if (value.IsEmpty() || value->IsNull() || value->IsUndefined())
+ return String();
+ UChar* buffer;
+ String result = String::createUninitialized(value->Length(), buffer);
+ value->Write(reinterpret_cast<uint16_t*>(buffer), 0, value->Length());
+ return result;
+}
+
+String toWTFStringWithTypeCheck(v8::Local<v8::Value> value)
+{
+ if (value.IsEmpty() || !value->IsString())
+ return String();
+ return toWTFString(value.As<v8::String>());
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698