OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/inspector/V8InspectorString.h" |
| 6 |
| 7 namespace blink { |
| 8 |
| 9 v8_inspector::StringView toV8InspectorStringView(const StringView& string) |
| 10 { |
| 11 if (string.isNull()) |
| 12 return v8_inspector::StringView(); |
| 13 if (string.is8Bit()) |
| 14 return v8_inspector::StringView(reinterpret_cast<const uint8_t*>(string.
characters8()), string.length()); |
| 15 return v8_inspector::StringView(reinterpret_cast<const uint16_t*>(string.cha
racters16()), string.length()); |
| 16 } |
| 17 |
| 18 std::unique_ptr<v8_inspector::StringBuffer> toV8InspectorStringBuffer(const Stri
ngView& string) |
| 19 { |
| 20 return v8_inspector::StringBuffer::create(toV8InspectorStringView(string)); |
| 21 } |
| 22 |
| 23 String toCoreString(const v8_inspector::StringView& string) |
| 24 { |
| 25 if (string.is8Bit()) |
| 26 return String(reinterpret_cast<const LChar*>(string.characters8()), stri
ng.length()); |
| 27 return String(reinterpret_cast<const UChar*>(string.characters16()), string.
length()); |
| 28 } |
| 29 |
| 30 String toCoreString(std::unique_ptr<v8_inspector::StringBuffer> buffer) |
| 31 { |
| 32 if (!buffer) |
| 33 return String(); |
| 34 return toCoreString(buffer->string()); |
| 35 } |
| 36 |
| 37 } // namespace blink |
OLD | NEW |