| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/inspector/string-util.h" | 5 #include "src/inspector/string-util.h" |
| 6 | 6 |
| 7 #include "src/inspector/protocol/Protocol.h" | 7 #include "src/inspector/protocol/Protocol.h" |
| 8 | 8 |
| 9 namespace v8_inspector { | 9 namespace v8_inspector { |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 isolate, reinterpret_cast<const uint8_t*>(string.characters8()), | 43 isolate, reinterpret_cast<const uint8_t*>(string.characters8()), |
| 44 v8::NewStringType::kNormal, static_cast<int>(string.length())) | 44 v8::NewStringType::kNormal, static_cast<int>(string.length())) |
| 45 .ToLocalChecked(); | 45 .ToLocalChecked(); |
| 46 return v8::String::NewFromTwoByte( | 46 return v8::String::NewFromTwoByte( |
| 47 isolate, reinterpret_cast<const uint16_t*>(string.characters16()), | 47 isolate, reinterpret_cast<const uint16_t*>(string.characters16()), |
| 48 v8::NewStringType::kNormal, static_cast<int>(string.length())) | 48 v8::NewStringType::kNormal, static_cast<int>(string.length())) |
| 49 .ToLocalChecked(); | 49 .ToLocalChecked(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 String16 toProtocolString(v8::Local<v8::String> value) { | 52 String16 toProtocolString(v8::Local<v8::String> value) { |
| 53 if (value.IsEmpty() || value->IsNull() || value->IsUndefined()) | 53 if (value.IsEmpty() || value->IsNullOrUndefined()) return String16(); |
| 54 return String16(); | |
| 55 std::unique_ptr<UChar[]> buffer(new UChar[value->Length()]); | 54 std::unique_ptr<UChar[]> buffer(new UChar[value->Length()]); |
| 56 value->Write(reinterpret_cast<uint16_t*>(buffer.get()), 0, value->Length()); | 55 value->Write(reinterpret_cast<uint16_t*>(buffer.get()), 0, value->Length()); |
| 57 return String16(buffer.get(), value->Length()); | 56 return String16(buffer.get(), value->Length()); |
| 58 } | 57 } |
| 59 | 58 |
| 60 String16 toProtocolStringWithTypeCheck(v8::Local<v8::Value> value) { | 59 String16 toProtocolStringWithTypeCheck(v8::Local<v8::Value> value) { |
| 61 if (value.IsEmpty() || !value->IsString()) return String16(); | 60 if (value.IsEmpty() || !value->IsString()) return String16(); |
| 62 return toProtocolString(value.As<v8::String>()); | 61 return toProtocolString(value.As<v8::String>()); |
| 63 } | 62 } |
| 64 | 63 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 std::unique_ptr<StringBufferImpl> StringBufferImpl::adopt(String16& string) { | 121 std::unique_ptr<StringBufferImpl> StringBufferImpl::adopt(String16& string) { |
| 123 return std::unique_ptr<StringBufferImpl>(new StringBufferImpl(string)); | 122 return std::unique_ptr<StringBufferImpl>(new StringBufferImpl(string)); |
| 124 } | 123 } |
| 125 | 124 |
| 126 StringBufferImpl::StringBufferImpl(String16& string) { | 125 StringBufferImpl::StringBufferImpl(String16& string) { |
| 127 m_owner.swap(string); | 126 m_owner.swap(string); |
| 128 m_string = toStringView(m_owner); | 127 m_string = toStringView(m_owner); |
| 129 } | 128 } |
| 130 | 129 |
| 131 } // namespace v8_inspector | 130 } // namespace v8_inspector |
| OLD | NEW |