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

Unified Diff: third_party/WebKit/Source/devtools/front_end/network/HARWriter.js

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/network/HARWriter.js
diff --git a/third_party/WebKit/Source/devtools/front_end/network/HARWriter.js b/third_party/WebKit/Source/devtools/front_end/network/HARWriter.js
index afa3eacef078655be98a279d969f73361b936206..564df988f38261ef2482e0a3b86b411f08a65b7e 100644
--- a/third_party/WebKit/Source/devtools/front_end/network/HARWriter.js
+++ b/third_party/WebKit/Source/devtools/front_end/network/HARWriter.js
@@ -27,97 +27,87 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
/**
- * @constructor
+ * @unrestricted
*/
-WebInspector.HARWriter = function()
-{
-};
-
-WebInspector.HARWriter.prototype = {
- /**
- * @param {!WebInspector.OutputStream} stream
- * @param {!Array.<!WebInspector.NetworkRequest>} requests
- * @param {!WebInspector.Progress} progress
- */
- write: function(stream, requests, progress)
- {
- this._stream = stream;
- this._harLog = (new WebInspector.HARLog(requests)).build();
- this._pendingRequests = 1; // Guard against completing resource transfer before all requests are made.
- var entries = this._harLog.entries;
- for (var i = 0; i < entries.length; ++i) {
- var content = requests[i].content;
- if (typeof content === "undefined" && requests[i].finished) {
- ++this._pendingRequests;
- requests[i].requestContent().then(this._onContentAvailable.bind(this, entries[i], requests[i]));
- } else if (content !== null)
- this._setEntryContent(entries[i], requests[i]);
- }
- var compositeProgress = new WebInspector.CompositeProgress(progress);
- this._writeProgress = compositeProgress.createSubProgress();
- if (--this._pendingRequests) {
- this._requestsProgress = compositeProgress.createSubProgress();
- this._requestsProgress.setTitle(WebInspector.UIString("Collecting content…"));
- this._requestsProgress.setTotalWork(this._pendingRequests);
- } else
- this._beginWrite();
- },
+WebInspector.HARWriter = class {
+ /**
+ * @param {!WebInspector.OutputStream} stream
+ * @param {!Array.<!WebInspector.NetworkRequest>} requests
+ * @param {!WebInspector.Progress} progress
+ */
+ write(stream, requests, progress) {
+ this._stream = stream;
+ this._harLog = (new WebInspector.HARLog(requests)).build();
+ this._pendingRequests = 1; // Guard against completing resource transfer before all requests are made.
+ var entries = this._harLog.entries;
+ for (var i = 0; i < entries.length; ++i) {
+ var content = requests[i].content;
+ if (typeof content === 'undefined' && requests[i].finished) {
+ ++this._pendingRequests;
+ requests[i].requestContent().then(this._onContentAvailable.bind(this, entries[i], requests[i]));
+ } else if (content !== null)
+ this._setEntryContent(entries[i], requests[i]);
+ }
+ var compositeProgress = new WebInspector.CompositeProgress(progress);
+ this._writeProgress = compositeProgress.createSubProgress();
+ if (--this._pendingRequests) {
+ this._requestsProgress = compositeProgress.createSubProgress();
+ this._requestsProgress.setTitle(WebInspector.UIString('Collecting content…'));
+ this._requestsProgress.setTotalWork(this._pendingRequests);
+ } else
+ this._beginWrite();
+ }
- /**
- * @param {!Object} entry
- * @param {!WebInspector.NetworkRequest} request
- */
- _setEntryContent: function(entry, request)
- {
- if (request.content !== null)
- entry.response.content.text = request.content;
- if (request.contentEncoded)
- entry.response.content.encoding = "base64";
- },
+ /**
+ * @param {!Object} entry
+ * @param {!WebInspector.NetworkRequest} request
+ */
+ _setEntryContent(entry, request) {
+ if (request.content !== null)
+ entry.response.content.text = request.content;
+ if (request.contentEncoded)
+ entry.response.content.encoding = 'base64';
+ }
- /**
- * @param {!Object} entry
- * @param {!WebInspector.NetworkRequest} request
- * @param {?string} content
- */
- _onContentAvailable: function(entry, request, content)
- {
- this._setEntryContent(entry, request);
- if (this._requestsProgress)
- this._requestsProgress.worked();
- if (!--this._pendingRequests) {
- this._requestsProgress.done();
- this._beginWrite();
- }
- },
+ /**
+ * @param {!Object} entry
+ * @param {!WebInspector.NetworkRequest} request
+ * @param {?string} content
+ */
+ _onContentAvailable(entry, request, content) {
+ this._setEntryContent(entry, request);
+ if (this._requestsProgress)
+ this._requestsProgress.worked();
+ if (!--this._pendingRequests) {
+ this._requestsProgress.done();
+ this._beginWrite();
+ }
+ }
- _beginWrite: function()
- {
- const jsonIndent = 2;
- this._text = JSON.stringify({log: this._harLog}, null, jsonIndent);
- this._writeProgress.setTitle(WebInspector.UIString("Writing file…"));
- this._writeProgress.setTotalWork(this._text.length);
- this._bytesWritten = 0;
- this._writeNextChunk(this._stream);
- },
+ _beginWrite() {
+ const jsonIndent = 2;
+ this._text = JSON.stringify({log: this._harLog}, null, jsonIndent);
+ this._writeProgress.setTitle(WebInspector.UIString('Writing file…'));
+ this._writeProgress.setTotalWork(this._text.length);
+ this._bytesWritten = 0;
+ this._writeNextChunk(this._stream);
+ }
- /**
- * @param {!WebInspector.OutputStream} stream
- * @param {string=} error
- */
- _writeNextChunk: function(stream, error)
- {
- if (this._bytesWritten >= this._text.length || error) {
- stream.close();
- this._writeProgress.done();
- return;
- }
- const chunkSize = 100000;
- var text = this._text.substring(this._bytesWritten, this._bytesWritten + chunkSize);
- this._bytesWritten += text.length;
- stream.write(text, this._writeNextChunk.bind(this));
- this._writeProgress.setWorked(this._bytesWritten);
+ /**
+ * @param {!WebInspector.OutputStream} stream
+ * @param {string=} error
+ */
+ _writeNextChunk(stream, error) {
+ if (this._bytesWritten >= this._text.length || error) {
+ stream.close();
+ this._writeProgress.done();
+ return;
}
+ const chunkSize = 100000;
+ var text = this._text.substring(this._bytesWritten, this._bytesWritten + chunkSize);
+ this._bytesWritten += text.length;
+ stream.write(text, this._writeNextChunk.bind(this));
+ this._writeProgress.setWorked(this._bytesWritten);
+ }
};

Powered by Google App Engine
This is Rietveld 408576698