OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 }, | 304 }, |
305 | 305 |
306 | 306 |
307 _innerRequestContent: function() | 307 _innerRequestContent: function() |
308 { | 308 { |
309 if (this._contentRequested) | 309 if (this._contentRequested) |
310 return; | 310 return; |
311 this._contentRequested = true; | 311 this._contentRequested = true; |
312 | 312 |
313 /** | 313 /** |
314 * @param {?Protocol.Error} error | |
315 * @param {string} content | 314 * @param {string} content |
316 * @param {boolean} contentEncoded | 315 * @param {boolean} contentEncoded |
317 */ | 316 */ |
318 function callback(error, content, contentEncoded) | 317 function contentLoaded(content, contentEncoded) |
319 { | 318 { |
320 this._content = error ? null : content; | 319 this._content = content; |
321 this._contentEncoded = contentEncoded; | 320 this._contentEncoded = contentEncoded; |
322 var callbacks = this._pendingContentCallbacks.slice(); | 321 var callbacks = this._pendingContentCallbacks.slice(); |
323 for (var i = 0; i < callbacks.length; ++i) | 322 for (var i = 0; i < callbacks.length; ++i) |
324 callbacks[i](this._content, this._contentEncoded, this.canonical
MimeType()); | 323 callbacks[i](this._content, this._contentEncoded, this.canonical
MimeType()); |
325 this._pendingContentCallbacks.length = 0; | 324 this._pendingContentCallbacks.length = 0; |
326 delete this._contentRequested; | 325 delete this._contentRequested; |
327 } | 326 } |
328 PageAgent.getResourceContent(this.frameId, this.url, callback.bind(this)
); | 327 |
| 328 /** |
| 329 * @param {?Protocol.Error} error |
| 330 * @param {string} content |
| 331 * @param {boolean} contentEncoded |
| 332 */ |
| 333 function resourceContentLoaded(error, content, contentEncoded) |
| 334 { |
| 335 if (error) |
| 336 console.error("Resource content request failed: " + error); |
| 337 contentLoaded.call(this, error ? null : content, contentEncoded); |
| 338 } |
| 339 |
| 340 if (this.request) { |
| 341 /** |
| 342 * @param {string} content |
| 343 * @param {boolean} contentEncoded |
| 344 * @param {string} mimeType |
| 345 */ |
| 346 function requestContentLoaded(content, contentEncoded, mimeType) |
| 347 { |
| 348 contentLoaded.call(this, content, contentEncoded); |
| 349 } |
| 350 |
| 351 this.request.requestContent(requestContentLoaded.bind(this)); |
| 352 return; |
| 353 } |
| 354 PageAgent.getResourceContent(this.frameId, this.url, resourceContentLoad
ed.bind(this)); |
329 }, | 355 }, |
330 | 356 |
331 /** | 357 /** |
332 * @return {boolean} | 358 * @return {boolean} |
333 */ | 359 */ |
334 isHidden: function() | 360 isHidden: function() |
335 { | 361 { |
336 return !!this._isHidden; | 362 return !!this._isHidden; |
337 } | 363 } |
338 } | 364 } |
339 | 365 |
340 WebInspector.Resource.prototype.__proto__ = WebInspector.Object.prototype; | 366 WebInspector.Resource.prototype.__proto__ = WebInspector.Object.prototype; |
341 | 367 |
OLD | NEW |