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

Side by Side Diff: third_party/WebKit/Source/core/fetch/Resource.h

Issue 1807323002: [WeakMemoryCache 1a] Make Reference from Inspector to Resource weak, remove removedFromMemoryCache() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 class ResourceTimingInfo; 50 class ResourceTimingInfo;
51 class ResourceLoader; 51 class ResourceLoader;
52 class SecurityOrigin; 52 class SecurityOrigin;
53 class SharedBuffer; 53 class SharedBuffer;
54 54
55 // A resource that is held in the cache. Classes who want to use this object sho uld derive 55 // A resource that is held in the cache. Classes who want to use this object sho uld derive
56 // from ResourceClient, to get the function calls in case the requested data has arrived. 56 // from ResourceClient, to get the function calls in case the requested data has arrived.
57 // This class also does the actual communication with the loader to obtain the r esource from the network. 57 // This class also does the actual communication with the loader to obtain the r esource from the network.
58 class CORE_EXPORT Resource : public GarbageCollectedFinalized<Resource> { 58 class CORE_EXPORT Resource : public GarbageCollectedFinalized<Resource> {
59 WTF_MAKE_NONCOPYABLE(Resource); 59 WTF_MAKE_NONCOPYABLE(Resource);
60 USING_PRE_FINALIZER(Resource, willDestroyResource);
60 public: 61 public:
61 enum Type { 62 enum Type {
62 MainResource, 63 MainResource,
63 Image, 64 Image,
64 CSSStyleSheet, 65 CSSStyleSheet,
65 Script, 66 Script,
66 Font, 67 Font,
67 Raw, 68 Raw,
68 SVGDocument, 69 SVGDocument,
69 XSLStyleSheet, 70 XSLStyleSheet,
(...skipping 13 matching lines...) Expand all
83 DecodeError 84 DecodeError
84 }; 85 };
85 86
86 // Exposed for testing. 87 // Exposed for testing.
87 static Resource* create(const ResourceRequest& request, Type type, const Res ourceLoaderOptions& options = ResourceLoaderOptions()) 88 static Resource* create(const ResourceRequest& request, Type type, const Res ourceLoaderOptions& options = ResourceLoaderOptions())
88 { 89 {
89 return new Resource(request, type, options); 90 return new Resource(request, type, options);
90 } 91 }
91 virtual ~Resource(); 92 virtual ~Resource();
92 93
93 virtual void removedFromMemoryCache(); 94 void willDestroyResource();
94 DECLARE_VIRTUAL_TRACE(); 95 DECLARE_VIRTUAL_TRACE();
95 96
96 void load(ResourceFetcher*); 97 void load(ResourceFetcher*);
97 98
98 virtual void setEncoding(const String&) { } 99 virtual void setEncoding(const String&) { }
99 virtual String encoding() const { return String(); } 100 virtual String encoding() const { return String(); }
100 virtual void appendData(const char*, size_t); 101 virtual void appendData(const char*, size_t);
101 virtual void error(Resource::Status); 102 virtual void error(Resource::Status);
102 virtual void setCORSFailed() { } 103 virtual void setCORSFailed() { }
103 104
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 258
258 void finishPendingClients(); 259 void finishPendingClients();
259 260
260 virtual void didAddClient(ResourceClient*); 261 virtual void didAddClient(ResourceClient*);
261 void willAddClientOrObserver(); 262 void willAddClientOrObserver();
262 263
263 // |this| object may be dead after didRemoveClientOrObserver(). 264 // |this| object may be dead after didRemoveClientOrObserver().
264 void didRemoveClientOrObserver(); 265 void didRemoveClientOrObserver();
265 virtual void allClientsAndObserversRemoved(); 266 virtual void allClientsAndObserversRemoved();
266 267
268 virtual void willDestroyResourceInternal() { }
269
267 HashCountedSet<ResourceClient*> m_clients; 270 HashCountedSet<ResourceClient*> m_clients;
268 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback; 271 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback;
269 HashCountedSet<ResourceClient*> m_finishedClients; 272 HashCountedSet<ResourceClient*> m_finishedClients;
270 273
271 bool hasClient(ResourceClient* client) { return m_clients.contains(client) | | m_clientsAwaitingCallback.contains(client) || m_finishedClients.contains(clien t); } 274 bool hasClient(ResourceClient* client) { return m_clients.contains(client) | | m_clientsAwaitingCallback.contains(client) || m_finishedClients.contains(clien t); }
272 275
273 struct RedirectPair { 276 struct RedirectPair {
274 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 277 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
275 public: 278 public:
276 explicit RedirectPair(const ResourceRequest& request, const ResourceResp onse& redirectResponse) 279 explicit RedirectPair(const ResourceRequest& request, const ResourceResp onse& redirectResponse)
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 367
365 Resource::Type m_type; 368 Resource::Type m_type;
366 }; 369 };
367 370
368 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ 371 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \
369 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType( ) == Resource::typeName, resource.getType() == Resource::typeName); 372 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType( ) == Resource::typeName, resource.getType() == Resource::typeName);
370 373
371 } // namespace blink 374 } // namespace blink
372 375
373 #endif 376 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698