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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8StringUtil.cpp

Issue 2159633002: [DevTools] Generate public versions of protocol classes to be exposed in v8_inspector/public. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed extra files 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
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 #include "platform/v8_inspector/V8StringUtil.h" 5 #include "platform/v8_inspector/V8StringUtil.h"
6 6
7 #include "platform/inspector_protocol/String16.h" 7 #include "platform/inspector_protocol/String16.h"
8 #include "platform/v8_inspector/V8DebuggerImpl.h" 8 #include "platform/v8_inspector/V8DebuggerImpl.h"
9 #include "platform/v8_inspector/V8InspectorSessionImpl.h" 9 #include "platform/v8_inspector/V8InspectorSessionImpl.h"
10 #include "platform/v8_inspector/V8Regex.h" 10 #include "platform/v8_inspector/V8Regex.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 return String16(buffer.get(), value->Length()); 175 return String16(buffer.get(), value->Length());
176 } 176 }
177 177
178 String16 toProtocolStringWithTypeCheck(v8::Local<v8::Value> value) 178 String16 toProtocolStringWithTypeCheck(v8::Local<v8::Value> value)
179 { 179 {
180 if (value.IsEmpty() || !value->IsString()) 180 if (value.IsEmpty() || !value->IsString())
181 return String16(); 181 return String16();
182 return toProtocolString(value.As<v8::String>()); 182 return toProtocolString(value.As<v8::String>());
183 } 183 }
184 184
185 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> searchInTextByLine sImpl(V8InspectorSession* session, const String16& text, const String16& query, const bool caseSensitive, const bool isRegex)
186 {
187 std::unique_ptr<V8Regex> regex = createSearchRegex(static_cast<V8InspectorSe ssionImpl*>(session)->debugger(), query, caseSensitive, isRegex);
188 std::vector<std::pair<int, String16>> matches = scriptRegexpMatchesByLines(* regex.get(), text);
189
190 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> result;
191 for (const auto& match : matches)
192 result.push_back(buildObjectForSearchMatch(match.first, match.second));
193 return result;
194 }
195
185 namespace V8ContentSearchUtil { 196 namespace V8ContentSearchUtil {
186 197
187 String16 findSourceURL(const String16& content, bool multiline, bool* deprecated ) 198 String16 findSourceURL(const String16& content, bool multiline, bool* deprecated )
188 { 199 {
189 return findMagicComment(content, "sourceURL", multiline, deprecated); 200 return findMagicComment(content, "sourceURL", multiline, deprecated);
190 } 201 }
191 202
192 String16 findSourceMapURL(const String16& content, bool multiline, bool* depreca ted) 203 String16 findSourceMapURL(const String16& content, bool multiline, bool* depreca ted)
193 { 204 {
194 return findMagicComment(content, "sourceMappingURL", multiline, deprecated); 205 return findMagicComment(content, "sourceMappingURL", multiline, deprecated);
195 } 206 }
196 207
197 std::unique_ptr<protocol::Array<protocol::Debugger::SearchMatch>> searchInTextBy Lines(V8InspectorSession* session, const String16& text, const String16& query, const bool caseSensitive, const bool isRegex) 208 std::unique_ptr<protocol::Array<protocol::Debugger::API::SearchMatch>> searchInT extByLines(V8InspectorSession* session, const String16& text, const String16& qu ery, const bool caseSensitive, const bool isRegex)
198 { 209 {
199 std::unique_ptr<protocol::Array<protocol::Debugger::SearchMatch>> result = p rotocol::Array<protocol::Debugger::SearchMatch>::create(); 210 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = sear chInTextByLinesImpl(session, text, query, caseSensitive, isRegex);
200 std::unique_ptr<V8Regex> regex = createSearchRegex(static_cast<V8InspectorSe ssionImpl*>(session)->debugger(), query, caseSensitive, isRegex); 211 std::unique_ptr<protocol::Array<protocol::Debugger::API::SearchMatch>> resul t = protocol::Array<protocol::Debugger::API::SearchMatch>::create();
201 std::vector<std::pair<int, String16>> matches = scriptRegexpMatchesByLines(* regex.get(), text); 212 for (size_t i = 0; i < matches.size(); ++i)
202 213 result->addItem(std::move(matches[i]));
203 for (const auto& match : matches)
204 result->addItem(buildObjectForSearchMatch(match.first, match.second));
205
206 return result; 214 return result;
207 } 215 }
208 216
209 } // namespace V8ContentSearchUtil 217 } // namespace V8ContentSearchUtil
210 218
211 std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context, v8::Local<v8::Value> value, int maxDepth) 219 std::unique_ptr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context, v8::Local<v8::Value> value, int maxDepth)
212 { 220 {
213 if (value.IsEmpty()) { 221 if (value.IsEmpty()) {
214 NOTREACHED(); 222 NOTREACHED();
215 return nullptr; 223 return nullptr;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 return nullptr; 283 return nullptr;
276 jsonObject->setValue(toProtocolString(propertyName), std::move(prope rtyValue)); 284 jsonObject->setValue(toProtocolString(propertyName), std::move(prope rtyValue));
277 } 285 }
278 return std::move(jsonObject); 286 return std::move(jsonObject);
279 } 287 }
280 NOTREACHED(); 288 NOTREACHED();
281 return nullptr; 289 return nullptr;
282 } 290 }
283 291
284 } // namespace blink 292 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698