OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013, Intel Corporation | 3 * Copyright (C) 2013, Intel Corporation |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 #include <memory> | 47 #include <memory> |
48 | 48 |
49 namespace blink { | 49 namespace blink { |
50 | 50 |
51 class Document; | 51 class Document; |
52 class KURL; | 52 class KURL; |
53 class ResourceRequest; | 53 class ResourceRequest; |
54 class SecurityOrigin; | 54 class SecurityOrigin; |
55 class ThreadableLoaderClient; | 55 class ThreadableLoaderClient; |
56 | 56 |
57 class CORE_EXPORT DocumentThreadableLoader final : public ThreadableLoader, priv ate RawResourceClient { | 57 class CORE_EXPORT DocumentThreadableLoader final : public ThreadableLoader, priv ate ResourceOwner<RawResource> { |
haraken
2016/07/29 15:00:44
I'm just curious but is there any reason for the p
yhirano
2016/08/01 08:52:38
I don't know, and I don't like private inheritance
| |
58 USING_GARBAGE_COLLECTED_MIXIN(DocumentThreadableLoader); | |
58 public: | 59 public: |
59 static void loadResourceSynchronously(Document&, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoaderOp tions&); | 60 static void loadResourceSynchronously(Document&, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoaderOp tions&); |
60 static DocumentThreadableLoader* create(Document&, ThreadableLoaderClien t*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&); | 61 static DocumentThreadableLoader* create(Document&, ThreadableLoaderClien t*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&); |
61 ~DocumentThreadableLoader() override; | 62 ~DocumentThreadableLoader() override; |
62 | 63 |
63 void start(const ResourceRequest&) override; | 64 void start(const ResourceRequest&) override; |
64 | 65 |
65 void overrideTimeout(unsigned long timeout) override; | 66 void overrideTimeout(unsigned long timeout) override; |
66 | 67 |
67 // |this| may be dead after calling this method in async mode. | 68 // |this| may be dead after calling this method in async mode. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 // |this| may be dead after calling this method. | 144 // |this| may be dead after calling this method. |
144 void handleError(const ResourceError&); | 145 void handleError(const ResourceError&); |
145 | 146 |
146 void loadRequest(const ResourceRequest&, ResourceLoaderOptions); | 147 void loadRequest(const ResourceRequest&, ResourceLoaderOptions); |
147 bool isAllowedRedirect(const KURL&) const; | 148 bool isAllowedRedirect(const KURL&) const; |
148 // Returns DoNotAllowStoredCredentials | 149 // Returns DoNotAllowStoredCredentials |
149 // if m_forceDoNotAllowStoredCredentials is set. Otherwise, just | 150 // if m_forceDoNotAllowStoredCredentials is set. Otherwise, just |
150 // returns allowCredentials value of m_resourceLoaderOptions. | 151 // returns allowCredentials value of m_resourceLoaderOptions. |
151 StoredCredentials effectiveAllowCredentials() const; | 152 StoredCredentials effectiveAllowCredentials() const; |
152 | 153 |
153 // TODO(oilpan): DocumentThreadableLoader used to be a ResourceOwner, | |
154 // but ResourceOwner was moved onto the oilpan heap before | |
155 // DocumentThreadableLoader was ready. When DocumentThreadableLoader | |
156 // moves onto the oilpan heap, make it a ResourceOwner again and remove | |
157 // this re-implementation of ResourceOwner. | |
158 RawResource* resource() const { return m_resource.get(); } | |
159 void clearResource() { setResource(nullptr); } | |
160 void setResource(RawResource* newResource) | |
161 { | |
162 if (newResource == m_resource) | |
163 return; | |
164 | |
165 if (RawResource* oldResource = m_resource.release()) | |
166 oldResource->removeClient(this); | |
167 | |
168 if (newResource) { | |
169 m_resource = newResource; | |
170 m_resource->addClient(this); | |
171 } | |
172 } | |
173 Member<RawResource> m_resource; | |
174 // End of ResourceOwner re-implementation, see above. | |
175 | |
176 SecurityOrigin* getSecurityOrigin() const; | 154 SecurityOrigin* getSecurityOrigin() const; |
177 Document& document() const; | 155 Document& document() const; |
178 | 156 |
179 ThreadableLoaderClient* m_client; | 157 ThreadableLoaderClient* m_client; |
180 Member<Document> m_document; | 158 Member<Document> m_document; |
181 | 159 |
182 const ThreadableLoaderOptions m_options; | 160 const ThreadableLoaderOptions m_options; |
183 // Some items may be overridden by m_forceDoNotAllowStoredCredentials | 161 // Some items may be overridden by m_forceDoNotAllowStoredCredentials |
184 // and m_securityOrigin. In such a case, build a ResourceLoaderOptions | 162 // and m_securityOrigin. In such a case, build a ResourceLoaderOptions |
185 // with up-to-date values from them and this variable, and use it. | 163 // with up-to-date values from them and this variable, and use it. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 // header when following the redirect. | 209 // header when following the redirect. |
232 bool m_didRedirect; | 210 bool m_didRedirect; |
233 Referrer m_referrerAfterRedirect; | 211 Referrer m_referrerAfterRedirect; |
234 | 212 |
235 WeakPtrFactory<DocumentThreadableLoader> m_weakFactory; | 213 WeakPtrFactory<DocumentThreadableLoader> m_weakFactory; |
236 }; | 214 }; |
237 | 215 |
238 } // namespace blink | 216 } // namespace blink |
239 | 217 |
240 #endif // DocumentThreadableLoader_h | 218 #endif // DocumentThreadableLoader_h |
OLD | NEW |