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

Side by Side Diff: src/inspector/v8-debugger-script.cc

Issue 2465553003: [inspector] added Debugger.getPossibleBreakpoints method (Closed)
Patch Set: addressed comments Created 4 years, 1 month 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
« no previous file with comments | « src/inspector/v8-debugger-script.h ('k') | test/inspector/debugger/get-possible-breakpoints.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project 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 "src/inspector/v8-debugger-script.h" 5 #include "src/inspector/v8-debugger-script.h"
6 6
7 #include "src/inspector/protocol-platform.h" 7 #include "src/inspector/protocol-platform.h"
8 #include "src/inspector/string-util.h" 8 #include "src/inspector/string-util.h"
9 9
10 namespace v8_inspector { 10 namespace v8_inspector {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 hashes[i] = (hashes[i] + zi[i] * (prime[i] - 1)) % prime[i]; 63 hashes[i] = (hashes[i] + zi[i] * (prime[i] - 1)) % prime[i];
64 64
65 String16Builder hash; 65 String16Builder hash;
66 for (size_t i = 0; i < hashesSize; ++i) appendUnsignedAsHex(hashes[i], &hash); 66 for (size_t i = 0; i < hashesSize; ++i) appendUnsignedAsHex(hashes[i], &hash);
67 return hash.toString(); 67 return hash.toString();
68 } 68 }
69 69
70 V8DebuggerScript::V8DebuggerScript(v8::Isolate* isolate, 70 V8DebuggerScript::V8DebuggerScript(v8::Isolate* isolate,
71 v8::Local<v8::DebugInterface::Script> script, 71 v8::Local<v8::DebugInterface::Script> script,
72 bool isLiveEdit) { 72 bool isLiveEdit) {
73 m_isolate = script->GetIsolate();
73 m_id = String16::fromInteger(script->Id()); 74 m_id = String16::fromInteger(script->Id());
74 v8::Local<v8::String> tmp; 75 v8::Local<v8::String> tmp;
75 if (script->Name().ToLocal(&tmp)) m_url = toProtocolString(tmp); 76 if (script->Name().ToLocal(&tmp)) m_url = toProtocolString(tmp);
76 if (script->SourceURL().ToLocal(&tmp)) { 77 if (script->SourceURL().ToLocal(&tmp)) {
77 m_sourceURL = toProtocolString(tmp); 78 m_sourceURL = toProtocolString(tmp);
78 if (m_url.isEmpty()) m_url = toProtocolString(tmp); 79 if (m_url.isEmpty()) m_url = toProtocolString(tmp);
79 } 80 }
80 if (script->SourceMappingURL().ToLocal(&tmp)) 81 if (script->SourceMappingURL().ToLocal(&tmp))
81 m_sourceMappingURL = toProtocolString(tmp); 82 m_sourceMappingURL = toProtocolString(tmp);
82 m_startLine = script->LineOffset(); 83 m_startLine = script->LineOffset();
(...skipping 23 matching lines...) Expand all
106 String16 executionContextId = 107 String16 executionContextId =
107 contextData.substring(firstComma + 1, secondComma - firstComma - 1); 108 contextData.substring(firstComma + 1, secondComma - firstComma - 1);
108 bool isOk = false; 109 bool isOk = false;
109 m_executionContextId = executionContextId.toInteger(&isOk); 110 m_executionContextId = executionContextId.toInteger(&isOk);
110 if (!isOk) m_executionContextId = 0; 111 if (!isOk) m_executionContextId = 0;
111 m_executionContextAuxData = contextData.substring(secondComma + 1); 112 m_executionContextAuxData = contextData.substring(secondComma + 1);
112 } 113 }
113 } 114 }
114 115
115 m_isLiveEdit = isLiveEdit; 116 m_isLiveEdit = isLiveEdit;
117
116 if (script->Source().ToLocal(&tmp)) { 118 if (script->Source().ToLocal(&tmp)) {
117 m_source.Reset(isolate, tmp); 119 m_source.Reset(m_isolate, tmp);
118 String16 source = toProtocolString(tmp); 120 String16 source = toProtocolString(tmp);
119 m_hash = calculateHash(source); 121 m_hash = calculateHash(source);
120 // V8 will not count last line if script source ends with \n. 122 // V8 will not count last line if script source ends with \n.
121 if (source.length() > 1 && source[source.length() - 1] == '\n') { 123 if (source.length() > 1 && source[source.length() - 1] == '\n') {
122 m_endLine++; 124 m_endLine++;
123 m_endColumn = 0; 125 m_endColumn = 0;
124 } 126 }
125 } 127 }
128
129 m_script.Reset(m_isolate, script);
126 } 130 }
127 131
128 V8DebuggerScript::~V8DebuggerScript() {} 132 V8DebuggerScript::~V8DebuggerScript() {}
129 133
130 const String16& V8DebuggerScript::sourceURL() const { 134 const String16& V8DebuggerScript::sourceURL() const {
131 return m_sourceURL.isEmpty() ? m_url : m_sourceURL; 135 return m_sourceURL.isEmpty() ? m_url : m_sourceURL;
132 } 136 }
133 137
134 v8::Local<v8::String> V8DebuggerScript::source(v8::Isolate* isolate) const { 138 v8::Local<v8::String> V8DebuggerScript::source(v8::Isolate* isolate) const {
135 return m_source.Get(isolate); 139 return m_source.Get(isolate);
136 } 140 }
137 141
138 void V8DebuggerScript::setSourceURL(const String16& sourceURL) { 142 void V8DebuggerScript::setSourceURL(const String16& sourceURL) {
139 m_sourceURL = sourceURL; 143 m_sourceURL = sourceURL;
140 } 144 }
141 145
142 void V8DebuggerScript::setSourceMappingURL(const String16& sourceMappingURL) { 146 void V8DebuggerScript::setSourceMappingURL(const String16& sourceMappingURL) {
143 m_sourceMappingURL = sourceMappingURL; 147 m_sourceMappingURL = sourceMappingURL;
144 } 148 }
145 149
146 void V8DebuggerScript::setSource(v8::Isolate* isolate, 150 void V8DebuggerScript::setSource(v8::Local<v8::String> source) {
147 v8::Local<v8::String> source) { 151 m_source.Reset(m_isolate, source);
148 m_source.Reset(isolate, source);
149 m_hash = calculateHash(toProtocolString(source)); 152 m_hash = calculateHash(toProtocolString(source));
150 } 153 }
151 154
155 bool V8DebuggerScript::getPossibleBreakpoints(
156 const v8::DebugInterface::Location& start,
157 const v8::DebugInterface::Location& end,
158 std::vector<v8::DebugInterface::Location>* locations) {
159 v8::HandleScope scope(m_isolate);
160 v8::Local<v8::DebugInterface::Script> script = m_script.Get(m_isolate);
161 return script->GetPossibleBreakpoints(start, end, locations);
162 }
163
152 } // namespace v8_inspector 164 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/v8-debugger-script.h ('k') | test/inspector/debugger/get-possible-breakpoints.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698