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

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

Issue 1706083002: Split ImageResourceClient into ResourceClient and ImageResourceObserver [1/2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reflect comments and 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) 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 void setRevalidatingRequest(const ResourceRequest& request) { m_revalidating Request = request; } 121 void setRevalidatingRequest(const ResourceRequest& request) { m_revalidating Request = request; }
122 122
123 const KURL& url() const { return m_resourceRequest.url();} 123 const KURL& url() const { return m_resourceRequest.url();}
124 Type getType() const { return static_cast<Type>(m_type); } 124 Type getType() const { return static_cast<Type>(m_type); }
125 const ResourceLoaderOptions& options() const { return m_options; } 125 const ResourceLoaderOptions& options() const { return m_options; }
126 ResourceLoaderOptions& mutableOptions() { return m_options; } 126 ResourceLoaderOptions& mutableOptions() { return m_options; }
127 void setOptions(const ResourceLoaderOptions& options) { m_options = options; } 127 void setOptions(const ResourceLoaderOptions& options) { m_options = options; }
128 128
129 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); 129 void didChangePriority(ResourceLoadPriority, int intraPriorityValue);
130 ResourcePriority priorityFromClients(); 130 virtual ResourcePriority priorityFromObservers() { return ResourcePriority() ; }
131 131
132 void addClient(ResourceClient*); 132 void addClient(ResourceClient*);
133 void removeClient(ResourceClient*); 133 void removeClient(ResourceClient*);
134 bool hasClients() const { return !m_clients.isEmpty() || !m_clientsAwaitingC allback.isEmpty() || !m_finishedClients.isEmpty(); } 134 virtual bool hasClientsOrObservers() const { return !m_clients.isEmpty() || !m_clientsAwaitingCallback.isEmpty() || !m_finishedClients.isEmpty(); }
135 135
136 enum PreloadResult { 136 enum PreloadResult {
137 PreloadNotReferenced, 137 PreloadNotReferenced,
138 PreloadReferenced, 138 PreloadReferenced,
139 PreloadReferencedWhileLoading, 139 PreloadReferencedWhileLoading,
140 PreloadReferencedWhileComplete 140 PreloadReferencedWhileComplete
141 }; 141 };
142 PreloadResult getPreloadResult() const { return static_cast<PreloadResult>(m _preloadResult); } 142 PreloadResult getPreloadResult() const { return static_cast<PreloadResult>(m _preloadResult); }
143 143
144 virtual void didAddClient(ResourceClient*); 144 virtual void didAddClient(ResourceClient*);
yhirano 2016/03/17 04:44:57 I think placing these two functions and willAddCli
hiroshige 2016/03/23 18:47:25 Done. Also make them protected.
145 virtual void didRemoveClient(ResourceClient*) { } 145
146 virtual void allClientsRemoved(); 146 // |this| object may be dead after didRemoveClientOrObserver().
147 void didRemoveClientOrObserver();
148 virtual void allClientsAndObserversRemoved();
147 149
148 unsigned count() const { return m_clients.size(); } 150 unsigned count() const { return m_clients.size(); }
149 151
150 Status getStatus() const { return static_cast<Status>(m_status); } 152 Status getStatus() const { return static_cast<Status>(m_status); }
151 void setStatus(Status status) { m_status = status; } 153 void setStatus(Status status) { m_status = status; }
152 154
153 size_t size() const { return encodedSize() + decodedSize() + overheadSize(); } 155 size_t size() const { return encodedSize() + decodedSize() + overheadSize(); }
154 size_t encodedSize() const { return m_encodedSize; } 156 size_t encodedSize() const { return m_encodedSize; }
155 size_t decodedSize() const { return m_decodedSize; } 157 size_t decodedSize() const { return m_decodedSize; }
156 size_t overheadSize() const; 158 size_t overheadSize() const;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 virtual void checkNotify(); 262 virtual void checkNotify();
261 263
262 virtual void destroyDecodedDataForFailedRevalidation() { } 264 virtual void destroyDecodedDataForFailedRevalidation() { }
263 265
264 void setEncodedSize(size_t); 266 void setEncodedSize(size_t);
265 void setDecodedSize(size_t); 267 void setDecodedSize(size_t);
266 void didAccessDecodedData(); 268 void didAccessDecodedData();
267 269
268 void finishPendingClients(); 270 void finishPendingClients();
269 271
272 void willAddClientOrObserver();
273
270 HashCountedSet<ResourceClient*> m_clients; 274 HashCountedSet<ResourceClient*> m_clients;
271 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback; 275 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback;
272 HashCountedSet<ResourceClient*> m_finishedClients; 276 HashCountedSet<ResourceClient*> m_finishedClients;
273 277
274 class ResourceCallback : public NoBaseWillBeGarbageCollectedFinalized<Resour ceCallback> { 278 class ResourceCallback : public NoBaseWillBeGarbageCollectedFinalized<Resour ceCallback> {
275 public: 279 public:
276 static ResourceCallback* callbackHandler(); 280 static ResourceCallback* callbackHandler();
277 DECLARE_TRACE(); 281 DECLARE_TRACE();
278 void schedule(Resource*); 282 void schedule(Resource*);
279 void cancel(Resource*); 283 void cancel(Resource*);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 Resource::Type m_type; 386 Resource::Type m_type;
383 }; 387 };
384 388
385 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ 389 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \
386 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType( ) == Resource::typeName, resource.getType() == Resource::typeName); \ 390 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType( ) == Resource::typeName, resource.getType() == Resource::typeName); \
387 inline typeName##Resource* to##typeName##Resource(const RefPtrWillBeRawPtr<R esource>& ptr) { return to##typeName##Resource(ptr.get()); } 391 inline typeName##Resource* to##typeName##Resource(const RefPtrWillBeRawPtr<R esource>& ptr) { return to##typeName##Resource(ptr.get()); }
388 392
389 } // namespace blink 393 } // namespace blink
390 394
391 #endif 395 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698