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

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

Issue 23484056: [DevTools] Renaming Scripts panel to Sources panel (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Modified missed files Created 7 years, 3 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
(Empty)
1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC.
20 * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 /**
30 * @constructor
31 * @implements {WebInspector.SearchScope}
32 * @param {WebInspector.Workspace} workspace
33 */
34 WebInspector.ScriptsSearchScope = function(workspace)
35 {
36 // FIXME: Add title once it is used by search controller.
37 WebInspector.SearchScope.call(this)
38 this._searchId = 0;
39 this._workspace = workspace;
40 }
41
42 WebInspector.ScriptsSearchScope.prototype = {
43 /**
44 * @param {WebInspector.Progress} progress
45 * @param {function(boolean)} indexingFinishedCallback
46 */
47 performIndexing: function(progress, indexingFinishedCallback)
48 {
49 this.stopSearch();
50
51 function filterOutServiceProjects(project)
52 {
53 return !project.isServiceProject();
54 }
55
56 var projects = this._workspace.projects().filter(filterOutServiceProject s);
57 var barrier = new CallbackBarrier();
58 var compositeProgress = new WebInspector.CompositeProgress(progress);
59 progress.addEventListener(WebInspector.Progress.Events.Canceled, indexin gCanceled.bind(this));
60 for (var i = 0; i < projects.length; ++i) {
61 var project = projects[i];
62 var projectProgress = compositeProgress.createSubProgress(project.ui SourceCodes().length);
63 project.indexContent(projectProgress, barrier.createCallback());
64 }
65 barrier.callWhenDone(indexingFinishedCallback.bind(this, true));
66
67 function indexingCanceled()
68 {
69 indexingFinishedCallback(false);
70 progress.done();
71 }
72 },
73
74 /**
75 * @param {WebInspector.SearchConfig} searchConfig
76 * @param {WebInspector.Progress} progress
77 * @param {function(WebInspector.FileBasedSearchResultsPane.SearchResult)} s earchResultCallback
78 * @param {function(boolean)} searchFinishedCallback
79 */
80 performSearch: function(searchConfig, progress, searchResultCallback, search FinishedCallback)
81 {
82 this.stopSearch();
83
84 /**
85 * @param {WebInspector.Project} project
86 */
87 function filterOutServiceProjects(project)
88 {
89 return !project.isServiceProject();
90 }
91
92 var projects = this._workspace.projects().filter(filterOutServiceProject s);
93 var barrier = new CallbackBarrier();
94 var compositeProgress = new WebInspector.CompositeProgress(progress);
95 for (var i = 0; i < projects.length; ++i) {
96 var project = projects[i];
97 var projectProgress = compositeProgress.createSubProgress(project.ui SourceCodes().length);
98 var callback = barrier.createCallback(searchCallbackWrapper.bind(thi s, this._searchId, project));
99 project.searchInContent(searchConfig.query, !searchConfig.ignoreCase , searchConfig.isRegex, projectProgress, callback);
100 }
101 barrier.callWhenDone(searchFinishedCallback.bind(this, true));
102
103 /**
104 * @param {number} searchId
105 * @param {WebInspector.Project} project
106 * @param {StringMap} searchMatches
107 */
108 function searchCallbackWrapper(searchId, project, searchMatches)
109 {
110 if (searchId !== this._searchId) {
111 searchFinishedCallback(false);
112 return;
113 }
114 var paths = searchMatches.keys();
115 for (var i = 0; i < paths.length; ++i) {
116 var uiSourceCode = project.uiSourceCode(paths[i]);
117 var searchResult = new WebInspector.FileBasedSearchResultsPane.S earchResult(uiSourceCode, searchMatches.get(paths[i]));
118 searchResultCallback(searchResult);
119 }
120 }
121 },
122
123 stopSearch: function()
124 {
125 ++this._searchId;
126 },
127
128 /**
129 * @param {WebInspector.SearchConfig} searchConfig
130 */
131 createSearchResultsPane: function(searchConfig)
132 {
133 return new WebInspector.FileBasedSearchResultsPane(searchConfig);
134 },
135
136 __proto__: WebInspector.SearchScope.prototype
137 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/ScriptsPanelDescriptor.js ('k') | Source/devtools/front_end/SourcesNavigator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698