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

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

Issue 2226863003: [DevTools] Reduce API surface of String16. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/V8Debugger.h" 5 #include "platform/v8_inspector/V8Debugger.h"
6 6
7 #include "platform/v8_inspector/DebuggerScript.h" 7 #include "platform/v8_inspector/DebuggerScript.h"
8 #include "platform/v8_inspector/ScriptBreakpoint.h" 8 #include "platform/v8_inspector/ScriptBreakpoint.h"
9 #include "platform/v8_inspector/V8Compat.h" 9 #include "platform/v8_inspector/V8Compat.h"
10 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" 10 #include "platform/v8_inspector/V8DebuggerAgentImpl.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return 0; 92 return 0;
93 String16 dataString = toProtocolString(data.As<v8::String>()); 93 String16 dataString = toProtocolString(data.As<v8::String>());
94 if (dataString.isEmpty()) 94 if (dataString.isEmpty())
95 return 0; 95 return 0;
96 size_t commaPos = dataString.find(","); 96 size_t commaPos = dataString.find(",");
97 if (commaPos == kNotFound) 97 if (commaPos == kNotFound)
98 return 0; 98 return 0;
99 size_t commaPos2 = dataString.find(",", commaPos + 1); 99 size_t commaPos2 = dataString.find(",", commaPos + 1);
100 if (commaPos2 == kNotFound) 100 if (commaPos2 == kNotFound)
101 return 0; 101 return 0;
102 return dataString.substring(commaPos + 1, commaPos2 - commaPos - 1).toInt(); 102 String16 idString = dataString.substring(commaPos + 1, commaPos2 - commaPos - 1);
103 return protocol::string16CharactersToInt(idString.characters16(), idString.l ength());
103 } 104 }
104 105
105 // static 106 // static
106 int V8Debugger::getGroupId(v8::Local<v8::Context> context) 107 int V8Debugger::getGroupId(v8::Local<v8::Context> context)
107 { 108 {
108 v8::Local<v8::Value> data = context->GetEmbedderData(static_cast<int>(v8::Co ntext::kDebugIdIndex)); 109 v8::Local<v8::Value> data = context->GetEmbedderData(static_cast<int>(v8::Co ntext::kDebugIdIndex));
109 if (data.IsEmpty() || !data->IsString()) 110 if (data.IsEmpty() || !data->IsString())
110 return 0; 111 return 0;
111 String16 dataString = toProtocolString(data.As<v8::String>()); 112 String16 dataString = toProtocolString(data.As<v8::String>());
112 if (dataString.isEmpty()) 113 if (dataString.isEmpty())
113 return 0; 114 return 0;
114 size_t commaPos = dataString.find(","); 115 size_t commaPos = dataString.find(",");
115 if (commaPos == kNotFound) 116 if (commaPos == kNotFound)
116 return 0; 117 return 0;
117 return dataString.substring(0, commaPos).toInt(); 118 String16 groupString = dataString.substring(0, commaPos);
119 return protocol::string16CharactersToInt(groupString.characters16(), groupSt ring.length());
118 } 120 }
119 121
120 void V8Debugger::getCompiledScripts(int contextGroupId, std::vector<std::unique_ ptr<V8DebuggerScript>>& result) 122 void V8Debugger::getCompiledScripts(int contextGroupId, std::vector<std::unique_ ptr<V8DebuggerScript>>& result)
121 { 123 {
122 v8::HandleScope scope(m_isolate); 124 v8::HandleScope scope(m_isolate);
123 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr otasks); 125 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr otasks);
124 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); 126 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate);
125 DCHECK(!debuggerScript->IsUndefined()); 127 DCHECK(!debuggerScript->IsUndefined());
126 v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(d ebuggerScript->Get(toV8StringInternalized(m_isolate, "getScripts"))); 128 v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(d ebuggerScript->Get(toV8StringInternalized(m_isolate, "getScripts")));
127 v8::Local<v8::Value> argv[] = { v8::Integer::New(m_isolate, contextGroupId) }; 129 v8::Local<v8::Value> argv[] = { v8::Integer::New(m_isolate, contextGroupId) };
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 V8DebuggerAgentImpl* agent = m_inspector->enabledDebuggerAgentForGroup(getGr oupId(pausedContext)); 432 V8DebuggerAgentImpl* agent = m_inspector->enabledDebuggerAgentForGroup(getGr oupId(pausedContext));
431 if (!agent) 433 if (!agent)
432 return; 434 return;
433 435
434 std::vector<String16> breakpointIds; 436 std::vector<String16> breakpointIds;
435 if (!hitBreakpointNumbers.IsEmpty()) { 437 if (!hitBreakpointNumbers.IsEmpty()) {
436 breakpointIds.reserve(hitBreakpointNumbers->Length()); 438 breakpointIds.reserve(hitBreakpointNumbers->Length());
437 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { 439 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) {
438 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get (i); 440 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get (i);
439 DCHECK(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3 2()); 441 DCHECK(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3 2());
440 breakpointIds.push_back(String16::fromInteger(hitBreakpointNumber->I nt32Value())); 442 breakpointIds.push_back(protocol::string16FromInteger(hitBreakpointN umber->Int32Value()));
441 } 443 }
442 } 444 }
443 445
444 m_pausedContext = pausedContext; 446 m_pausedContext = pausedContext;
445 m_executionState = executionState; 447 m_executionState = executionState;
446 V8DebuggerAgentImpl::SkipPauseRequest result = agent->didPause(pausedContext , exception, breakpointIds, isPromiseRejection); 448 V8DebuggerAgentImpl::SkipPauseRequest result = agent->didPause(pausedContext , exception, breakpointIds, isPromiseRejection);
447 if (result == V8DebuggerAgentImpl::RequestNoSkip) { 449 if (result == V8DebuggerAgentImpl::RequestNoSkip) {
448 m_runningNestedMessageLoop = true; 450 m_runningNestedMessageLoop = true;
449 int groupId = getGroupId(pausedContext); 451 int groupId = getGroupId(pausedContext);
450 DCHECK(groupId); 452 DCHECK(groupId);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 v8::Local<v8::Value> V8Debugger::functionLocation(v8::Local<v8::Context> context , v8::Local<v8::Function> function) 684 v8::Local<v8::Value> V8Debugger::functionLocation(v8::Local<v8::Context> context , v8::Local<v8::Function> function)
683 { 685 {
684 int scriptId = function->ScriptId(); 686 int scriptId = function->ScriptId();
685 if (scriptId == v8::UnboundScript::kNoScriptId) 687 if (scriptId == v8::UnboundScript::kNoScriptId)
686 return v8::Null(m_isolate); 688 return v8::Null(m_isolate);
687 int lineNumber = function->GetScriptLineNumber(); 689 int lineNumber = function->GetScriptLineNumber();
688 int columnNumber = function->GetScriptColumnNumber(); 690 int columnNumber = function->GetScriptColumnNumber();
689 if (lineNumber == v8::Function::kLineOffsetNotFound || columnNumber == v8::F unction::kLineOffsetNotFound) 691 if (lineNumber == v8::Function::kLineOffsetNotFound || columnNumber == v8::F unction::kLineOffsetNotFound)
690 return v8::Null(m_isolate); 692 return v8::Null(m_isolate);
691 v8::Local<v8::Object> location = v8::Object::New(m_isolate); 693 v8::Local<v8::Object> location = v8::Object::New(m_isolate);
692 if (!location->Set(context, toV8StringInternalized(m_isolate, "scriptId"), t oV8String(m_isolate, String16::fromInteger(scriptId))).FromMaybe(false)) 694 if (!location->Set(context, toV8StringInternalized(m_isolate, "scriptId"), t oV8String(m_isolate, protocol::string16FromInteger(scriptId))).FromMaybe(false))
693 return v8::Null(m_isolate); 695 return v8::Null(m_isolate);
694 if (!location->Set(context, toV8StringInternalized(m_isolate, "lineNumber"), v8::Integer::New(m_isolate, lineNumber)).FromMaybe(false)) 696 if (!location->Set(context, toV8StringInternalized(m_isolate, "lineNumber"), v8::Integer::New(m_isolate, lineNumber)).FromMaybe(false))
695 return v8::Null(m_isolate); 697 return v8::Null(m_isolate);
696 if (!location->Set(context, toV8StringInternalized(m_isolate, "columnNumber" ), v8::Integer::New(m_isolate, columnNumber)).FromMaybe(false)) 698 if (!location->Set(context, toV8StringInternalized(m_isolate, "columnNumber" ), v8::Integer::New(m_isolate, columnNumber)).FromMaybe(false))
697 return v8::Null(m_isolate); 699 return v8::Null(m_isolate);
698 if (!markAsInternal(context, location, V8InternalValueType::kLocation)) 700 if (!markAsInternal(context, location, V8InternalValueType::kLocation))
699 return v8::Null(m_isolate); 701 return v8::Null(m_isolate);
700 return location; 702 return location;
701 } 703 }
702 704
703 bool V8Debugger::isPaused() 705 bool V8Debugger::isPaused()
704 { 706 {
705 return !m_pausedContext.IsEmpty(); 707 return !m_pausedContext.IsEmpty();
706 } 708 }
707 709
708 std::unique_ptr<V8StackTraceImpl> V8Debugger::createStackTrace(v8::Local<v8::Sta ckTrace> stackTrace) 710 std::unique_ptr<V8StackTraceImpl> V8Debugger::createStackTrace(v8::Local<v8::Sta ckTrace> stackTrace)
709 { 711 {
710 int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurre ntContext()) : 0; 712 int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurre ntContext()) : 0;
711 return V8StackTraceImpl::create(this, contextGroupId, stackTrace, V8StackTra ceImpl::maxCallStackSizeToCapture); 713 return V8StackTraceImpl::create(this, contextGroupId, stackTrace, V8StackTra ceImpl::maxCallStackSizeToCapture);
712 } 714 }
713 715
714 int V8Debugger::markContext(const V8ContextInfo& info) 716 int V8Debugger::markContext(const V8ContextInfo& info)
715 { 717 {
716 DCHECK(info.context->GetIsolate() == m_isolate); 718 DCHECK(info.context->GetIsolate() == m_isolate);
717 int contextId = ++m_lastContextId; 719 int contextId = ++m_lastContextId;
718 String16 debugData = String16::fromInteger(info.contextGroupId) + "," + Stri ng16::fromInteger(contextId) + "," + info.auxData; 720 String16 debugData = protocol::string16FromInteger(info.contextGroupId) + ", " + protocol::string16FromInteger(contextId) + "," + info.auxData;
719 v8::Context::Scope contextScope(info.context); 721 v8::Context::Scope contextScope(info.context);
720 info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex), toV8String(m_isolate, debugData)); 722 info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex), toV8String(m_isolate, debugData));
721 return contextId; 723 return contextId;
722 } 724 }
723 725
724 void V8Debugger::setAsyncCallStackDepth(V8DebuggerAgentImpl* agent, int depth) 726 void V8Debugger::setAsyncCallStackDepth(V8DebuggerAgentImpl* agent, int depth)
725 { 727 {
726 if (depth <= 0) 728 if (depth <= 0)
727 m_maxAsyncCallStackDepthMap.erase(agent); 729 m_maxAsyncCallStackDepthMap.erase(agent);
728 else 730 else
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 return nullptr; 819 return nullptr;
818 820
819 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1; 821 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1;
820 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId)) 822 if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId))
821 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; 823 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture;
822 824
823 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); 825 return V8StackTraceImpl::capture(this, contextGroupId, stackSize);
824 } 826 }
825 827
826 } // namespace blink 828 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698