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

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: Created 6 years, 9 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 = new StringSet();
138 files.forEach(function(file) {
139 matchingFiles.put(file);
vsevik 2014/03/28 16:18:36 Can we use matchingFiles.put.bind(matchingFiles) i
apavlov 2014/03/30 13:02:09 Done.
140 });
141
142 project.uiSourceCodes().filter(dirtySourceCodeFilter).forEach(append FilePath);
143
144 /**
145 * @param {!WebInspector.UISourceCode} sourceCode
vsevik 2014/03/28 16:18:36 s/sourceCode/uiSourceCode
apavlov 2014/03/30 13:02:09 Saw sourceCode somewhere
146 */
147 function dirtySourceCodeFilter(sourceCode)
148 {
149 return sourceCode.isDirty();
150 }
151
152 /**
153 * @param {!WebInspector.UISourceCode} sourceCode
154 */
155 function appendFilePath(sourceCode)
156 {
157 var path = sourceCode.path();
158 if (!matchingFiles.contains(path))
159 files.push(path);
160 }
161 }
162
133 /** 163 /**
134 * @param {!string} path 164 * @param {!string} path
135 * @this {WebInspector.SourcesSearchScope} 165 * @this {WebInspector.SourcesSearchScope}
136 */ 166 */
137 function searchInNextFile(path) 167 function searchInNextFile(path)
138 { 168 {
139 var uiSourceCode = project.uiSourceCode(path); 169 var uiSourceCode = project.uiSourceCode(path);
140 if (!uiSourceCode) { 170 if (!uiSourceCode) {
141 --callbacksLeft; 171 --callbacksLeft;
142 progress.worked(1); 172 progress.worked(1);
143 scheduleSearchInNextFileOrFinish.call(this); 173 scheduleSearchInNextFileOrFinish.call(this);
144 return; 174 return;
145 } 175 }
146 uiSourceCode.requestContent(contentLoaded.bind(this, path)); 176 if (uiSourceCode.isDirty())
177 contentLoaded.call(this, uiSourceCode.path(), uiSourceCode.worki ngCopy());
178 else
179 uiSourceCode.checkContentUpdated(contentUpdated.bind(this, uiSou rceCode));
147 } 180 }
148 181
149 /** 182 /**
183 * @param {!WebInspector.UISourceCode} uiSourceCode
184 * @this {WebInspector.SourcesSearchScope}
185 */
186 function contentUpdated(uiSourceCode)
187 {
188 uiSourceCode.requestContent(contentLoaded.bind(this, uiSourceCode.pa th()));
189 }
190
191 /**
150 * @this {WebInspector.SourcesSearchScope} 192 * @this {WebInspector.SourcesSearchScope}
151 */ 193 */
152 function scheduleSearchInNextFileOrFinish() 194 function scheduleSearchInNextFileOrFinish()
153 { 195 {
154 if (fileIndex >= files.length) { 196 if (fileIndex >= files.length) {
155 if (!callbacksLeft) { 197 if (!callbacksLeft) {
156 progress.done(); 198 progress.done();
157 callback(); 199 callback();
158 return; 200 return;
159 } 201 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 250
209 /** 251 /**
210 * @param {!WebInspector.SearchConfig} searchConfig 252 * @param {!WebInspector.SearchConfig} searchConfig
211 * @return {!WebInspector.FileBasedSearchResultsPane} 253 * @return {!WebInspector.FileBasedSearchResultsPane}
212 */ 254 */
213 createSearchResultsPane: function(searchConfig) 255 createSearchResultsPane: function(searchConfig)
214 { 256 {
215 return new WebInspector.FileBasedSearchResultsPane(searchConfig); 257 return new WebInspector.FileBasedSearchResultsPane(searchConfig);
216 } 258 }
217 } 259 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/UISourceCode.js » ('j') | Source/devtools/front_end/UISourceCode.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698