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

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

Issue 2417083002: DevTools: introduce WI.UISourceCode.requestMetadata() (Closed)
Patch Set: normalize test + address nit 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).then(onMetadata );
241 uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadata] = promis e;
242 return promise;
243
244 /**
245 * @param {?{modificationTime: !Date, size: number}} metadata
246 * @return {?WebInspector.UISourceCodeMetadata}
247 */
248 function onMetadata(metadata)
249 {
250 if (!metadata)
251 return null;
252 return new WebInspector.UISourceCodeMetadata(metadata.modificationTi me, metadata.size);
253 }
254 },
255
256 /**
257 * @override
258 * @param {!WebInspector.UISourceCode} uiSourceCode
231 * @param {function(?string)} callback 259 * @param {function(?string)} callback
232 */ 260 */
233 requestFileContent: function(uiSourceCode, callback) 261 requestFileContent: function(uiSourceCode, callback)
234 { 262 {
235 var filePath = this._filePathForUISourceCode(uiSourceCode); 263 var filePath = this._filePathForUISourceCode(uiSourceCode);
236 var isImage = WebInspector.FileSystemWorkspaceBinding._imageExtensions.h as(WebInspector.ParsedURL.extractExtension(filePath)); 264 var isImage = WebInspector.FileSystemWorkspaceBinding._imageExtensions.h as(WebInspector.ParsedURL.extractExtension(filePath));
237 265
238 this._fileSystem.requestFileContent(filePath, isImage ? base64CallbackWr apper : callback); 266 this._fileSystem.requestFileContent(filePath, isImage ? base64CallbackWr apper : callback);
239 267
240 /** 268 /**
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 * @param {string} path 554 * @param {string} path
527 */ 555 */
528 _fileChanged: function(path) 556 _fileChanged: function(path)
529 { 557 {
530 var uiSourceCode = this.uiSourceCodeForURL(path); 558 var uiSourceCode = this.uiSourceCodeForURL(path);
531 if (!uiSourceCode) { 559 if (!uiSourceCode) {
532 var contentType = WebInspector.FileSystemWorkspaceBinding._contentTy peForExtension(this._extensionForPath(path)); 560 var contentType = WebInspector.FileSystemWorkspaceBinding._contentTy peForExtension(this._extensionForPath(path));
533 this.addUISourceCode(this.createUISourceCode(path, contentType)); 561 this.addUISourceCode(this.createUISourceCode(path, contentType));
534 return; 562 return;
535 } 563 }
564 uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadata] = null;
536 uiSourceCode.checkContentUpdated(); 565 uiSourceCode.checkContentUpdated();
537 }, 566 },
538 567
539 dispose: function() 568 dispose: function()
540 { 569 {
541 this.removeProject(); 570 this.removeProject();
542 }, 571 },
543 572
544 __proto__: WebInspector.ProjectStore.prototype 573 __proto__: WebInspector.ProjectStore.prototype
545 } 574 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698