OLD | NEW |
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 22 matching lines...) Expand all Loading... |
33 #include "platform/network/ResourceResponse.h" | 33 #include "platform/network/ResourceResponse.h" |
34 #include "platform/scheduler/CancellableTaskFactory.h" | 34 #include "platform/scheduler/CancellableTaskFactory.h" |
35 #include "public/platform/WebDataConsumerHandle.h" | 35 #include "public/platform/WebDataConsumerHandle.h" |
36 #include "public/platform/WebMemoryDumpProvider.h" | 36 #include "public/platform/WebMemoryDumpProvider.h" |
37 #include "wtf/Allocator.h" | 37 #include "wtf/Allocator.h" |
38 #include "wtf/HashCountedSet.h" | 38 #include "wtf/HashCountedSet.h" |
39 #include "wtf/HashSet.h" | 39 #include "wtf/HashSet.h" |
40 #include "wtf/OwnPtr.h" | 40 #include "wtf/OwnPtr.h" |
41 #include "wtf/text/WTFString.h" | 41 #include "wtf/text/WTFString.h" |
42 | 42 |
43 // FIXME(crbug.com/352043): This is temporarily enabled even on RELEASE to diagn
ose a wild crash. | |
44 #define ENABLE_RESOURCE_IS_DELETED_CHECK | |
45 | |
46 namespace blink { | 43 namespace blink { |
47 | 44 |
48 struct FetchInitiatorInfo; | 45 struct FetchInitiatorInfo; |
49 class CachedMetadata; | 46 class CachedMetadata; |
50 class FetchRequest; | 47 class FetchRequest; |
51 class ResourceClient; | 48 class ResourceClient; |
52 class ResourceFetcher; | 49 class ResourceFetcher; |
53 class ResourceTimingInfo; | 50 class ResourceTimingInfo; |
54 class InspectorResource; | |
55 class ResourceLoader; | 51 class ResourceLoader; |
56 class SecurityOrigin; | 52 class SecurityOrigin; |
57 class SharedBuffer; | 53 class SharedBuffer; |
58 | 54 |
59 // 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 |
60 // 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. |
61 // 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. |
62 class CORE_EXPORT Resource : public RefCountedWillBeGarbageCollectedFinalized<Re
source> { | 58 class CORE_EXPORT Resource : public RefCountedWillBeGarbageCollectedFinalized<Re
source> { |
63 WTF_MAKE_NONCOPYABLE(Resource); | 59 WTF_MAKE_NONCOPYABLE(Resource); |
64 USING_FAST_MALLOC_WITH_TYPE_NAME_WILL_BE_REMOVED(blink::Resource); | 60 USING_FAST_MALLOC_WITH_TYPE_NAME_WILL_BE_REMOVED(blink::Resource); |
65 friend class InspectorResource; | |
66 | |
67 public: | 61 public: |
68 enum Type { | 62 enum Type { |
69 MainResource, | 63 MainResource, |
70 Image, | 64 Image, |
71 CSSStyleSheet, | 65 CSSStyleSheet, |
72 Script, | 66 Script, |
73 Font, | 67 Font, |
74 Raw, | 68 Raw, |
75 SVGDocument, | 69 SVGDocument, |
76 XSLStyleSheet, | 70 XSLStyleSheet, |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 void prune(); | 247 void prune(); |
254 | 248 |
255 virtual void onMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*)
const; | 249 virtual void onMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*)
const; |
256 | 250 |
257 static const char* resourceTypeToString(Type, const FetchInitiatorInfo&); | 251 static const char* resourceTypeToString(Type, const FetchInitiatorInfo&); |
258 static const char* resourceTypeName(Type); | 252 static const char* resourceTypeName(Type); |
259 | 253 |
260 // TODO(japhet): Remove once oilpan ships, it doesn't need the WeakPtr. | 254 // TODO(japhet): Remove once oilpan ships, it doesn't need the WeakPtr. |
261 WeakPtrWillBeRawPtr<Resource> asWeakPtr(); | 255 WeakPtrWillBeRawPtr<Resource> asWeakPtr(); |
262 | 256 |
263 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK | |
264 void assertAlive() const { RELEASE_ASSERT(!m_deleted); } | |
265 #else | |
266 void assertAlive() const { } | |
267 #endif | |
268 | |
269 protected: | 257 protected: |
270 Resource(const ResourceRequest&, Type); | 258 Resource(const ResourceRequest&, Type); |
271 | 259 |
272 virtual void checkNotify(); | 260 virtual void checkNotify(); |
273 virtual void finishOnePart(); | 261 virtual void finishOnePart(); |
274 | 262 |
275 virtual void destroyDecodedDataForFailedRevalidation() { } | 263 virtual void destroyDecodedDataForFailedRevalidation() { } |
276 | 264 |
277 void setEncodedSize(size_t); | 265 void setEncodedSize(size_t); |
278 void setDecodedSize(size_t); | 266 void setDecodedSize(size_t); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 unsigned m_requestedFromNetworkingLayer : 1; | 360 unsigned m_requestedFromNetworkingLayer : 1; |
373 | 361 |
374 unsigned m_loading : 1; | 362 unsigned m_loading : 1; |
375 | 363 |
376 unsigned m_type : 4; // Type | 364 unsigned m_type : 4; // Type |
377 unsigned m_status : 3; // Status | 365 unsigned m_status : 3; // Status |
378 | 366 |
379 unsigned m_needsSynchronousCacheHit : 1; | 367 unsigned m_needsSynchronousCacheHit : 1; |
380 unsigned m_linkPreload : 1; | 368 unsigned m_linkPreload : 1; |
381 | 369 |
382 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK | |
383 bool m_deleted; | |
384 #endif | |
385 | |
386 // Ordered list of all redirects followed while fetching this resource. | 370 // Ordered list of all redirects followed while fetching this resource. |
387 Vector<RedirectPair> m_redirectChain; | 371 Vector<RedirectPair> m_redirectChain; |
388 }; | 372 }; |
389 | 373 |
390 class ResourceFactory { | 374 class ResourceFactory { |
391 STACK_ALLOCATED(); | 375 STACK_ALLOCATED(); |
392 public: | 376 public: |
393 virtual PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest&, cons
t String&) const = 0; | 377 virtual PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest&, cons
t String&) const = 0; |
394 Resource::Type type() const { return m_type; } | 378 Resource::Type type() const { return m_type; } |
395 | 379 |
396 protected: | 380 protected: |
397 ResourceFactory(Resource::Type type) : m_type(type) { } | 381 ResourceFactory(Resource::Type type) : m_type(type) { } |
398 | 382 |
399 Resource::Type m_type; | 383 Resource::Type m_type; |
400 }; | 384 }; |
401 | 385 |
402 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ | 386 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ |
403 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); \ | 387 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); \ |
404 inline typeName##Resource* to##typeName##Resource(const RefPtrWillBeRawPtr<R
esource>& ptr) { return to##typeName##Resource(ptr.get()); } | 388 inline typeName##Resource* to##typeName##Resource(const RefPtrWillBeRawPtr<R
esource>& ptr) { return to##typeName##Resource(ptr.get()); } |
405 | 389 |
406 } // namespace blink | 390 } // namespace blink |
407 | 391 |
408 #endif | 392 #endif |
OLD | NEW |