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

Unified Diff: Source/devtools/front_end/sdk/CSSStyleModel.js

Issue 1212263002: DevTools: [CSS] migrate setStyleSheetText to promises (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: log error from first stylesheet Created 5 years, 6 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 | « Source/devtools/front_end/bindings/StylesSourceMapping.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/sdk/CSSStyleModel.js
diff --git a/Source/devtools/front_end/sdk/CSSStyleModel.js b/Source/devtools/front_end/sdk/CSSStyleModel.js
index 359c415192c44743492841d72ff4231d651a778b..d1bf067504dcdea229afc57724777e20ec780ed9 100644
--- a/Source/devtools/front_end/sdk/CSSStyleModel.js
+++ b/Source/devtools/front_end/sdk/CSSStyleModel.js
@@ -557,17 +557,18 @@ WebInspector.CSSStyleModel.prototype = {
* @param {!CSSAgent.StyleSheetId} styleSheetId
* @param {string} newText
* @param {boolean} majorChange
- * @param {?function(?Protocol.Error)} userCallback
+ * @return {!Promise.<?Protocol.Error>}
*/
- setStyleSheetText: function(styleSheetId, newText, majorChange, userCallback)
+ setStyleSheetText: function(styleSheetId, newText, majorChange)
{
var header = this._styleSheetIdToHeader.get(styleSheetId);
console.assert(header);
this._pendingCommandsMajorState.push(majorChange);
- header.setContent(newText, callback.bind(this));
+ return header._setContentPromise(newText).then(callback.bind(this));
/**
* @param {?Protocol.Error} error
+ * @return {?Protocol.Error}
* @this {WebInspector.CSSStyleModel}
*/
function callback(error)
@@ -576,8 +577,7 @@ WebInspector.CSSStyleModel.prototype = {
if (!error && majorChange)
this._domModel.markUndoableState();
- if (!error && userCallback)
- userCallback(error);
+ return error;
}
},
@@ -1807,18 +1807,18 @@ WebInspector.CSSStyleSheetHeader.prototype = {
/**
* @param {string} newText
- * @param {function(?Protocol.Error)} callback
+ * @return {!Promise.<?Protocol.Error>}
*/
- setContent: function(newText, callback)
+ _setContentPromise: function(newText)
{
newText = this._trimSourceURL(newText);
if (this.hasSourceURL)
newText += "\n/*# sourceURL=" + this.sourceURL + " */";
- this._cssModel._agent.setStyleSheetText(this.id, newText, extractProtocolError)
- .then(callback);
+ return this._cssModel._agent.setStyleSheetText(this.id, newText, extractProtocolError);
/**
* @param {?Protocol.Error} error
+ * @return {?Protocol.Error}
*/
function extractProtocolError(error)
{
@@ -1827,6 +1827,17 @@ WebInspector.CSSStyleSheetHeader.prototype = {
},
/**
+ * @param {string} newText
+ * @param {function(?Protocol.Error)} callback
+ */
+ setContent: function(newText, callback)
+ {
+ this._setContentPromise(newText)
+ .catchException(null)
+ .then(callback);
+ },
+
+ /**
* @return {boolean}
*/
isViaInspector: function()
« no previous file with comments | « Source/devtools/front_end/bindings/StylesSourceMapping.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698