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

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

Issue 2191633003: Move ResourceClient to Oilpan heap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@onheap-raw-resource-client
Patch Set: rebase Created 4 years, 4 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
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. 21 Boston, MA 02110-1301, USA.
22 */ 22 */
23 23
24 #include "core/fetch/ImageResource.h" 24 #include "core/fetch/ImageResource.h"
25 25
26 #include "core/fetch/ImageResourceObserver.h" 26 #include "core/fetch/ImageResourceObserver.h"
27 #include "core/fetch/MemoryCache.h" 27 #include "core/fetch/MemoryCache.h"
28 #include "core/fetch/ResourceClient.h" 28 #include "core/fetch/ResourceClient.h"
29 #include "core/fetch/ResourceClientOrObserverWalker.h"
30 #include "core/fetch/ResourceFetcher.h" 29 #include "core/fetch/ResourceFetcher.h"
31 #include "core/fetch/ResourceLoader.h" 30 #include "core/fetch/ResourceLoader.h"
32 #include "core/svg/graphics/SVGImage.h" 31 #include "core/svg/graphics/SVGImage.h"
33 #include "platform/Logging.h" 32 #include "platform/Logging.h"
34 #include "platform/RuntimeEnabledFeatures.h" 33 #include "platform/RuntimeEnabledFeatures.h"
35 #include "platform/SharedBuffer.h" 34 #include "platform/SharedBuffer.h"
36 #include "platform/TraceEvent.h" 35 #include "platform/TraceEvent.h"
37 #include "platform/graphics/BitmapImage.h" 36 #include "platform/graphics/BitmapImage.h"
38 #include "public/platform/Platform.h" 37 #include "public/platform/Platform.h"
39 #include "public/platform/WebCachePolicy.h" 38 #include "public/platform/WebCachePolicy.h"
40 #include "wtf/CurrentTime.h" 39 #include "wtf/CurrentTime.h"
40 #include "wtf/HashCountedSet.h"
41 #include "wtf/StdLibExtras.h" 41 #include "wtf/StdLibExtras.h"
42 #include "wtf/Vector.h"
42 #include <memory> 43 #include <memory>
43 44
44 namespace blink { 45 namespace blink {
45 46
46 using ImageResourceObserverWalker = ResourceClientOrObserverWalker<ImageResource Observer, ImageResourceObserver>; 47 struct ImageResourceObserverWalker {
haraken 2016/08/02 04:18:06 Shall we add a TODO to replace this with ResourceC
yhirano 2016/08/03 10:40:28 Thanks, done.
48 STACK_ALLOCATED();
49 public:
50 explicit ImageResourceObserverWalker(const HashCountedSet<ImageResourceObser ver*>& set)
51 : m_observerSet(set)
52 {
53 m_observerVector.reserveCapacity(set.size());
54 for (const auto& keyvalue : set)
55 m_observerVector.append(keyvalue.key);
56 }
57
58 ImageResourceObserver* next()
59 {
60 size_t size = m_observerVector.size();
61 while (m_index < size) {
62 auto* next = m_observerVector[m_index++];
63 if (m_observerSet.contains(next))
64 return next;
65 }
66 return nullptr;
67 }
68
69 private:
70 const HashCountedSet<ImageResourceObserver*>& m_observerSet;
71 Vector<ImageResourceObserver*> m_observerVector;
72 size_t m_index = 0;
73 };
47 74
48 ImageResource* ImageResource::fetch(FetchRequest& request, ResourceFetcher* fetc her) 75 ImageResource* ImageResource::fetch(FetchRequest& request, ResourceFetcher* fetc her)
49 { 76 {
50 if (request.resourceRequest().requestContext() == WebURLRequest::RequestCont extUnspecified) 77 if (request.resourceRequest().requestContext() == WebURLRequest::RequestCont extUnspecified)
51 request.mutableResourceRequest().setRequestContext(WebURLRequest::Reques tContextImage); 78 request.mutableResourceRequest().setRequestContext(WebURLRequest::Reques tContextImage);
52 if (fetcher->context().pageDismissalEventBeingDispatched()) { 79 if (fetcher->context().pageDismissalEventBeingDispatched()) {
53 KURL requestURL = request.resourceRequest().url(); 80 KURL requestURL = request.resourceRequest().url();
54 if (requestURL.isValid() && fetcher->context().canRequest(Resource::Imag e, request.resourceRequest(), requestURL, request.options(), request.forPreload( ), request.getOriginRestriction())) 81 if (requestURL.isValid() && fetcher->context().canRequest(Resource::Imag e, request.resourceRequest(), requestURL, request.options(), request.forPreload( ), request.getOriginRestriction()))
55 fetcher->context().sendImagePing(requestURL); 82 fetcher->context().sendImagePing(requestURL);
56 return nullptr; 83 return nullptr;
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 if (response().wasFetchedViaServiceWorker()) 621 if (response().wasFetchedViaServiceWorker())
595 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque; 622 return response().serviceWorkerResponseType() != WebServiceWorkerRespons eTypeOpaque;
596 if (!getImage()->currentFrameHasSingleSecurityOrigin()) 623 if (!getImage()->currentFrameHasSingleSecurityOrigin())
597 return false; 624 return false;
598 if (passesAccessControlCheck(securityOrigin)) 625 if (passesAccessControlCheck(securityOrigin))
599 return true; 626 return true;
600 return !securityOrigin->taintsCanvas(response().url()); 627 return !securityOrigin->taintsCanvas(response().url());
601 } 628 }
602 629
603 } // namespace blink 630 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698