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

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

Issue 1756953002: Stop dispatching notifyFinished for each part in a multipart response (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@multipart-cleanup-2
Patch Set: Created 4 years, 9 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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 load(fetcher, fetcher->defaultResourceOptions()); 458 load(fetcher, fetcher->defaultResourceOptions());
459 } 459 }
460 460
461 void ImageResource::changedInRect(const blink::Image* image, const IntRect& rect ) 461 void ImageResource::changedInRect(const blink::Image* image, const IntRect& rect )
462 { 462 {
463 if (!image || image != m_image) 463 if (!image || image != m_image)
464 return; 464 return;
465 notifyObservers(&rect); 465 notifyObservers(&rect);
466 } 466 }
467 467
468 void ImageResource::onePartInMultipartReceived(const ResourceResponse& response, bool isFirstPart) 468 void ImageResource::onePartInMultipartReceived(const ResourceResponse& response)
469 { 469 {
470 ASSERT(m_multipartParser); 470 ASSERT(m_multipartParser);
471
471 m_response = response; 472 m_response = response;
472 if (m_data) { 473 if (m_multipartParsingState == MultipartParsingState::WaitingForFirstPart) {
473 clear(); 474 // We have nothing to do because we don't have any data.
474 updateImage(true); 475 m_multipartParsingState = MultipartParsingState::ParsingFirstPart;
475 m_data.clear(); 476 return;
477 }
478 clear();
479 updateImage(true);
480 m_data.clear();
481
482 if (m_multipartParsingState == MultipartParsingState::ParsingFirstPart) {
483 m_multipartParsingState = MultipartParsingState::FinishedParsingFirstPar t;
484 // Notify finished when the first part ends.
476 setLoading(false); 485 setLoading(false);
477 checkNotify(); 486 checkNotify();
487 if (m_loader)
488 m_loader->didFinishLoadingOnePart(0, WebURLLoaderClient::kUnknownEnc odedDataLength);
478 } 489 }
479 if (!isFirstPart && m_loader)
480 m_loader->didFinishLoadingOnePart(0, WebURLLoaderClient::kUnknownEncoded DataLength);
481 } 490 }
482 491
483 void ImageResource::multipartDataReceived(const char* bytes, size_t size) 492 void ImageResource::multipartDataReceived(const char* bytes, size_t size)
484 { 493 {
485 ASSERT(m_multipartParser); 494 ASSERT(m_multipartParser);
486 Resource::appendData(bytes, size); 495 Resource::appendData(bytes, size);
487 } 496 }
488 497
489 bool ImageResource::isAccessAllowed(SecurityOrigin* securityOrigin) 498 bool ImageResource::isAccessAllowed(SecurityOrigin* securityOrigin)
490 { 499 {
491 if (response().wasFetchedViaServiceWorker()) 500 if (response().wasFetchedViaServiceWorker())
492 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque; 501 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque;
493 if (!getImage()->currentFrameHasSingleSecurityOrigin()) 502 if (!getImage()->currentFrameHasSingleSecurityOrigin())
494 return false; 503 return false;
495 if (passesAccessControlCheck(securityOrigin)) 504 if (passesAccessControlCheck(securityOrigin))
496 return true; 505 return true;
497 return !securityOrigin->taintsCanvas(response().url()); 506 return !securityOrigin->taintsCanvas(response().url());
498 } 507 }
499 508
500 } // namespace blink 509 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698