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

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

Issue 1822353002: Revert of 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 18 matching lines...) Expand all
29 #include "core/fetch/ResourceClientWalker.h" 29 #include "core/fetch/ResourceClientWalker.h"
30 #include "core/fetch/ResourceFetcher.h" 30 #include "core/fetch/ResourceFetcher.h"
31 #include "core/fetch/ResourceLoader.h" 31 #include "core/fetch/ResourceLoader.h"
32 #include "core/svg/graphics/SVGImage.h" 32 #include "core/svg/graphics/SVGImage.h"
33 #include "platform/Logging.h" 33 #include "platform/Logging.h"
34 #include "platform/RuntimeEnabledFeatures.h" 34 #include "platform/RuntimeEnabledFeatures.h"
35 #include "platform/SharedBuffer.h" 35 #include "platform/SharedBuffer.h"
36 #include "platform/TraceEvent.h" 36 #include "platform/TraceEvent.h"
37 #include "platform/graphics/BitmapImage.h" 37 #include "platform/graphics/BitmapImage.h"
38 #include "public/platform/Platform.h" 38 #include "public/platform/Platform.h"
39 #include "wtf/CheckedNumeric.h"
40 #include "wtf/CurrentTime.h" 39 #include "wtf/CurrentTime.h"
41 #include "wtf/StdLibExtras.h" 40 #include "wtf/StdLibExtras.h"
42 41
43 namespace blink { 42 namespace blink {
44 43
45 PassRefPtrWillBeRawPtr<ImageResource> ImageResource::fetch(FetchRequest& request , ResourceFetcher* fetcher) 44 PassRefPtrWillBeRawPtr<ImageResource> ImageResource::fetch(FetchRequest& request , ResourceFetcher* fetcher)
46 { 45 {
47 if (request.resourceRequest().requestContext() == WebURLRequest::RequestCont extUnspecified) 46 if (request.resourceRequest().requestContext() == WebURLRequest::RequestCont extUnspecified)
48 request.mutableResourceRequest().setRequestContext(WebURLRequest::Reques tContextImage); 47 request.mutableResourceRequest().setRequestContext(WebURLRequest::Reques tContextImage);
49 if (fetcher->context().pageDismissalEventBeingDispatched()) { 48 if (fetcher->context().pageDismissalEventBeingDispatched()) {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 374 }
376 375
377 } 376 }
378 } 377 }
379 378
380 void ImageResource::decodedSizeChanged(const blink::Image* image, int delta) 379 void ImageResource::decodedSizeChanged(const blink::Image* image, int delta)
381 { 380 {
382 if (!image || image != m_image) 381 if (!image || image != m_image)
383 return; 382 return;
384 383
385 CheckedNumeric<intptr_t> signedDecodedSize(decodedSize()); 384 // TODO(bsep): Crash on underflow, which is possible if an error causes
386 signedDecodedSize += delta; 385 // decodedSize to be 0.
387 setDecodedSize(safeCast<size_t>(signedDecodedSize.ValueOrDie())); 386 setDecodedSize(decodedSize() + delta);
388 } 387 }
389 388
390 void ImageResource::didDraw(const blink::Image* image) 389 void ImageResource::didDraw(const blink::Image* image)
391 { 390 {
392 if (!image || image != m_image) 391 if (!image || image != m_image)
393 return; 392 return;
394 // decodedSize() == 0 indicates that the image is decoded into DiscardableMe mory, 393 // decodedSize() == 0 indicates that the image is decoded into DiscardableMe mory,
395 // 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()
396 // to update MemoryCache. 395 // to update MemoryCache.
397 if (decodedSize() != 0) 396 if (decodedSize() != 0)
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 if (response().wasFetchedViaServiceWorker()) 500 if (response().wasFetchedViaServiceWorker())
502 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque; 501 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque;
503 if (!getImage()->currentFrameHasSingleSecurityOrigin()) 502 if (!getImage()->currentFrameHasSingleSecurityOrigin())
504 return false; 503 return false;
505 if (passesAccessControlCheck(securityOrigin)) 504 if (passesAccessControlCheck(securityOrigin))
506 return true; 505 return true;
507 return !securityOrigin->taintsCanvas(response().url()); 506 return !securityOrigin->taintsCanvas(response().url());
508 } 507 }
509 508
510 } // namespace blink 509 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/CharacterData.cpp ('k') | third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698