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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/FileSystemWorkspaceBinding.js

Issue 2417083002: DevTools: introduce WI.UISourceCode.requestMetadata() (Closed)
Patch Set: nits Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 var id = WebInspector.FileSystemWorkspaceBinding.projectId(this._fileSystemP ath); 200 var id = WebInspector.FileSystemWorkspaceBinding.projectId(this._fileSystemP ath);
201 console.assert(!workspace.project(id)); 201 console.assert(!workspace.project(id));
202 202
203 var displayName = this._fileSystemPath.substr(this._fileSystemPath.lastIndex Of("/") + 1); 203 var displayName = this._fileSystemPath.substr(this._fileSystemPath.lastIndex Of("/") + 1);
204 WebInspector.ProjectStore.call(this, workspace, id, WebInspector.projectType s.FileSystem, displayName); 204 WebInspector.ProjectStore.call(this, workspace, id, WebInspector.projectType s.FileSystem, displayName);
205 205
206 workspace.addProject(this); 206 workspace.addProject(this);
207 this.populate(); 207 this.populate();
208 } 208 }
209 209
210 WebInspector.FileSystemWorkspaceBinding._metadata = Symbol("FileSystemWorkspaceB inding.Metadata");
211
210 WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = { 212 WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = {
211 /** 213 /**
212 * @return {string} 214 * @return {string}
213 */ 215 */
214 fileSystemPath: function() 216 fileSystemPath: function()
215 { 217 {
216 return this._fileSystemPath; 218 return this._fileSystemPath;
217 }, 219 },
218 220
219 /** 221 /**
220 * @param {!WebInspector.UISourceCode} uiSourceCode 222 * @param {!WebInspector.UISourceCode} uiSourceCode
221 * @return {string} 223 * @return {string}
222 */ 224 */
223 _filePathForUISourceCode: function(uiSourceCode) 225 _filePathForUISourceCode: function(uiSourceCode)
224 { 226 {
225 return uiSourceCode.url().substring(this._fileSystemPath.length); 227 return uiSourceCode.url().substring(this._fileSystemPath.length);
226 }, 228 },
227 229
228 /** 230 /**
229 * @override 231 * @override
230 * @param {!WebInspector.UISourceCode} uiSourceCode 232 * @param {!WebInspector.UISourceCode} uiSourceCode
233 * @return {!Promise<?WebInspector.UISourceCodeMetadata>}
234 */
235 requestMetadata: function(uiSourceCode)
236 {
237 if (uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadata])
238 return uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadat a];
239 var relativePath = this._filePathForUISourceCode(uiSourceCode);
240 var promise = this._fileSystem.getMetadata(relativePath)
241 .then(onMetadata);
dgozman 2016/10/14 03:35:26 nit: move to the previous line
lushnikov 2016/10/14 05:45:32 Done.
242 uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadata] = promis e;
243 return promise;
244
245 /**
246 * @param {?{modificationTime: !Date, size: number}} metadata
247 * @return {?WebInspector.UISourceCodeMetadata}
248 */
249 function onMetadata(metadata)
250 {
251 if (!metadata)
252 return null;
253 return new WebInspector.UISourceCodeMetadata(metadata.modificationTi me, metadata.size);
254 }
255 },
256
257 /**
258 * @override
259 * @param {!WebInspector.UISourceCode} uiSourceCode
231 * @param {function(?string)} callback 260 * @param {function(?string)} callback
232 */ 261 */
233 requestFileContent: function(uiSourceCode, callback) 262 requestFileContent: function(uiSourceCode, callback)
234 { 263 {
235 var filePath = this._filePathForUISourceCode(uiSourceCode); 264 var filePath = this._filePathForUISourceCode(uiSourceCode);
236 var isImage = WebInspector.FileSystemWorkspaceBinding._imageExtensions.h as(WebInspector.ParsedURL.extractExtension(filePath)); 265 var isImage = WebInspector.FileSystemWorkspaceBinding._imageExtensions.h as(WebInspector.ParsedURL.extractExtension(filePath));
237 266
238 this._fileSystem.requestFileContent(filePath, isImage ? base64CallbackWr apper : callback); 267 this._fileSystem.requestFileContent(filePath, isImage ? base64CallbackWr apper : callback);
239 268
240 /** 269 /**
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 * @param {string} path 555 * @param {string} path
527 */ 556 */
528 _fileChanged: function(path) 557 _fileChanged: function(path)
529 { 558 {
530 var uiSourceCode = this.uiSourceCodeForURL(path); 559 var uiSourceCode = this.uiSourceCodeForURL(path);
531 if (!uiSourceCode) { 560 if (!uiSourceCode) {
532 var contentType = WebInspector.FileSystemWorkspaceBinding._contentTy peForExtension(this._extensionForPath(path)); 561 var contentType = WebInspector.FileSystemWorkspaceBinding._contentTy peForExtension(this._extensionForPath(path));
533 this.addUISourceCode(this.createUISourceCode(path, contentType)); 562 this.addUISourceCode(this.createUISourceCode(path, contentType));
534 return; 563 return;
535 } 564 }
565 uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadata] = null;
536 uiSourceCode.checkContentUpdated(); 566 uiSourceCode.checkContentUpdated();
537 }, 567 },
538 568
539 dispose: function() 569 dispose: function()
540 { 570 {
541 this.removeProject(); 571 this.removeProject();
542 }, 572 },
543 573
544 __proto__: WebInspector.ProjectStore.prototype 574 __proto__: WebInspector.ProjectStore.prototype
545 } 575 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698