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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/SourceLocation.cpp

Issue 2251343003: [DevTools] Generate separate copies of inspector_protocol. (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 "bindings/core/v8/SourceLocation.h" 5 #include "bindings/core/v8/SourceLocation.h"
6 6
7 #include "bindings/core/v8/V8BindingMacros.h" 7 #include "bindings/core/v8/V8BindingMacros.h"
8 #include "bindings/core/v8/V8PerIsolateData.h" 8 #include "bindings/core/v8/V8PerIsolateData.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/ExecutionContext.h" 10 #include "core/dom/ExecutionContext.h"
11 #include "core/dom/ScriptableDocumentParser.h" 11 #include "core/dom/ScriptableDocumentParser.h"
12 #include "core/html/HTMLFrameOwnerElement.h" 12 #include "core/html/HTMLFrameOwnerElement.h"
13 #include "core/inspector/ThreadDebugger.h" 13 #include "core/inspector/ThreadDebugger.h"
14 #include "core/inspector/V8InspectorStringConversion.h"
14 #include "platform/ScriptForbiddenScope.h" 15 #include "platform/ScriptForbiddenScope.h"
15 #include "platform/TracedValue.h" 16 #include "platform/TracedValue.h"
16 #include "platform/v8_inspector/public/V8Inspector.h" 17 #include "platform/v8_inspector/public/V8Inspector.h"
17 #include "wtf/PtrUtil.h" 18 #include "wtf/PtrUtil.h"
18 #include <memory> 19 #include <memory>
19 20
20 namespace blink { 21 namespace blink {
21 22
22 namespace { 23 namespace {
23 24
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // static 97 // static
97 std::unique_ptr<SourceLocation> SourceLocation::create(const String& url, unsign ed lineNumber, unsigned columnNumber, std::unique_ptr<v8_inspector::V8StackTrace > stackTrace, int scriptId) 98 std::unique_ptr<SourceLocation> SourceLocation::create(const String& url, unsign ed lineNumber, unsigned columnNumber, std::unique_ptr<v8_inspector::V8StackTrace > stackTrace, int scriptId)
98 { 99 {
99 return wrapUnique(new SourceLocation(url, lineNumber, columnNumber, std::mov e(stackTrace), scriptId)); 100 return wrapUnique(new SourceLocation(url, lineNumber, columnNumber, std::mov e(stackTrace), scriptId));
100 } 101 }
101 102
102 // static 103 // static
103 std::unique_ptr<SourceLocation> SourceLocation::createFromNonEmptyV8StackTrace(s td::unique_ptr<v8_inspector::V8StackTrace> stackTrace, int scriptId) 104 std::unique_ptr<SourceLocation> SourceLocation::createFromNonEmptyV8StackTrace(s td::unique_ptr<v8_inspector::V8StackTrace> stackTrace, int scriptId)
104 { 105 {
105 // Retrieve the data before passing the ownership to SourceLocation. 106 // Retrieve the data before passing the ownership to SourceLocation.
106 const String& url = stackTrace->topSourceURL(); 107 const String& url = toCoreString(stackTrace->topSourceURL());
caseq 2016/08/19 02:50:36 this doesn't look good :-)
107 unsigned lineNumber = stackTrace->topLineNumber(); 108 unsigned lineNumber = stackTrace->topLineNumber();
108 unsigned columnNumber = stackTrace->topColumnNumber(); 109 unsigned columnNumber = stackTrace->topColumnNumber();
109 return wrapUnique(new SourceLocation(url, lineNumber, columnNumber, std::mov e(stackTrace), scriptId)); 110 return wrapUnique(new SourceLocation(url, lineNumber, columnNumber, std::mov e(stackTrace), scriptId));
110 } 111 }
111 112
112 // static 113 // static
113 std::unique_ptr<SourceLocation> SourceLocation::fromFunction(v8::Local<v8::Funct ion> function) 114 std::unique_ptr<SourceLocation> SourceLocation::fromFunction(v8::Local<v8::Funct ion> function)
114 { 115 {
115 if (!function.IsEmpty()) 116 if (!function.IsEmpty())
116 return SourceLocation::create(toCoreStringWithUndefinedOrNullCheck(funct ion->GetScriptOrigin().ResourceName()), function->GetScriptLineNumber() + 1, fun ction->GetScriptColumnNumber() + 1, nullptr, function->ScriptId()); 117 return SourceLocation::create(toCoreStringWithUndefinedOrNullCheck(funct ion->GetScriptOrigin().ResourceName()), function->GetScriptLineNumber() + 1, fun ction->GetScriptColumnNumber() + 1, nullptr, function->ScriptId());
(...skipping 21 matching lines...) Expand all
138 SourceLocation::~SourceLocation() 139 SourceLocation::~SourceLocation()
139 { 140 {
140 } 141 }
141 142
142 void SourceLocation::toTracedValue(TracedValue* value, const char* name) const 143 void SourceLocation::toTracedValue(TracedValue* value, const char* name) const
143 { 144 {
144 if (!m_stackTrace || m_stackTrace->isEmpty()) 145 if (!m_stackTrace || m_stackTrace->isEmpty())
145 return; 146 return;
146 value->beginArray(name); 147 value->beginArray(name);
147 value->beginDictionary(); 148 value->beginDictionary();
148 value->setString("functionName", m_stackTrace->topFunctionName()); 149 value->setString("functionName", toCoreString(m_stackTrace->topFunctionName( )));
149 value->setString("scriptId", m_stackTrace->topScriptId()); 150 value->setString("scriptId", toCoreString(m_stackTrace->topScriptId()));
150 value->setString("url", m_stackTrace->topSourceURL()); 151 value->setString("url", toCoreString(m_stackTrace->topSourceURL()));
151 value->setInteger("lineNumber", m_stackTrace->topLineNumber()); 152 value->setInteger("lineNumber", m_stackTrace->topLineNumber());
152 value->setInteger("columnNumber", m_stackTrace->topColumnNumber()); 153 value->setInteger("columnNumber", m_stackTrace->topColumnNumber());
153 value->endDictionary(); 154 value->endDictionary();
154 value->endArray(); 155 value->endArray();
155 } 156 }
156 157
157 std::unique_ptr<SourceLocation> SourceLocation::clone() const 158 std::unique_ptr<SourceLocation> SourceLocation::clone() const
158 { 159 {
159 return wrapUnique(new SourceLocation(m_url.isolatedCopy(), m_lineNumber, m_c olumnNumber, m_stackTrace ? m_stackTrace->clone() : nullptr, m_scriptId)); 160 return wrapUnique(new SourceLocation(m_url.isolatedCopy(), m_lineNumber, m_c olumnNumber, m_stackTrace ? m_stackTrace->clone() : nullptr, m_scriptId));
160 } 161 }
161 162
162 std::unique_ptr<protocol::Runtime::API::StackTrace> SourceLocation::buildInspect orObject() const 163 std::unique_ptr<v8_inspector::protocol::Runtime::API::StackTrace> SourceLocation ::buildInspectorObject() const
163 { 164 {
164 return m_stackTrace ? m_stackTrace->buildInspectorObject() : nullptr; 165 return m_stackTrace ? m_stackTrace->buildInspectorObject() : nullptr;
165 } 166 }
166 167
167 String SourceLocation::toString() const 168 String SourceLocation::toString() const
168 { 169 {
169 if (!m_stackTrace) 170 if (!m_stackTrace)
170 return String(); 171 return String();
171 return m_stackTrace->toString(); 172 return toCoreString(m_stackTrace->toString());
172 } 173 }
173 174
174 } // namespace blink 175 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698