Lines Matching defs:this

2 // Use of this source code is governed by a BSD-style license that can be
22 this.id_ = id;
28 this.cache_ = cache;
34 this.request_ = request;
40 this.sendResponse_ = callback;
47 this.image_ = new Image();
54 this.contentType_ = null;
61 this.xhr_ = new XMLHttpRequest();
68 this.canvas_ = document.createElement('canvas');
74 this.context_ = this.canvas_.getContext('2d');
81 this.downloadCallback_ = null;
89 return this.id_;
99 return (this.request_.priority !== undefined) ? this.request_.priority : 2;
109 this.loadFromCache_(
111 this.sendImageData_(data);
113 }.bind(this),
122 if (this.downloadCallback_)
125 this.downloadCallback_ = callback;
126 this.downloadOriginal_(this.onImageLoad_.bind(this),
127 this.onImageError_.bind(this));
138 var cacheKey = Cache.createKey(this.request_);
140 if (!this.request_.cache) {
141 // Cache is disabled for this request; therefore, remove it from cache
143 this.cache_.removeImage(cacheKey);
148 if (!this.request_.timestamp) {
154 this.cache_.loadImage(cacheKey,
155 this.request_.timestamp,
167 if (!this.request_.cache || !this.request_.timestamp) {
172 var cacheKey = Cache.createKey(this.request_);
173 this.cache_.saveImage(cacheKey,
175 this.request_.timestamp);
186 this.image_.onload = onSuccess;
187 this.image_.onerror = onFailure;
190 var dataUrlMatches = this.request_.url.match(/^data:([^,;]*)[,;]/);
192 this.image_.src = this.request_.url;
193 this.contentType_ = dataUrlMatches[1];
198 this.xhr_.responseType = 'blob';
200 this.xhr_.onerror = this.image_.onerror;
201 this.xhr_.onload = function() {
202 if (this.xhr_.status != 200) {
203 this.image_.onerror();
208 this.contentType_ = this.xhr_.getResponseHeader('Content-Type');
210 reader.onerror = this.image_.onerror;
212 this.image_.src = e.target.result;
213 }.bind(this);
216 reader.readAsDataURL(this.xhr_.response);
217 }.bind(this);
221 this.xhr_.open('GET', this.request_.url, true);
222 this.xhr_.send();
224 this.image_.onerror();
240 imageData = this.image_.src;
244 switch (this.contentType_) {
249 imageData = this.canvas_.toDataURL('image/png');
253 imageData = this.canvas_.toDataURL('image/jpeg', 0.9);
258 this.sendImageData_(imageData);
259 this.saveToCache_(imageData);
268 this.sendResponse_({status: 'success',
270 taskId: this.request_.taskId});
283 if (!this.request_.url.match(/^data/) ||
284 ImageLoader.shouldProcess(this.image_.width,
285 this.image_.height,
286 this.request_)) {
287 ImageLoader.resize(this.image_, this.canvas_, this.request_);
288 this.sendImage_(true); // Image changed.
290 this.sendImage_(false); // Image not changed.
292 this.cleanup_();
293 this.downloadCallback_();
304 this.sendResponse_({status: 'error',
305 taskId: this.request_.taskId});
306 this.cleanup_();
307 this.downloadCallback_();
314 this.cleanup_();
317 if (this.downloadCallback_)
318 this.downloadCallback_();
322 * Cleans up memory used by this request.
326 this.image_.onerror = function() {};
327 this.image_.onload = function() {};
330 this.image_.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAA' +
333 this.xhr_.onerror = function() {};
334 this.xhr_.onload = function() {};
335 this.xhr_.abort();
338 this.canvas_.width = 0;
339 this.canvas_.height = 0;