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

Side by Side Diff: third_party/WebKit/Source/core/fetch/ImageResource.cpp

Issue 2054643003: Remove duplication of encoded image data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bug fix: m_image should not be cleared Created 4 years, 6 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
1 /* 1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 void ImageResource::addObserver(ImageResourceObserver* observer) 117 void ImageResource::addObserver(ImageResourceObserver* observer)
118 { 118 {
119 willAddClientOrObserver(); 119 willAddClientOrObserver();
120 120
121 m_observers.add(observer); 121 m_observers.add(observer);
122 122
123 if (isCacheValidator()) 123 if (isCacheValidator())
124 return; 124 return;
125 125
126 if (m_data && !m_image && !errorOccurred()) {
127 createImage();
128 m_image->setData(m_data, true);
129 }
130
131 if (m_image && !m_image->isNull()) { 126 if (m_image && !m_image->isNull()) {
132 observer->imageChanged(this); 127 observer->imageChanged(this);
133 } 128 }
134 129
135 if (isLoaded()) { 130 if (isLoaded()) {
136 observer->imageNotifyFinished(this); 131 observer->imageNotifyFinished(this);
137 if (m_observers.contains(observer)) { 132 if (m_observers.contains(observer)) {
138 m_finishedObservers.add(observer); 133 m_finishedObservers.add(observer);
139 m_observers.remove(observer); 134 m_observers.remove(observer);
140 } 135 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 344
350 if (m_data) 345 if (m_data)
351 createImage(); 346 createImage();
352 347
353 bool sizeAvailable = false; 348 bool sizeAvailable = false;
354 349
355 // Have the image update its data from its internal buffer. 350 // Have the image update its data from its internal buffer.
356 // It will not do anything now, but will delay decoding until 351 // It will not do anything now, but will delay decoding until
357 // queried for info (like size or specific image frames). 352 // queried for info (like size or specific image frames).
358 if (m_image) 353 if (m_image)
359 sizeAvailable = m_image->setData(m_data, allDataReceived); 354 sizeAvailable = m_image->setData(m_data, allDataReceived);
hiroshige 2016/06/15 13:16:25 Isn't it problematic if |setData(m_data)| is calle
hajimehoshi 2016/06/16 09:43:20 Actually |m_data| is null here after m_data.clear(
hajimehoshi 2016/06/16 09:47:41 s/In this case,/Aside from |m_data.clear()|,/
hajimehoshi 2016/06/17 09:25:15 TBH I'm not confident this is OK. Let me check wit
360 355
361 // Go ahead and tell our observers to try to draw if we have either 356 // Go ahead and tell our observers to try to draw if we have either
362 // received all the data or the size is known. Each chunk from the 357 // received all the data or the size is known. Each chunk from the
363 // network causes observers to repaint, which will force that chunk 358 // network causes observers to repaint, which will force that chunk
364 // to decode. 359 // to decode.
365 if (sizeAvailable || allDataReceived) { 360 if (sizeAvailable || allDataReceived) {
366 if (!m_image || m_image->isNull()) { 361 if (!m_image || m_image->isNull()) {
367 if (!errorOccurred()) 362 if (!errorOccurred())
368 setStatus(DecodeError); 363 setStatus(DecodeError);
369 clear(); 364 clear();
(...skipping 15 matching lines...) Expand all
385 } 380 }
386 381
387 void ImageResource::finish(double loadFinishTime) 382 void ImageResource::finish(double loadFinishTime)
388 { 383 {
389 if (m_multipartParser) { 384 if (m_multipartParser) {
390 m_multipartParser->finish(); 385 m_multipartParser->finish();
391 if (m_data) 386 if (m_data)
392 updateImageAndClearBuffer(); 387 updateImageAndClearBuffer();
393 } else { 388 } else {
394 updateImage(true); 389 updateImage(true);
390 m_data.clear();
395 } 391 }
396 Resource::finish(loadFinishTime); 392 Resource::finish(loadFinishTime);
397 } 393 }
398 394
399 void ImageResource::error(const ResourceError& error) 395 void ImageResource::error(const ResourceError& error)
400 { 396 {
401 if (m_multipartParser) 397 if (m_multipartParser)
402 m_multipartParser->cancel(); 398 m_multipartParser->cancel();
403 clear(); 399 clear();
404 Resource::error(error); 400 Resource::error(error);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 m_image->setAnimationPolicy(newPolicy); 489 m_image->setAnimationPolicy(newPolicy);
494 } 490 }
495 } 491 }
496 492
497 void ImageResource::reloadIfLoFi(ResourceFetcher* fetcher) 493 void ImageResource::reloadIfLoFi(ResourceFetcher* fetcher)
498 { 494 {
499 if (!m_response.httpHeaderField("chrome-proxy").contains("q=low")) 495 if (!m_response.httpHeaderField("chrome-proxy").contains("q=low"))
500 return; 496 return;
501 m_resourceRequest.setCachePolicy(WebCachePolicy::BypassingCache); 497 m_resourceRequest.setCachePolicy(WebCachePolicy::BypassingCache);
502 m_resourceRequest.setLoFiState(WebURLRequest::LoFiOff); 498 m_resourceRequest.setLoFiState(WebURLRequest::LoFiOff);
503 if (isLoading()) 499 if (isLoading()) {
504 m_loader->cancel(); 500 m_loader->cancel();
505 else 501 }
506 updateImageAndClearBuffer();
507 setStatus(NotStarted); 502 setStatus(NotStarted);
508 fetcher->startLoad(this); 503 fetcher->startLoad(this);
509 } 504 }
510 505
511 void ImageResource::changedInRect(const blink::Image* image, const IntRect& rect ) 506 void ImageResource::changedInRect(const blink::Image* image, const IntRect& rect )
512 { 507 {
513 if (!image || image != m_image) 508 if (!image || image != m_image)
514 return; 509 return;
515 notifyObservers(&rect); 510 notifyObservers(&rect);
516 } 511 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 if (response().wasFetchedViaServiceWorker()) 544 if (response().wasFetchedViaServiceWorker())
550 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque; 545 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque;
551 if (!getImage()->currentFrameHasSingleSecurityOrigin()) 546 if (!getImage()->currentFrameHasSingleSecurityOrigin())
552 return false; 547 return false;
553 if (passesAccessControlCheck(securityOrigin)) 548 if (passesAccessControlCheck(securityOrigin))
554 return true; 549 return true;
555 return !securityOrigin->taintsCanvas(response().url()); 550 return !securityOrigin->taintsCanvas(response().url());
556 } 551 }
557 552
558 } // namespace blink 553 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/clipboard/DataTransfer.cpp ('k') | third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698