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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/network/JSONView.js

Issue 2570263002: DevTools: introduce API for the Common.FormatterWorkerPool. (Closed)
Patch Set: address comments Created 4 years 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 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 /** 69 /**
70 * @param {?string} text 70 * @param {?string} text
71 * @return {!Promise<?Network.ParsedJSON>} 71 * @return {!Promise<?Network.ParsedJSON>}
72 */ 72 */
73 static parseJSON(text) { 73 static parseJSON(text) {
74 var returnObj = null; 74 var returnObj = null;
75 if (text) 75 if (text)
76 returnObj = Network.JSONView._extractJSON(/** @type {string} */ (text)); 76 returnObj = Network.JSONView._extractJSON(/** @type {string} */ (text));
77 if (!returnObj) 77 if (!returnObj)
78 return Promise.resolve(/** @type {?Network.ParsedJSON} */ (null)); 78 return Promise.resolve(/** @type {?Network.ParsedJSON} */ (null));
79 return Common.formatterWorkerPool.runTask('relaxedJSONParser', {content: ret urnObj.data}).then(handleReturnedJSON); 79 return Common.formatterWorkerPool.parseJSONRelaxed(returnObj.data).then(hand leReturnedJSON);
80 80
81 /** 81 /**
82 * @param {?MessageEvent} event 82 * @param {*} data
83 * @return {?Network.ParsedJSON} 83 * @return {?Network.ParsedJSON}
84 */ 84 */
85 function handleReturnedJSON(event) { 85 function handleReturnedJSON(data) {
86 if (!event || !event.data) 86 if (!data)
87 return null; 87 return null;
88 returnObj.data = event.data; 88 returnObj.data = data;
89 return returnObj; 89 return returnObj;
90 } 90 }
91 } 91 }
92 92
93 /** 93 /**
94 * @param {string} text 94 * @param {string} text
95 * @return {?Network.ParsedJSON} 95 * @return {?Network.ParsedJSON}
96 */ 96 */
97 static _extractJSON(text) { 97 static _extractJSON(text) {
98 // Do not treat HTML as JSON. 98 // Do not treat HTML as JSON.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 * @param {*} data 290 * @param {*} data
291 * @param {string} prefix 291 * @param {string} prefix
292 * @param {string} suffix 292 * @param {string} suffix
293 */ 293 */
294 constructor(data, prefix, suffix) { 294 constructor(data, prefix, suffix) {
295 this.data = data; 295 this.data = data;
296 this.prefix = prefix; 296 this.prefix = prefix;
297 this.suffix = suffix; 297 this.suffix = suffix;
298 } 298 }
299 }; 299 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698