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

Side by Side Diff: third_party/WebKit/Source/core/inspector/V8InspectorString.cpp

Issue 2260233002: [DevTools] Migrate v8_inspector/public from String16 to String{View,Buffer}. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: small fixes Created 4 years, 4 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 unified diff | Download patch
OLDNEW
(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 if (!string.characters8())
esprehn 2016/08/23 17:35:39 the string constructor does this for you.
27 return String();
28 if (!string.length())
29 return emptyString();
esprehn 2016/08/23 17:35:39 ditto
30 return String(reinterpret_cast<const LChar*>(string.characters8()), stri ng.length());
31 }
32 if (!string.characters16())
33 return String();
esprehn 2016/08/23 17:35:39 ditto, you don't need to null check or empty check
dgozman 2016/08/24 00:45:00 Done.
34 if (!string.length())
35 return emptyString();
36 return String(reinterpret_cast<const UChar*>(string.characters16()), string. length());
37 }
38
39 String toCoreString(std::unique_ptr<v8_inspector::StringBuffer> buffer)
40 {
41 if (!buffer)
42 return String();
43 return toCoreString(buffer->string());
44 }
45
46 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698