Chromium Code Reviews| 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/V8InspectorStringView.h" | |
| 6 | |
| 7 #include <cstring> | |
| 8 | |
| 9 namespace blink { | |
| 10 | |
| 11 v8_inspector::StringView toV8InspectorStringView(const String& string) | |
| 12 { | |
| 13 if (string.isEmpty()) | |
| 14 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.
| |
| 15 if (string.is8Bit()) | |
| 16 return v8_inspector::StringView(reinterpret_cast<const uint8_t*>(string. characters8()), string.length()); | |
| 17 return v8_inspector::StringView(reinterpret_cast<const uint16_t*>(string.cha racters16()), string.length()); | |
| 18 } | |
| 19 | |
| 20 v8_inspector::StringView toV8InspectorStringView(const String16& string) | |
| 21 { | |
| 22 if (string.isEmpty()) | |
| 23 return v8_inspector::StringView(); | |
| 24 return v8_inspector::StringView(reinterpret_cast<const uint16_t*>(string.cha racters16()), string.length()); | |
| 25 } | |
| 26 | |
| 27 v8_inspector::StringView toV8InspectorStringView(const char* string) | |
| 28 { | |
| 29 return v8_inspector::StringView(reinterpret_cast<const uint8_t*>(string), st rlen(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.
| |
| 30 } | |
| 31 | |
| 32 String toCoreString(const v8_inspector::StringView& string) | |
| 33 { | |
| 34 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.
| |
| 35 return emptyString(); | |
| 36 if (string.is8Bit()) | |
| 37 return String(reinterpret_cast<const LChar*>(string.characters8()), stri ng.length()); | |
| 38 return String(reinterpret_cast<const UChar*>(string.characters16()), string. length()); | |
| 39 } | |
| 40 | |
| 41 } // namespace blink | |
| OLD | NEW |