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) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. | 4 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 5 rights reserved. |
5 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
6 | 7 |
7 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
8 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
9 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
10 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. |
11 | 12 |
12 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, |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 Library General Public License for more details. | 16 Library General Public License for more details. |
16 | 17 |
17 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 |
18 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 |
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 Boston, MA 02110-1301, USA. | 21 Boston, MA 02110-1301, USA. |
21 | 22 |
22 This class provides all functionality needed for loading images, style sheet
s and html | 23 This class provides all functionality needed for loading images, style |
23 pages from the web. It has a memory cache for these objects. | 24 sheets and html pages from the web. It has a memory cache for these objects. |
24 */ | 25 */ |
25 | 26 |
26 #ifndef ResourceFetcher_h | 27 #ifndef ResourceFetcher_h |
27 #define ResourceFetcher_h | 28 #define ResourceFetcher_h |
28 | 29 |
29 #include "core/CoreExport.h" | 30 #include "core/CoreExport.h" |
30 #include "core/fetch/CachePolicy.h" | 31 #include "core/fetch/CachePolicy.h" |
31 #include "core/fetch/FetchContext.h" | 32 #include "core/fetch/FetchContext.h" |
32 #include "core/fetch/FetchInitiatorInfo.h" | 33 #include "core/fetch/FetchInitiatorInfo.h" |
33 #include "core/fetch/FetchRequest.h" | 34 #include "core/fetch/FetchRequest.h" |
(...skipping 16 matching lines...) Expand all Loading... |
50 class DocumentResource; | 51 class DocumentResource; |
51 class FontResource; | 52 class FontResource; |
52 class ImageResource; | 53 class ImageResource; |
53 class MHTMLArchive; | 54 class MHTMLArchive; |
54 class RawResource; | 55 class RawResource; |
55 class ScriptResource; | 56 class ScriptResource; |
56 class XSLStyleSheetResource; | 57 class XSLStyleSheetResource; |
57 class KURL; | 58 class KURL; |
58 class ResourceTimingInfo; | 59 class ResourceTimingInfo; |
59 | 60 |
60 // The ResourceFetcher provides a per-context interface to the MemoryCache | 61 // The ResourceFetcher provides a per-context interface to the MemoryCache and |
61 // and enforces a bunch of security checks and rules for resource revalidation. | 62 // enforces a bunch of security checks and rules for resource revalidation. Its |
62 // Its lifetime is roughly per-DocumentLoader, in that it is generally created | 63 // lifetime is roughly per-DocumentLoader, in that it is generally created in |
63 // in the DocumentLoader constructor and loses its ability to generate network | 64 // the DocumentLoader constructor and loses its ability to generate network |
64 // requests when the DocumentLoader is destroyed. Documents also hold a pointer | 65 // requests when the DocumentLoader is destroyed. Documents also hold a pointer |
65 // to ResourceFetcher for their lifetime (and will create one if they | 66 // to ResourceFetcher for their lifetime (and will create one if they are |
66 // are initialized without a LocalFrame), so a Document can keep a ResourceFetch
er | 67 // initialized without a LocalFrame), so a Document can keep a ResourceFetcher |
67 // alive past detach if scripts still reference the Document. | 68 // alive past detach if scripts still reference the Document. |
68 class CORE_EXPORT ResourceFetcher | 69 class CORE_EXPORT ResourceFetcher |
69 : public GarbageCollectedFinalized<ResourceFetcher> { | 70 : public GarbageCollectedFinalized<ResourceFetcher> { |
70 WTF_MAKE_NONCOPYABLE(ResourceFetcher); | 71 WTF_MAKE_NONCOPYABLE(ResourceFetcher); |
71 USING_PRE_FINALIZER(ResourceFetcher, clearPreloads); | 72 USING_PRE_FINALIZER(ResourceFetcher, clearPreloads); |
72 | 73 |
73 public: | 74 public: |
74 static ResourceFetcher* create(FetchContext* context) { | 75 static ResourceFetcher* create(FetchContext* context) { |
75 return new ResourceFetcher(context); | 76 return new ResourceFetcher(context); |
76 } | 77 } |
77 virtual ~ResourceFetcher(); | 78 virtual ~ResourceFetcher(); |
78 DECLARE_VIRTUAL_TRACE(); | 79 DECLARE_VIRTUAL_TRACE(); |
79 | 80 |
80 Resource* requestResource(FetchRequest&, | 81 Resource* requestResource(FetchRequest&, |
81 const ResourceFactory&, | 82 const ResourceFactory&, |
82 const SubstituteData& = SubstituteData()); | 83 const SubstituteData& = SubstituteData()); |
83 | 84 |
84 Resource* cachedResource(const KURL&) const; | 85 Resource* cachedResource(const KURL&) const; |
85 | 86 |
86 using DocumentResourceMap = HeapHashMap<String, WeakMember<Resource>>; | 87 using DocumentResourceMap = HeapHashMap<String, WeakMember<Resource>>; |
87 const DocumentResourceMap& allResources() const { | 88 const DocumentResourceMap& allResources() const { |
88 return m_documentResources; | 89 return m_documentResources; |
89 } | 90 } |
90 | 91 |
91 // Actually starts loading a Resource if it wasn't started during requestResou
rce(). | 92 // Actually starts loading a Resource if it wasn't started during |
| 93 // requestResource(). |
92 bool startLoad(Resource*); | 94 bool startLoad(Resource*); |
93 | 95 |
94 void setAutoLoadImages(bool); | 96 void setAutoLoadImages(bool); |
95 void setImagesEnabled(bool); | 97 void setImagesEnabled(bool); |
96 | 98 |
97 FetchContext& context() const { | 99 FetchContext& context() const { |
98 return m_context ? *m_context.get() : FetchContext::nullInstance(); | 100 return m_context ? *m_context.get() : FetchContext::nullInstance(); |
99 } | 101 } |
100 void clearContext(); | 102 void clearContext(); |
101 | 103 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 } | 290 } |
289 | 291 |
290 private: | 292 private: |
291 Member<ResourceFetcher> m_loader; | 293 Member<ResourceFetcher> m_loader; |
292 bool m_previousState; | 294 bool m_previousState; |
293 }; | 295 }; |
294 | 296 |
295 } // namespace blink | 297 } // namespace blink |
296 | 298 |
297 #endif // ResourceFetcher_h | 299 #endif // ResourceFetcher_h |
OLD | NEW |