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

Unified Diff: src/mirror-delay.js

Issue 647022: Add maxStrinLength argument to debugger requests (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/debug-delay.js ('k') | test/mjsunit/debug-evaluate.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mirror-delay.js
===================================================================
--- src/mirror-delay.js (revision 3918)
+++ src/mirror-delay.js (working copy)
@@ -553,17 +553,19 @@
return this.value_.length;
};
-
-StringMirror.prototype.toText = function() {
- if (this.length() > kMaxProtocolStringLength) {
- return this.value_.substring(0, kMaxProtocolStringLength) +
+StringMirror.prototype.getTruncatedValue = function(maxLength) {
+ if (maxLength != -1 && this.length() > maxLength) {
+ return this.value_.substring(0, maxLength) +
'... (length: ' + this.length() + ')';
- } else {
- return this.value_;
}
+ return this.value_;
}
+StringMirror.prototype.toText = function() {
+ return this.getTruncatedValue(kMaxProtocolStringLength);
+}
+
/**
* Mirror object for objects.
* @param {object} value The object reflected by this mirror
@@ -1955,6 +1957,15 @@
}
+JSONProtocolSerializer.prototype.maxStringLength_ = function() {
+ if (IS_UNDEFINED(this.options_) ||
+ IS_UNDEFINED(this.options_.maxStringLength)) {
+ return kMaxProtocolStringLength;
+ }
+ return this.options_.maxStringLength;
+}
+
+
JSONProtocolSerializer.prototype.add_ = function(mirror) {
// If this mirror is already in the list just return.
for (var i = 0; i < this.mirrors_.length; i++) {
@@ -1987,8 +1998,7 @@
o.value = mirror.value();
break;
case STRING_TYPE:
- // Limit string length.
- o.value = mirror.toText();
+ o.value = mirror.getTruncatedValue(this.maxStringLength_());
break;
case FUNCTION_TYPE:
o.name = mirror.name();
@@ -2052,11 +2062,12 @@
case STRING_TYPE:
// String values might have their value cropped to keep down size.
- if (mirror.length() > kMaxProtocolStringLength) {
- var str = mirror.value().substring(0, kMaxProtocolStringLength);
+ if (this.maxStringLength_() != -1 &&
+ mirror.length() > this.maxStringLength_()) {
+ var str = mirror.getTruncatedValue(this.maxStringLength_());
content.value = str;
content.fromIndex = 0;
- content.toIndex = kMaxProtocolStringLength;
+ content.toIndex = this.maxStringLength_();
} else {
content.value = mirror.value();
}
« no previous file with comments | « src/debug-delay.js ('k') | test/mjsunit/debug-evaluate.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698