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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 class ResourceClient; 48 class ResourceClient;
49 class ResourceFetcher; 49 class ResourceFetcher;
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 RefCountedWillBeGarbageCollectedFinalized<Re source> { 58 class CORE_EXPORT Resource : public GarbageCollectedFinalized<Resource> {
59 WTF_MAKE_NONCOPYABLE(Resource); 59 WTF_MAKE_NONCOPYABLE(Resource);
60 USING_FAST_MALLOC_WITH_TYPE_NAME_WILL_BE_REMOVED(blink::Resource);
61 public: 60 public:
62 enum Type { 61 enum Type {
63 MainResource, 62 MainResource,
64 Image, 63 Image,
65 CSSStyleSheet, 64 CSSStyleSheet,
66 Script, 65 Script,
67 Font, 66 Font,
68 Raw, 67 Raw,
69 SVGDocument, 68 SVGDocument,
70 XSLStyleSheet, 69 XSLStyleSheet,
71 LinkPrefetch, 70 LinkPrefetch,
72 LinkPreload, 71 LinkPreload,
73 TextTrack, 72 TextTrack,
74 ImportResource, 73 ImportResource,
75 Media, // Audio or video file requested by a HTML5 media element 74 Media, // Audio or video file requested by a HTML5 media element
76 Manifest 75 Manifest
77 }; 76 };
78 77
79 enum Status { 78 enum Status {
80 NotStarted, 79 NotStarted,
81 LoadStartScheduled, // scheduled but not yet started, only used by fonts . 80 LoadStartScheduled, // scheduled but not yet started, only used by fonts .
82 Pending, // load in progress 81 Pending, // load in progress
83 Cached, // load completed successfully 82 Cached, // load completed successfully
84 LoadError, 83 LoadError,
85 DecodeError 84 DecodeError
86 }; 85 };
87 86
88 // Exposed for testing. 87 // Exposed for testing.
89 static PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest& reques t, Type type, const ResourceLoaderOptions& options = ResourceLoaderOptions()) 88 static RawPtr<Resource> create(const ResourceRequest& request, Type type, co nst ResourceLoaderOptions& options = ResourceLoaderOptions())
90 { 89 {
91 return adoptRefWillBeNoop(new Resource(request, type, options)); 90 return new Resource(request, type, options);
92 } 91 }
93 virtual ~Resource(); 92 virtual ~Resource();
94 93
95 virtual void removedFromMemoryCache(); 94 virtual void removedFromMemoryCache();
96 DECLARE_VIRTUAL_TRACE(); 95 DECLARE_VIRTUAL_TRACE();
97 96
98 virtual void load(ResourceFetcher*); 97 virtual void load(ResourceFetcher*);
99 98
100 virtual void setEncoding(const String&) { } 99 virtual void setEncoding(const String&) { }
101 virtual String encoding() const { return String(); } 100 virtual String encoding() const { return String(); }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 239
241 // Used by the MemoryCache to reduce the memory consumption of the entry. 240 // Used by the MemoryCache to reduce the memory consumption of the entry.
242 void prune(); 241 void prune();
243 242
244 virtual void onMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*) const; 243 virtual void onMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*) const;
245 244
246 static const char* resourceTypeToString(Type, const FetchInitiatorInfo&); 245 static const char* resourceTypeToString(Type, const FetchInitiatorInfo&);
247 static const char* resourceTypeName(Type); 246 static const char* resourceTypeName(Type);
248 247
249 // TODO(japhet): Remove once oilpan ships, it doesn't need the WeakPtr. 248 // TODO(japhet): Remove once oilpan ships, it doesn't need the WeakPtr.
250 WeakPtrWillBeRawPtr<Resource> asWeakPtr(); 249 RawPtr<Resource> asWeakPtr();
251 250
252 protected: 251 protected:
253 Resource(const ResourceRequest&, Type, const ResourceLoaderOptions&); 252 Resource(const ResourceRequest&, Type, const ResourceLoaderOptions&);
254 253
255 virtual void checkNotify(); 254 virtual void checkNotify();
256 255
257 virtual void destroyDecodedDataForFailedRevalidation() { } 256 virtual void destroyDecodedDataForFailedRevalidation() { }
258 257
259 void setEncodedSize(size_t); 258 void setEncodedSize(size_t);
260 void setDecodedSize(size_t); 259 void setDecodedSize(size_t);
261 void didAccessDecodedData(); 260 void didAccessDecodedData();
262 261
263 void finishPendingClients(); 262 void finishPendingClients();
264 263
265 virtual void didAddClient(ResourceClient*); 264 virtual void didAddClient(ResourceClient*);
266 void willAddClientOrObserver(); 265 void willAddClientOrObserver();
267 266
268 // |this| object may be dead after didRemoveClientOrObserver(). 267 // |this| object may be dead after didRemoveClientOrObserver().
269 void didRemoveClientOrObserver(); 268 void didRemoveClientOrObserver();
270 virtual void allClientsAndObserversRemoved(); 269 virtual void allClientsAndObserversRemoved();
271 270
272 HashCountedSet<ResourceClient*> m_clients; 271 HashCountedSet<ResourceClient*> m_clients;
273 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback; 272 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback;
274 HashCountedSet<ResourceClient*> m_finishedClients; 273 HashCountedSet<ResourceClient*> m_finishedClients;
275 274
276 class ResourceCallback : public NoBaseWillBeGarbageCollectedFinalized<Resour ceCallback> { 275 class ResourceCallback : public GarbageCollectedFinalized<ResourceCallback> {
277 public: 276 public:
278 static ResourceCallback* callbackHandler(); 277 static ResourceCallback* callbackHandler();
279 DECLARE_TRACE(); 278 DECLARE_TRACE();
280 void schedule(Resource*); 279 void schedule(Resource*);
281 void cancel(Resource*); 280 void cancel(Resource*);
282 bool isScheduled(Resource*) const; 281 bool isScheduled(Resource*) const;
283 private: 282 private:
284 ResourceCallback(); 283 ResourceCallback();
285 void runTask(); 284 void runTask();
286 OwnPtr<CancellableTaskFactory> m_callbackTaskFactory; 285 OwnPtr<CancellableTaskFactory> m_callbackTaskFactory;
287 WillBeHeapHashSet<RefPtrWillBeMember<Resource>> m_resourcesWithPendingCl ients; 286 HeapHashSet<Member<Resource>> m_resourcesWithPendingClients;
288 }; 287 };
289 288
290 bool hasClient(ResourceClient* client) { return m_clients.contains(client) | | m_clientsAwaitingCallback.contains(client) || m_finishedClients.contains(clien t); } 289 bool hasClient(ResourceClient* client) { return m_clients.contains(client) | | m_clientsAwaitingCallback.contains(client) || m_finishedClients.contains(clien t); }
291 290
292 struct RedirectPair { 291 struct RedirectPair {
293 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 292 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
294 public: 293 public:
295 explicit RedirectPair(const ResourceRequest& request, const ResourceResp onse& redirectResponse) 294 explicit RedirectPair(const ResourceRequest& request, const ResourceResp onse& redirectResponse)
296 : m_request(request) 295 : m_request(request)
297 , m_redirectResponse(redirectResponse) 296 , m_redirectResponse(redirectResponse)
298 { 297 {
299 } 298 }
300 299
301 ResourceRequest m_request; 300 ResourceRequest m_request;
302 ResourceResponse m_redirectResponse; 301 ResourceResponse m_redirectResponse;
303 }; 302 };
304 const Vector<RedirectPair>& redirectChain() const { return m_redirectChain; } 303 const Vector<RedirectPair>& redirectChain() const { return m_redirectChain; }
305 304
306 virtual bool isSafeToUnlock() const { return false; } 305 virtual bool isSafeToUnlock() const { return false; }
307 virtual void destroyDecodedDataIfPossible() { } 306 virtual void destroyDecodedDataIfPossible() { }
308 307
309 void markClientsFinished(); 308 void markClientsFinished();
310 309
311 // Returns the memory dump name used for tracing. See Resource::onMemoryDump . 310 // Returns the memory dump name used for tracing. See Resource::onMemoryDump .
312 String getMemoryDumpName() const; 311 String getMemoryDumpName() const;
313 312
314 ResourceRequest m_resourceRequest; 313 ResourceRequest m_resourceRequest;
315 ResourceRequest m_revalidatingRequest; 314 ResourceRequest m_revalidatingRequest;
316 AtomicString m_accept; 315 AtomicString m_accept;
317 PersistentWillBeMember<ResourceLoader> m_loader; 316 Member<ResourceLoader> m_loader;
318 ResourceLoaderOptions m_options; 317 ResourceLoaderOptions m_options;
319 318
320 ResourceResponse m_response; 319 ResourceResponse m_response;
321 double m_responseTimestamp; 320 double m_responseTimestamp;
322 321
323 RefPtr<SharedBuffer> m_data; 322 RefPtr<SharedBuffer> m_data;
324 Timer<Resource> m_cancelTimer; 323 Timer<Resource> m_cancelTimer;
325 324
326 private: 325 private:
327 class CacheHandler; 326 class CacheHandler;
(...skipping 10 matching lines...) Expand all
338 void clearCachedMetadata(CachedMetadataHandler::CacheType); 337 void clearCachedMetadata(CachedMetadataHandler::CacheType);
339 CachedMetadata* cachedMetadata(unsigned dataTypeID) const; 338 CachedMetadata* cachedMetadata(unsigned dataTypeID) const;
340 339
341 String m_fragmentIdentifierForRequest; 340 String m_fragmentIdentifierForRequest;
342 341
343 #if !ENABLE(OILPAN) 342 #if !ENABLE(OILPAN)
344 WeakPtrFactory<Resource> m_weakPtrFactory; 343 WeakPtrFactory<Resource> m_weakPtrFactory;
345 #endif 344 #endif
346 345
347 RefPtr<CachedMetadata> m_cachedMetadata; 346 RefPtr<CachedMetadata> m_cachedMetadata;
348 OwnPtrWillBeMember<CacheHandler> m_cacheHandler; 347 Member<CacheHandler> m_cacheHandler;
349 348
350 ResourceError m_error; 349 ResourceError m_error;
351 350
352 double m_loadFinishTime; 351 double m_loadFinishTime;
353 352
354 unsigned long m_identifier; 353 unsigned long m_identifier;
355 354
356 size_t m_encodedSize; 355 size_t m_encodedSize;
357 size_t m_decodedSize; 356 size_t m_decodedSize;
358 357
(...skipping 14 matching lines...) Expand all
373 unsigned m_needsSynchronousCacheHit : 1; 372 unsigned m_needsSynchronousCacheHit : 1;
374 unsigned m_linkPreload : 1; 373 unsigned m_linkPreload : 1;
375 374
376 // Ordered list of all redirects followed while fetching this resource. 375 // Ordered list of all redirects followed while fetching this resource.
377 Vector<RedirectPair> m_redirectChain; 376 Vector<RedirectPair> m_redirectChain;
378 }; 377 };
379 378
380 class ResourceFactory { 379 class ResourceFactory {
381 STACK_ALLOCATED(); 380 STACK_ALLOCATED();
382 public: 381 public:
383 virtual PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest&, cons t ResourceLoaderOptions&, const String&) const = 0; 382 virtual RawPtr<Resource> create(const ResourceRequest&, const ResourceLoader Options&, const String&) const = 0;
384 Resource::Type type() const { return m_type; } 383 Resource::Type type() const { return m_type; }
385 384
386 protected: 385 protected:
387 ResourceFactory(Resource::Type type) : m_type(type) { } 386 ResourceFactory(Resource::Type type) : m_type(type) { }
388 387
389 Resource::Type m_type; 388 Resource::Type m_type;
390 }; 389 };
391 390
392 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ 391 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \
393 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType( ) == Resource::typeName, resource.getType() == Resource::typeName); \ 392 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType( ) == Resource::typeName, resource.getType() == Resource::typeName); \
394 inline typeName##Resource* to##typeName##Resource(const RefPtrWillBeRawPtr<R esource>& ptr) { return to##typeName##Resource(ptr.get()); } 393 inline typeName##Resource* to##typeName##Resource(const RawPtr<Resource>& pt r) { return to##typeName##Resource(ptr.get()); }
395 394
396 } // namespace blink 395 } // namespace blink
397 396
398 #endif 397 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/RawResourceTest.cpp ('k') | third_party/WebKit/Source/core/fetch/Resource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698