Chromium Code Reviews| Index: third_party/WebKit/Source/core/inspector/V8InspectorStringView.cpp |
| diff --git a/third_party/WebKit/Source/core/inspector/V8InspectorStringView.cpp b/third_party/WebKit/Source/core/inspector/V8InspectorStringView.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4819a9dfd3da83e0e948edd10640e7e40434bed7 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/inspector/V8InspectorStringView.cpp |
| @@ -0,0 +1,41 @@ |
| +// 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/V8InspectorStringView.h" |
| + |
| +#include <cstring> |
| + |
| +namespace blink { |
| + |
| +v8_inspector::StringView toV8InspectorStringView(const String& string) |
| +{ |
| + if (string.isEmpty()) |
| + return v8_inspector::StringView(); |
|
esprehn
2016/08/19 18:53:12
this is converting empty to null, those are two di
dgozman
2016/08/19 20:50:12
Fixed.
|
| + if (string.is8Bit()) |
| + return v8_inspector::StringView(reinterpret_cast<const uint8_t*>(string.characters8()), string.length()); |
| + return v8_inspector::StringView(reinterpret_cast<const uint16_t*>(string.characters16()), string.length()); |
| +} |
| + |
| +v8_inspector::StringView toV8InspectorStringView(const String16& string) |
| +{ |
| + if (string.isEmpty()) |
| + return v8_inspector::StringView(); |
| + return v8_inspector::StringView(reinterpret_cast<const uint16_t*>(string.characters16()), string.length()); |
| +} |
| + |
| +v8_inspector::StringView toV8InspectorStringView(const char* string) |
| +{ |
| + return v8_inspector::StringView(reinterpret_cast<const uint8_t*>(string), strlen(string)); |
|
esprehn
2016/08/19 18:53:12
You should either take a WTF::StringView or make t
dgozman
2016/08/19 20:50:12
Done.
|
| +} |
| + |
| +String toCoreString(const v8_inspector::StringView& string) |
| +{ |
| + if (!string.length()) |
|
esprehn
2016/08/19 18:53:12
This converts zero length strings to empty strings
dgozman
2016/08/19 20:50:12
Fixed.
|
| + return emptyString(); |
| + if (string.is8Bit()) |
| + return String(reinterpret_cast<const LChar*>(string.characters8()), string.length()); |
| + return String(reinterpret_cast<const UChar*>(string.characters16()), string.length()); |
| +} |
| + |
| +} // namespace blink |