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

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

Issue 2588503002: DevTools: Cache the original content on UISourceCode (Closed)
Patch Set: Move logic to the project level Created 3 years, 12 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 * @param {!Workspace.UISourceCode} uiSourceCode 53 * @param {!Workspace.UISourceCode} uiSourceCode
54 * @param {function(?string)} callback 54 * @param {function(?string)} callback
55 */ 55 */
56 requestFileContent(uiSourceCode, callback) { 56 requestFileContent(uiSourceCode, callback) {
57 var contentProvider = this._contentProviders[uiSourceCode.url()]; 57 var contentProvider = this._contentProviders[uiSourceCode.url()];
58 contentProvider.requestContent().then(callback); 58 contentProvider.requestContent().then(callback);
59 } 59 }
60 60
61 /** 61 /**
62 * @override 62 * @override
63 * @param {!Workspace.UISourceCode} uiSourceCode
64 * @return {!Promise<?string>}
65 */
66 requestOriginalFileContent(uiSourceCode) {
67 var fulfill;
68 var promise = new Promise(x => fulfill = x);
69 this.requestFileContent(uiSourceCode, fulfill);
70 return promise;
71 }
72
73 /**
74 * @override
63 * @return {boolean} 75 * @return {boolean}
64 */ 76 */
65 isServiceProject() { 77 isServiceProject() {
66 return this._isServiceProject; 78 return this._isServiceProject;
67 } 79 }
68 80
69 /** 81 /**
70 * @override 82 * @override
71 * @param {!Workspace.UISourceCode} uiSourceCode 83 * @param {!Workspace.UISourceCode} uiSourceCode
72 * @return {!Promise<?Workspace.UISourceCodeMetadata>} 84 * @return {!Promise<?Workspace.UISourceCodeMetadata>}
73 */ 85 */
74 requestMetadata(uiSourceCode) { 86 requestMetadata(uiSourceCode) {
75 return Promise.resolve(uiSourceCode[Bindings.ContentProviderBasedProject._me tadata]); 87 return Promise.resolve(uiSourceCode[Bindings.ContentProviderBasedProject._me tadata]);
76 } 88 }
77 89
78 /** 90 /**
79 * @override 91 * @override
80 * @return {boolean} 92 * @return {boolean}
81 */ 93 */
82 canSetFileContent() { 94 canSetFileContent() {
83 return false; 95 return false;
84 } 96 }
85 97
86 /** 98 /**
87 * @override 99 * @override
88 * @param {!Workspace.UISourceCode} uiSourceCode 100 * @param {!Workspace.UISourceCode} uiSourceCode
89 * @param {string} newContent 101 * @param {string} newContent
90 * @param {function(?string)} callback 102 * @param {function()} callback
91 */ 103 */
92 setFileContent(uiSourceCode, newContent, callback) { 104 setFileContent(uiSourceCode, newContent, callback) {
93 callback(null); 105 callback();
94 } 106 }
95 107
96 /** 108 /**
97 * @override 109 * @override
98 * @return {boolean} 110 * @return {boolean}
99 */ 111 */
100 canRename() { 112 canRename() {
101 return false; 113 return false;
102 } 114 }
103 115
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 this.workspace().addProject(this); 311 this.workspace().addProject(this);
300 } 312 }
301 313
302 dispose() { 314 dispose() {
303 this._contentProviders = {}; 315 this._contentProviders = {};
304 this.removeProject(); 316 this.removeProject();
305 } 317 }
306 }; 318 };
307 319
308 Bindings.ContentProviderBasedProject._metadata = Symbol('ContentProviderBasedPro ject.Metadata'); 320 Bindings.ContentProviderBasedProject._metadata = Symbol('ContentProviderBasedPro ject.Metadata');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698