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

Side by Side Diff: Source/devtools/front_end/SourcesSearchScope.js

Issue 216183003: DevTools: Make sure UISC content is up-to-date when running performSearchInContent() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Introduce callback array for pending requests Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
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 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 10 *
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 * @param {function()} callback 108 * @param {function()} callback
109 * @param {!Array.<string>} files 109 * @param {!Array.<string>} files
110 */ 110 */
111 _processMatchingFilesForProject: function(searchId, project, progress, callb ack, files) 111 _processMatchingFilesForProject: function(searchId, project, progress, callb ack, files)
112 { 112 {
113 if (searchId !== this._searchId) { 113 if (searchId !== this._searchId) {
114 this._searchFinishedCallback(false); 114 this._searchFinishedCallback(false);
115 return; 115 return;
116 } 116 }
117 117
118 addDirtyFiles();
119
118 if (!files.length) { 120 if (!files.length) {
119 progress.done(); 121 progress.done();
120 callback(); 122 callback();
121 return; 123 return;
122 } 124 }
123 125
124 progress.setTotalWork(files.length); 126 progress.setTotalWork(files.length);
125 127
126 var fileIndex = 0; 128 var fileIndex = 0;
127 var maxFileContentRequests = 20; 129 var maxFileContentRequests = 20;
128 var callbacksLeft = 0; 130 var callbacksLeft = 0;
129 131
130 for (var i = 0; i < maxFileContentRequests && i < files.length; ++i) 132 for (var i = 0; i < maxFileContentRequests && i < files.length; ++i)
131 scheduleSearchInNextFileOrFinish.call(this); 133 scheduleSearchInNextFileOrFinish.call(this);
132 134
135 function addDirtyFiles()
136 {
137 var matchingFiles = StringSet.fromArray(files);
138 var uiSourceCodes = project.uiSourceCodes();
139 for (var i = 0; i < uiSourceCodes.length; ++i) {
140 if (!uiSourceCodes[i].isDirty())
141 continue;
142 var path = uiSourceCodes[i].path();
143 if (!matchingFiles.contains(path))
144 files.push(path);
145 }
146 }
147
133 /** 148 /**
134 * @param {!string} path 149 * @param {!string} path
135 * @this {WebInspector.SourcesSearchScope} 150 * @this {WebInspector.SourcesSearchScope}
136 */ 151 */
137 function searchInNextFile(path) 152 function searchInNextFile(path)
138 { 153 {
139 var uiSourceCode = project.uiSourceCode(path); 154 var uiSourceCode = project.uiSourceCode(path);
140 if (!uiSourceCode) { 155 if (!uiSourceCode) {
141 --callbacksLeft; 156 --callbacksLeft;
142 progress.worked(1); 157 progress.worked(1);
143 scheduleSearchInNextFileOrFinish.call(this); 158 scheduleSearchInNextFileOrFinish.call(this);
144 return; 159 return;
145 } 160 }
146 uiSourceCode.requestContent(contentLoaded.bind(this, path)); 161 if (uiSourceCode.isDirty())
162 contentLoaded.call(this, uiSourceCode.path(), uiSourceCode.worki ngCopy());
163 else
164 uiSourceCode.checkContentUpdated(contentUpdated.bind(this, uiSou rceCode));
147 } 165 }
148 166
149 /** 167 /**
168 * @param {!WebInspector.UISourceCode} uiSourceCode
169 * @this {WebInspector.SourcesSearchScope}
170 */
171 function contentUpdated(uiSourceCode)
172 {
173 uiSourceCode.requestContent(contentLoaded.bind(this, uiSourceCode.pa th()));
174 }
175
176 /**
150 * @this {WebInspector.SourcesSearchScope} 177 * @this {WebInspector.SourcesSearchScope}
151 */ 178 */
152 function scheduleSearchInNextFileOrFinish() 179 function scheduleSearchInNextFileOrFinish()
153 { 180 {
154 if (fileIndex >= files.length) { 181 if (fileIndex >= files.length) {
155 if (!callbacksLeft) { 182 if (!callbacksLeft) {
156 progress.done(); 183 progress.done();
157 callback(); 184 callback();
158 return; 185 return;
159 } 186 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 235
209 /** 236 /**
210 * @param {!WebInspector.SearchConfig} searchConfig 237 * @param {!WebInspector.SearchConfig} searchConfig
211 * @return {!WebInspector.FileBasedSearchResultsPane} 238 * @return {!WebInspector.FileBasedSearchResultsPane}
212 */ 239 */
213 createSearchResultsPane: function(searchConfig) 240 createSearchResultsPane: function(searchConfig)
214 { 241 {
215 return new WebInspector.FileBasedSearchResultsPane(searchConfig); 242 return new WebInspector.FileBasedSearchResultsPane(searchConfig);
216 } 243 }
217 } 244 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/ResourceScriptMapping.js ('k') | Source/devtools/front_end/UISourceCode.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698