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

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

Issue 1814563002: wtf/CheckedArithmetic.h delegates to base/numerics/safe_math.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } 374 }
375 375
376 } 376 }
377 } 377 }
378 378
379 void ImageResource::decodedSizeChanged(const blink::Image* image, int delta) 379 void ImageResource::decodedSizeChanged(const blink::Image* image, int delta)
380 { 380 {
381 if (!image || image != m_image) 381 if (!image || image != m_image)
382 return; 382 return;
383 383
384 // TODO(bsep): Crash on underflow, which is possible if an error causes 384 WTF::CheckedNumeric<size_t> checkedDecodedSize(decodedSize());
385 // decodedSize to be 0. 385 checkedDecodedSize += delta;
386 setDecodedSize(decodedSize() + delta); 386 setDecodedSize(checkedDecodedSize.ValueOrDie());
387 } 387 }
388 388
389 void ImageResource::didDraw(const blink::Image* image) 389 void ImageResource::didDraw(const blink::Image* image)
390 { 390 {
391 if (!image || image != m_image) 391 if (!image || image != m_image)
392 return; 392 return;
393 // decodedSize() == 0 indicates that the image is decoded into DiscardableMe mory, 393 // decodedSize() == 0 indicates that the image is decoded into DiscardableMe mory,
394 // not in MemoryCache. So we don't need to call Resource::didAccessDecodedDa ta() 394 // not in MemoryCache. So we don't need to call Resource::didAccessDecodedDa ta()
395 // to update MemoryCache. 395 // to update MemoryCache.
396 if (decodedSize() != 0) 396 if (decodedSize() != 0)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 if (response().wasFetchedViaServiceWorker()) 491 if (response().wasFetchedViaServiceWorker())
492 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque; 492 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque;
493 if (!getImage()->currentFrameHasSingleSecurityOrigin()) 493 if (!getImage()->currentFrameHasSingleSecurityOrigin())
494 return false; 494 return false;
495 if (passesAccessControlCheck(securityOrigin)) 495 if (passesAccessControlCheck(securityOrigin))
496 return true; 496 return true;
497 return !securityOrigin->taintsCanvas(response().url()); 497 return !securityOrigin->taintsCanvas(response().url());
498 } 498 }
499 499
500 } // namespace blink 500 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698