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

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

Issue 144283012: DevTools: Move the fallback for not loaded resources to NetworkUISourceCodeProvider.js (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix console.assert Created 6 years, 10 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
« no previous file with comments | « no previous file | Source/devtools/front_end/Resource.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 this._addFile(header.resourceURL(), header, false); 94 this._addFile(header.resourceURL(), header, false);
95 }, 95 },
96 96
97 /** 97 /**
98 * @param {!WebInspector.Event|!{data: !WebInspector.Resource}} event 98 * @param {!WebInspector.Event|!{data: !WebInspector.Resource}} event
99 */ 99 */
100 _resourceAdded: function(event) 100 _resourceAdded: function(event)
101 { 101 {
102 var resource = /** @type {!WebInspector.Resource} */ (event.data); 102 var resource = /** @type {!WebInspector.Resource} */ (event.data);
103 this._addFile(resource.url, resource); 103 this._addFile(resource.url, new WebInspector.NetworkUISourceCodeProvider .FallbackResource(resource));
104 }, 104 },
105 105
106 /** 106 /**
107 * @param {!WebInspector.Event} event 107 * @param {!WebInspector.Event} event
108 */ 108 */
109 _mainFrameNavigated: function(event) 109 _mainFrameNavigated: function(event)
110 { 110 {
111 this._reset(); 111 this._reset();
112 }, 112 },
113 113
(...skipping 19 matching lines...) Expand all
133 133
134 _reset: function() 134 _reset: function()
135 { 135 {
136 this._processedURLs = {}; 136 this._processedURLs = {};
137 this._networkWorkspaceProvider.reset(); 137 this._networkWorkspaceProvider.reset();
138 this._populate(); 138 this._populate();
139 } 139 }
140 } 140 }
141 141
142 /** 142 /**
143 * @constructor
144 * @implements {WebInspector.ContentProvider}
145 * @param {!WebInspector.Resource} resource
146 */
147 WebInspector.NetworkUISourceCodeProvider.FallbackResource = function(resource)
148 {
149 this._resource = resource;
150 }
151
152 WebInspector.NetworkUISourceCodeProvider.FallbackResource.prototype = {
153
154 /**
155 * @return {string}
156 */
157 contentURL: function()
158 {
159 return this._resource.contentURL();
160 },
161
162 /**
163 * @return {!WebInspector.ResourceType}
164 */
165 contentType: function()
166 {
167 return this._resource.contentType();
168 },
169
170 /**
171 * @param {function(?string)} callback
172 */
173 requestContent: function(callback)
174 {
175 /**
176 * @this {WebInspector.NetworkUISourceCodeProvider.FallbackResource}
177 */
178 function loadFallbackContent()
179 {
180 var scripts = WebInspector.debuggerModel.scriptsForSourceURL(this._r esource.url);
181 if (!scripts.length) {
182 callback(null);
183 return;
184 }
185
186 var contentProvider;
187 if (this._resource.type === WebInspector.resourceTypes.Document)
188 contentProvider = new WebInspector.ConcatenatedScriptsContentPro vider(scripts);
189 else if (this._resource.type === WebInspector.resourceTypes.Script)
190 contentProvider = scripts[0];
191
192 console.assert(contentProvider, "Resource content request failed. " + this._resource.url);
193
194 contentProvider.requestContent(callback);
195 }
196
197 /**
198 * @param {?string} content
199 * @this {WebInspector.NetworkUISourceCodeProvider.FallbackResource}
200 */
201 function requestContentLoaded(content)
202 {
203 if (content)
204 callback(content)
205 else
206 loadFallbackContent.call(this);
207 }
208
209 this._resource.requestContent(requestContentLoaded.bind(this));
210 },
211
212 /**
213 * @param {string} query
214 * @param {boolean} caseSensitive
215 * @param {boolean} isRegex
216 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} cal lback
217 */
218 searchInContent: function(query, caseSensitive, isRegex, callback)
219 {
220 /**
221 * @param {?string} content
222 */
223 function documentContentLoaded(content)
224 {
225 if (content === null) {
226 callback([]);
227 return;
228 }
229
230 var result = WebInspector.ContentProvider.performSearchInContent(con tent, query, caseSensitive, isRegex);
231 callback(result);
232 }
233
234 if (this.contentType() === WebInspector.resourceTypes.Document) {
235 this.requestContent(documentContentLoaded);
236 return;
237 }
238
239 this._resource.searchInContent(query, caseSensitive, isRegex, callback);
240 }
241 }
242
243 /**
143 * @type {!WebInspector.SimpleWorkspaceProvider} 244 * @type {!WebInspector.SimpleWorkspaceProvider}
144 */ 245 */
145 WebInspector.networkWorkspaceProvider; 246 WebInspector.networkWorkspaceProvider;
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/Resource.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698