| OLD | NEW |
| 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" |
| 11 #include "platform/v8_inspector/public/V8ContentSearchUtil.h" | 11 #include "platform/v8_inspector/public/V8ContentSearchUtil.h" |
| 12 #include "platform/v8_inspector/public/V8ToProtocolValue.h" | 12 #include "platform/v8_inspector/public/V8ToProtocolValue.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 String16 findMagicComment(const String16& content, const String16& name, bool mu
ltiline, bool* deprecated) | 18 String16 findMagicComment(const String16& content, const String16& name, bool mu
ltiline, bool* deprecated) |
| 19 { | 19 { |
| 20 ASSERT(name.find("=") == kNotFound); | 20 DCHECK(name.find("=") == kNotFound); |
| 21 if (deprecated) | 21 if (deprecated) |
| 22 *deprecated = false; | 22 *deprecated = false; |
| 23 | 23 |
| 24 unsigned length = content.length(); | 24 unsigned length = content.length(); |
| 25 unsigned nameLength = name.length(); | 25 unsigned nameLength = name.length(); |
| 26 | 26 |
| 27 size_t pos = length; | 27 size_t pos = length; |
| 28 size_t equalSignPos = 0; | 28 size_t equalSignPos = 0; |
| 29 size_t closingCommentPos = 0; | 29 size_t closingCommentPos = 0; |
| 30 while (true) { | 30 while (true) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 53 if (closingCommentPos == kNotFound) | 53 if (closingCommentPos == kNotFound) |
| 54 return String16(); | 54 return String16(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 break; | 57 break; |
| 58 } | 58 } |
| 59 | 59 |
| 60 if (deprecated && content[pos + 2] == '@') | 60 if (deprecated && content[pos + 2] == '@') |
| 61 *deprecated = true; | 61 *deprecated = true; |
| 62 | 62 |
| 63 ASSERT(equalSignPos); | 63 DCHECK(equalSignPos); |
| 64 ASSERT(!multiline || closingCommentPos); | 64 DCHECK(!multiline || closingCommentPos); |
| 65 size_t urlPos = equalSignPos + 1; | 65 size_t urlPos = equalSignPos + 1; |
| 66 String16 match = multiline | 66 String16 match = multiline |
| 67 ? content.substring(urlPos, closingCommentPos - urlPos) | 67 ? content.substring(urlPos, closingCommentPos - urlPos) |
| 68 : content.substring(urlPos); | 68 : content.substring(urlPos); |
| 69 | 69 |
| 70 size_t newLine = match.find("\n"); | 70 size_t newLine = match.find("\n"); |
| 71 if (newLine != kNotFound) | 71 if (newLine != kNotFound) |
| 72 match = match.substring(0, newLine); | 72 match = match.substring(0, newLine); |
| 73 match = match.stripWhiteSpace(); | 73 match = match.stripWhiteSpace(); |
| 74 | 74 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 result->addItem(buildObjectForSearchMatch(match.first, match.second)); | 205 result->addItem(buildObjectForSearchMatch(match.first, match.second)); |
| 206 | 206 |
| 207 return result; | 207 return result; |
| 208 } | 208 } |
| 209 | 209 |
| 210 } // namespace V8ContentSearchUtil | 210 } // namespace V8ContentSearchUtil |
| 211 | 211 |
| 212 PassOwnPtr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context, v8::
Local<v8::Value> value, int maxDepth) | 212 PassOwnPtr<protocol::Value> toProtocolValue(v8::Local<v8::Context> context, v8::
Local<v8::Value> value, int maxDepth) |
| 213 { | 213 { |
| 214 if (value.IsEmpty()) { | 214 if (value.IsEmpty()) { |
| 215 ASSERT_NOT_REACHED(); | 215 NOTREACHED(); |
| 216 return nullptr; | 216 return nullptr; |
| 217 } | 217 } |
| 218 | 218 |
| 219 if (!maxDepth) | 219 if (!maxDepth) |
| 220 return nullptr; | 220 return nullptr; |
| 221 maxDepth--; | 221 maxDepth--; |
| 222 | 222 |
| 223 if (value->IsNull() || value->IsUndefined()) | 223 if (value->IsNull() || value->IsUndefined()) |
| 224 return protocol::Value::null(); | 224 return protocol::Value::null(); |
| 225 if (value->IsBoolean()) | 225 if (value->IsBoolean()) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 v8::Local<v8::Value> property; | 266 v8::Local<v8::Value> property; |
| 267 if (!object->Get(context, name).ToLocal(&property)) | 267 if (!object->Get(context, name).ToLocal(&property)) |
| 268 return nullptr; | 268 return nullptr; |
| 269 OwnPtr<protocol::Value> propertyValue = toProtocolValue(context, pro
perty, maxDepth); | 269 OwnPtr<protocol::Value> propertyValue = toProtocolValue(context, pro
perty, maxDepth); |
| 270 if (!propertyValue) | 270 if (!propertyValue) |
| 271 return nullptr; | 271 return nullptr; |
| 272 jsonObject->setValue(toProtocolString(propertyName), std::move(prope
rtyValue)); | 272 jsonObject->setValue(toProtocolString(propertyName), std::move(prope
rtyValue)); |
| 273 } | 273 } |
| 274 return std::move(jsonObject); | 274 return std::move(jsonObject); |
| 275 } | 275 } |
| 276 ASSERT_NOT_REACHED(); | 276 NOTREACHED(); |
| 277 return nullptr; | 277 return nullptr; |
| 278 } | 278 } |
| 279 | 279 |
| 280 } // namespace blink | 280 } // namespace blink |
| OLD | NEW |