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

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

Issue 1710733002: Move multipart resource handling to core/fetch (2/2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@multipart-cleanup
Patch Set: rebase 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 { 286 {
287 if (!m_image) 287 if (!m_image)
288 return; 288 return;
289 289
290 // If our Image has an observer, it's always us so we need to clear the back pointer 290 // If our Image has an observer, it's always us so we need to clear the back pointer
291 // before dropping our reference. 291 // before dropping our reference.
292 m_image->setImageObserver(nullptr); 292 m_image->setImageObserver(nullptr);
293 m_image.clear(); 293 m_image.clear();
294 } 294 }
295 295
296 void ImageResource::appendData(const char* data, size_t length) 296 void ImageResource::appendDataInternal(const char* data, size_t length)
297 { 297 {
298 Resource::appendData(data, length); 298 Resource::appendDataInternal(data, length);
299 if (!loadingMultipartContent()) 299 if (!loadingMultipartContent())
300 updateImage(false); 300 updateImage(false);
301 } 301 }
302 302
303 void ImageResource::updateImage(bool allDataReceived) 303 void ImageResource::updateImage(bool allDataReceived)
304 { 304 {
305 TRACE_EVENT0("blink", "ImageResource::updateImage"); 305 TRACE_EVENT0("blink", "ImageResource::updateImage");
306 306
307 if (m_data) 307 if (m_data)
308 createImage(); 308 createImage();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 345
346 void ImageResource::error(Resource::Status status) 346 void ImageResource::error(Resource::Status status)
347 { 347 {
348 clear(); 348 clear();
349 Resource::error(status); 349 Resource::error(status);
350 notifyObservers(); 350 notifyObservers();
351 } 351 }
352 352
353 void ImageResource::responseReceived(const ResourceResponse& response, PassOwnPt r<WebDataConsumerHandle> handle) 353 void ImageResource::responseReceived(const ResourceResponse& response, PassOwnPt r<WebDataConsumerHandle> handle)
354 { 354 {
355 if (loadingMultipartContent() && m_data) 355 ASSERT(!handle);
356 if (response.isMultipartPayload() && m_data)
356 finishOnePart(); 357 finishOnePart();
357 Resource::responseReceived(response, handle); 358 Resource::responseReceived(response, handle);
358 if (RuntimeEnabledFeatures::clientHintsEnabled()) { 359 if (RuntimeEnabledFeatures::clientHintsEnabled()) {
359 m_devicePixelRatioHeaderValue = m_response.httpHeaderField(HTTPNames::Co ntent_DPR).toFloat(&m_hasDevicePixelRatioHeaderValue); 360 m_devicePixelRatioHeaderValue = m_response.httpHeaderField(HTTPNames::Co ntent_DPR).toFloat(&m_hasDevicePixelRatioHeaderValue);
360 if (!m_hasDevicePixelRatioHeaderValue || m_devicePixelRatioHeaderValue < = 0.0) { 361 if (!m_hasDevicePixelRatioHeaderValue || m_devicePixelRatioHeaderValue < = 0.0) {
361 m_devicePixelRatioHeaderValue = 1.0; 362 m_devicePixelRatioHeaderValue = 1.0;
362 m_hasDevicePixelRatioHeaderValue = false; 363 m_hasDevicePixelRatioHeaderValue = false;
363 } 364 }
364 365
365 } 366 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque; 461 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque;
461 if (!image()->currentFrameHasSingleSecurityOrigin()) 462 if (!image()->currentFrameHasSingleSecurityOrigin())
462 return false; 463 return false;
463 if (passesAccessControlCheck(securityOrigin)) 464 if (passesAccessControlCheck(securityOrigin))
464 return true; 465 return true;
465 return !securityOrigin->taintsCanvas(response().url()); 466 return !securityOrigin->taintsCanvas(response().url());
466 } 467 }
467 468
468 bool ImageResource::loadingMultipartContent() const 469 bool ImageResource::loadingMultipartContent() const
469 { 470 {
470 return m_loader && m_loader->loadingMultipartContent(); 471 return m_loader && isMultipartImage();
471 } 472 }
472 473
473 } // namespace blink 474 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698