OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2013 Google Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 #include "CachedResource.h" | 29 #include "CachedResource.h" |
30 #include "CachedResourceRequest.h" | 30 #include "CachedResourceRequest.h" |
31 | 31 |
32 namespace WebCore { | 32 namespace WebCore { |
33 | 33 |
34 class PreloadRequest { | 34 class PreloadRequest { |
35 public: | 35 public: |
36 static PassOwnPtr<PreloadRequest> create(const String& initiator, const Stri
ng& resourceURL, const KURL& baseURL, CachedResource::Type resourceType, const S
tring& mediaAttribute) | 36 static PassOwnPtr<PreloadRequest> create(const String& initiator, const Stri
ng& resourceURL, const KURL& baseURL, CachedResource::Type resourceType, const S
tring& mediaAttribute) |
37 { | 37 { |
38 return adoptPtr(new PreloadRequest(initiator, resourceURL, baseURL, reso
urceType, mediaAttribute)); | 38 return adoptPtr(new PreloadRequest(initiator, resourceURL, baseURL, reso
urceType, mediaAttribute, false, false)); |
39 } | 39 } |
40 | 40 |
41 static PassOwnPtr<PreloadRequest> create(const String& initiator, const Stri
ng& resourceURL, const KURL& baseURL, CachedResource::Type resourceType) | 41 static PassOwnPtr<PreloadRequest> create(const String& initiator, const Stri
ng& resourceURL, const KURL& baseURL, CachedResource::Type resourceType) |
42 { | 42 { |
43 return adoptPtr(new PreloadRequest(initiator, resourceURL, baseURL, reso
urceType, "")); | 43 return adoptPtr(new PreloadRequest(initiator, resourceURL, baseURL, reso
urceType, "", false, false)); |
| 44 } |
| 45 |
| 46 static PassOwnPtr<PreloadRequest> create(bool bundleStart, bool bundleEnd) |
| 47 { |
| 48 return adoptPtr(new PreloadRequest("", "", KURL(), CachedResource::RawRe
source, "", bundleStart, bundleEnd)); |
44 } | 49 } |
45 | 50 |
46 bool isSafeToSendToAnotherThread() const; | 51 bool isSafeToSendToAnotherThread() const; |
47 | 52 |
48 CachedResourceRequest resourceRequest(Document*); | 53 CachedResourceRequest resourceRequest(Document*); |
49 | 54 |
50 const String& charset() const { return m_charset; } | 55 const String& charset() const { return m_charset; } |
51 const String& media() const { return m_mediaAttribute; } | 56 const String& media() const { return m_mediaAttribute; } |
52 void setCharset(const String& charset) { m_charset = charset.isolatedCopy();
} | 57 void setCharset(const String& charset) { m_charset = charset.isolatedCopy();
} |
53 void setCrossOriginModeAllowsCookies(bool allowsCookies) { m_crossOriginMode
AllowsCookies = allowsCookies; } | 58 void setCrossOriginModeAllowsCookies(bool allowsCookies) { m_crossOriginMode
AllowsCookies = allowsCookies; } |
54 CachedResource::Type resourceType() const { return m_resourceType; } | 59 CachedResource::Type resourceType() const { return m_resourceType; } |
| 60 const String& resourceURL() const { return m_resourceURL; } |
| 61 bool bundleStart() { return m_bundleStart; } |
| 62 bool bundleEnd() { return m_bundleEnd; } |
55 | 63 |
56 private: | 64 private: |
57 PreloadRequest(const String& initiator, const String& resourceURL, const KUR
L& baseURL, CachedResource::Type resourceType, const String& mediaAttribute) | 65 PreloadRequest(const String& initiator, |
| 66 const String& resourceURL, |
| 67 const KURL& baseURL, |
| 68 CachedResource::Type resourceType, |
| 69 const String& mediaAttribute, |
| 70 bool bundleStart, |
| 71 bool bundleEnd) |
58 : m_initiator(initiator) | 72 : m_initiator(initiator) |
59 , m_resourceURL(resourceURL.isolatedCopy()) | 73 , m_resourceURL(resourceURL.isolatedCopy()) |
60 , m_baseURL(baseURL.copy()) | 74 , m_baseURL(baseURL.copy()) |
61 , m_resourceType(resourceType) | 75 , m_resourceType(resourceType) |
62 , m_mediaAttribute(mediaAttribute.isolatedCopy()) | 76 , m_mediaAttribute(mediaAttribute.isolatedCopy()) |
63 , m_crossOriginModeAllowsCookies(false) | 77 , m_crossOriginModeAllowsCookies(false) |
| 78 , m_bundleStart(bundleStart) |
| 79 , m_bundleEnd(bundleEnd) |
64 { | 80 { |
65 } | 81 } |
66 | 82 |
67 KURL completeURL(Document*); | 83 KURL completeURL(Document*); |
68 | 84 |
69 String m_initiator; | 85 String m_initiator; |
70 String m_resourceURL; | 86 String m_resourceURL; |
71 KURL m_baseURL; | 87 KURL m_baseURL; |
72 String m_charset; | 88 String m_charset; |
73 CachedResource::Type m_resourceType; | 89 CachedResource::Type m_resourceType; |
74 String m_mediaAttribute; | 90 String m_mediaAttribute; |
75 bool m_crossOriginModeAllowsCookies; | 91 bool m_crossOriginModeAllowsCookies; |
| 92 bool m_bundleStart; |
| 93 bool m_bundleEnd; |
76 }; | 94 }; |
77 | 95 |
78 typedef Vector<OwnPtr<PreloadRequest> > PreloadRequestStream; | 96 typedef Vector<OwnPtr<PreloadRequest> > PreloadRequestStream; |
79 | 97 |
80 class HTMLResourcePreloader { | 98 class HTMLResourcePreloader { |
81 WTF_MAKE_NONCOPYABLE(HTMLResourcePreloader); WTF_MAKE_FAST_ALLOCATED; | 99 WTF_MAKE_NONCOPYABLE(HTMLResourcePreloader); WTF_MAKE_FAST_ALLOCATED; |
82 public: | 100 public: |
83 explicit HTMLResourcePreloader(Document* document) | 101 explicit HTMLResourcePreloader(Document* document) |
84 : m_document(document) | 102 : m_document(document) |
85 , m_weakFactory(this) | 103 , m_weakFactory(this) |
| 104 , m_inBundle(false) |
| 105 , m_foundBundleResource(false) |
86 { | 106 { |
87 } | 107 } |
88 | 108 |
89 void takeAndPreload(PreloadRequestStream&); | 109 void takeAndPreload(PreloadRequestStream&); |
90 void preload(PassOwnPtr<PreloadRequest>); | 110 void preload(PassOwnPtr<PreloadRequest>); |
91 | 111 |
92 WeakPtr<HTMLResourcePreloader> createWeakPtr() { return m_weakFactory.create
WeakPtr(); } | 112 WeakPtr<HTMLResourcePreloader> createWeakPtr() { return m_weakFactory.create
WeakPtr(); } |
93 | 113 |
94 private: | 114 private: |
95 Document* m_document; | 115 Document* m_document; |
96 WeakPtrFactory<HTMLResourcePreloader> m_weakFactory; | 116 WeakPtrFactory<HTMLResourcePreloader> m_weakFactory; |
| 117 bool m_inBundle; |
| 118 bool m_foundBundleResource; |
97 }; | 119 }; |
98 | 120 |
99 } | 121 } |
100 | 122 |
101 #endif | 123 #endif |
OLD | NEW |