Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 /** @type {!Multimap<string, !Workspace.UISourceCode.LineMarker>} */ | 61 /** @type {!Multimap<string, !Workspace.UISourceCode.LineMarker>} */ |
| 62 this._decorations = new Multimap(); | 62 this._decorations = new Multimap(); |
| 63 | 63 |
| 64 /** @type {!Array.<!Workspace.Revision>} */ | 64 /** @type {!Array.<!Workspace.Revision>} */ |
| 65 this.history = []; | 65 this.history = []; |
| 66 | 66 |
| 67 /** @type {!Array<!Workspace.UISourceCode.Message>} */ | 67 /** @type {!Array<!Workspace.UISourceCode.Message>} */ |
| 68 this._messages = []; | 68 this._messages = []; |
| 69 | 69 |
| 70 this._contentLoaded = false; | 70 this._contentLoaded = false; |
| 71 /** @type {?Promise<?string>} */ | |
| 72 this._originalContentPromise = null; | |
| 71 /** @type {?string} */ | 73 /** @type {?string} */ |
| 72 this._content = null; | 74 this._content = null; |
| 73 this._forceLoadOnCheckContent = false; | 75 this._forceLoadOnCheckContent = false; |
| 74 this._checkingContent = false; | 76 this._checkingContent = false; |
| 75 /** @type {?string} */ | 77 /** @type {?string} */ |
| 76 this._lastAcceptedContent = null; | 78 this._lastAcceptedContent = null; |
| 77 /** @type {?string} */ | 79 /** @type {?string} */ |
| 78 this._workingCopy = null; | 80 this._workingCopy = null; |
| 79 /** @type {?function() : string} */ | 81 /** @type {?function() : string} */ |
| 80 this._workingCopyGetter = null; | 82 this._workingCopyGetter = null; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 } | 284 } |
| 283 | 285 |
| 284 forceLoadOnCheckContent() { | 286 forceLoadOnCheckContent() { |
| 285 this._forceLoadOnCheckContent = true; | 287 this._forceLoadOnCheckContent = true; |
| 286 } | 288 } |
| 287 | 289 |
| 288 /** | 290 /** |
| 289 * @return {!Promise<?string>} | 291 * @return {!Promise<?string>} |
| 290 */ | 292 */ |
| 291 requestOriginalContent() { | 293 requestOriginalContent() { |
| 292 var callback; | 294 if (this._originalContentPromise) |
| 293 var promise = new Promise(fulfill => callback = fulfill); | 295 return this._originalContentPromise; |
| 294 this._project.requestFileContent(this, callback); | 296 var fulfill; |
| 295 return promise; | 297 this._originalContentPromise = new Promise(x => fulfill = x); |
| 298 this._project.requestFileContent(this, fulfill); | |
| 299 return this._originalContentPromise; | |
| 296 } | 300 } |
| 297 | 301 |
| 298 /** | 302 /** |
| 299 * @param {string} content | 303 * @param {string} content |
| 300 */ | 304 */ |
| 301 _commitContent(content) { | 305 _commitContent(content) { |
| 302 if (this._project.canSetFileContent()) { | 306 if (this._project.canSetFileContent()) { |
| 303 this._project.setFileContent(this, content, function() {}); | 307 // Cache the original content before we overwrite it. |
| 308 this.requestOriginalContent().then(() => this._project.setFileContent(this , content, function() {})); | |
|
lushnikov
2016/12/20 01:05:23
this should be in filesystemworkspacebindings
| |
| 304 } else if (this._url && Workspace.fileManager.isURLSaved(this._url)) { | 309 } else if (this._url && Workspace.fileManager.isURLSaved(this._url)) { |
| 305 Workspace.fileManager.save(this._url, content, false, function() {}); | 310 Workspace.fileManager.save(this._url, content, false, function() {}); |
| 306 Workspace.fileManager.close(this._url); | 311 Workspace.fileManager.close(this._url); |
| 307 } | 312 } |
| 308 this._contentCommitted(content, true); | 313 this._contentCommitted(content, true); |
| 309 } | 314 } |
| 310 | 315 |
| 311 /** | 316 /** |
| 312 * @param {string} content | 317 * @param {string} content |
| 313 * @param {boolean} committedByUser | 318 * @param {boolean} committedByUser |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 907 Workspace.UISourceCodeMetadata = class { | 912 Workspace.UISourceCodeMetadata = class { |
| 908 /** | 913 /** |
| 909 * @param {?Date} modificationTime | 914 * @param {?Date} modificationTime |
| 910 * @param {?number} contentSize | 915 * @param {?number} contentSize |
| 911 */ | 916 */ |
| 912 constructor(modificationTime, contentSize) { | 917 constructor(modificationTime, contentSize) { |
| 913 this.modificationTime = modificationTime; | 918 this.modificationTime = modificationTime; |
| 914 this.contentSize = contentSize; | 919 this.contentSize = contentSize; |
| 915 } | 920 } |
| 916 }; | 921 }; |
| OLD | NEW |