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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/StringUtil.h

Issue 2251343003: [DevTools] Generate separate copies of inspector_protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: win compile Created 4 years, 3 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 #ifndef V8StringUtil_h 5 #ifndef StringUtil_h
6 #define V8StringUtil_h 6 #define StringUtil_h
7 7
8 #include "platform/inspector_protocol/InspectorProtocol.h" 8 #include "platform/v8_inspector/Allocator.h"
9 #include "platform/v8_inspector/protocol/Debugger.h" 9 #include "platform/v8_inspector/String16.h"
10 #include "platform/v8_inspector/public/StringBuffer.h" 10 #include "platform/v8_inspector/public/StringBuffer.h"
11 #include "platform/v8_inspector/public/StringView.h" 11 #include "platform/v8_inspector/public/StringView.h"
12
12 #include <v8.h> 13 #include <v8.h>
13 14
14 namespace v8_inspector { 15 namespace v8_inspector {
15 16
16 class V8InspectorSession; 17 namespace protocol {
17 18
18 namespace protocol = blink::protocol; 19 class Value;
19 20
20 std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context>, v8::Loc al<v8::Value>, int maxDepth = protocol::Value::maxDepth); 21 using String = v8_inspector::String16;
22 using StringBuilder = v8_inspector::String16Builder;
23
24 class StringUtil {
25 public:
26 static String substring(const String& s, unsigned pos, unsigned len) { retur n s.substring(pos, len); }
27 static String fromInteger(int number) { return String::fromInteger(number); }
28 static String fromDouble(double number) { return String::fromDouble(number); }
29 static const size_t kNotFound = String::kNotFound;
30 static void builderReserve(StringBuilder& builder, unsigned capacity) { buil der.reserveCapacity(capacity); }
31 };
32
33 std::unique_ptr<protocol::Value> parseJSON(const StringView& json);
34 std::unique_ptr<protocol::Value> parseJSON(const String16& json);
35
36 } // namespace protocol
37
38 std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context>, v8::Loc al<v8::Value>, int maxDepth = 1000);
21 39
22 v8::Local<v8::String> toV8String(v8::Isolate*, const String16&); 40 v8::Local<v8::String> toV8String(v8::Isolate*, const String16&);
23 v8::Local<v8::String> toV8StringInternalized(v8::Isolate*, const String16&); 41 v8::Local<v8::String> toV8StringInternalized(v8::Isolate*, const String16&);
24 v8::Local<v8::String> toV8StringInternalized(v8::Isolate*, const char*); 42 v8::Local<v8::String> toV8StringInternalized(v8::Isolate*, const char*);
25 v8::Local<v8::String> toV8String(v8::Isolate*, const StringView&); 43 v8::Local<v8::String> toV8String(v8::Isolate*, const StringView&);
26 44 // TODO(dgozman): rename to toString16.
27 String16 toProtocolString(v8::Local<v8::String>); 45 String16 toProtocolString(v8::Local<v8::String>);
28 String16 toProtocolStringWithTypeCheck(v8::Local<v8::Value>); 46 String16 toProtocolStringWithTypeCheck(v8::Local<v8::Value>);
29 String16 toString16(const StringView&); 47 String16 toString16(const StringView&);
30 StringView toStringView(const String16&); 48 StringView toStringView(const String16&);
31
32 bool stringViewStartsWith(const StringView&, const char*); 49 bool stringViewStartsWith(const StringView&, const char*);
33 std::unique_ptr<protocol::Value> parseJSON(const StringView& json);
34
35 String16 findSourceURL(const String16& content, bool multiline);
36 String16 findSourceMapURL(const String16& content, bool multiline);
37 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> searchInTextByLine sImpl(V8InspectorSession*, const String16& text, const String16& query, bool cas eSensitive, bool isRegex);
38 50
39 class StringBufferImpl : public StringBuffer { 51 class StringBufferImpl : public StringBuffer {
40 PROTOCOL_DISALLOW_COPY(StringBufferImpl); 52 V8_INSPECTOR_DISALLOW_COPY(StringBufferImpl);
41 public: 53 public:
42 // Destroys string's content. 54 // Destroys string's content.
43 static std::unique_ptr<StringBufferImpl> adopt(String16&); 55 static std::unique_ptr<StringBufferImpl> adopt(String16&);
44 const StringView& string() override { return m_string; } 56 const StringView& string() override { return m_string; }
45 57
46 private: 58 private:
47 explicit StringBufferImpl(String16&); 59 explicit StringBufferImpl(String16&);
48 String16 m_owner; 60 String16 m_owner;
49 StringView m_string; 61 StringView m_string;
50 }; 62 };
51 63
52 } // namespace v8_inspector 64 } // namespace v8_inspector
53 65
54 66
55 #endif // !defined(V8StringUtil_h) 67 #endif // !defined(StringUtil_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698