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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 class Document; | 50 class Document; |
51 class KURL; | 51 class KURL; |
52 class ResourceRequest; | 52 class ResourceRequest; |
53 class SecurityOrigin; | 53 class SecurityOrigin; |
54 class ThreadableLoaderClient; | 54 class ThreadableLoaderClient; |
55 | 55 |
56 class CORE_EXPORT DocumentThreadableLoader final : public ThreadableLoader, priv
ate ResourceOwner<RawResource> { | 56 class CORE_EXPORT DocumentThreadableLoader final : public ThreadableLoader, priv
ate ResourceOwner<RawResource> { |
57 WTF_MAKE_FAST_ALLOCATED(DocumentThreadableLoader); | 57 WTF_MAKE_FAST_ALLOCATED(DocumentThreadableLoader); |
58 public: | 58 public: |
59 static void loadResourceSynchronously(Document&, const ResourceRequest&,
ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoaderOp
tions&); | 59 static void loadResourceSynchronously(Document&, const ResourceRequest&,
ThreadableLoaderClient&, const ThreadableLoaderOptions&, const ResourceLoaderOp
tions&); |
60 static PassRefPtr<DocumentThreadableLoader> create(Document&, Threadable
LoaderClient*, const ResourceRequest&, const ThreadableLoaderOptions&, const Res
ourceLoaderOptions&); | 60 static PassRefPtr<DocumentThreadableLoader> create(Document&, Threadable
LoaderClient*, const ThreadableLoaderOptions&, const ResourceLoaderOptions&); |
61 ~DocumentThreadableLoader() override; | 61 ~DocumentThreadableLoader() override; |
62 | 62 |
| 63 void start(const ResourceRequest&) override; |
| 64 |
63 void overrideTimeout(unsigned long timeout) override; | 65 void overrideTimeout(unsigned long timeout) override; |
64 | 66 |
65 void cancel() override; | 67 void cancel() override; |
66 void setDefersLoading(bool); | 68 void setDefersLoading(bool); |
67 | 69 |
68 private: | 70 private: |
69 enum BlockingBehavior { | 71 enum BlockingBehavior { |
70 LoadSynchronously, | 72 LoadSynchronously, |
71 LoadAsynchronously | 73 LoadAsynchronously |
72 }; | 74 }; |
73 | 75 |
74 DocumentThreadableLoader(Document&, ThreadableLoaderClient*, BlockingBeh
avior, const ResourceRequest&, const ThreadableLoaderOptions&, const ResourceLoa
derOptions&); | 76 DocumentThreadableLoader(Document&, ThreadableLoaderClient*, BlockingBeh
avior, const ThreadableLoaderOptions&, const ResourceLoaderOptions&); |
75 | 77 |
76 // ResourceClient | 78 // ResourceClient |
77 void notifyFinished(Resource*) override; | 79 void notifyFinished(Resource*) override; |
78 // RawResourceClient | 80 // RawResourceClient |
79 void dataSent(Resource*, unsigned long long bytesSent, unsigned long lon
g totalBytesToBeSent) override; | 81 void dataSent(Resource*, unsigned long long bytesSent, unsigned long lon
g totalBytesToBeSent) override; |
80 void responseReceived(Resource*, const ResourceResponse&, PassOwnPtr<Web
DataConsumerHandle>) override; | 82 void responseReceived(Resource*, const ResourceResponse&, PassOwnPtr<Web
DataConsumerHandle>) override; |
81 void setSerializedCachedMetadata(Resource*, const char*, size_t) overrid
e; | 83 void setSerializedCachedMetadata(Resource*, const char*, size_t) overrid
e; |
82 void dataReceived(Resource*, const char* data, unsigned dataLength) over
ride; | 84 void dataReceived(Resource*, const char* data, unsigned dataLength) over
ride; |
83 void redirectReceived(Resource*, ResourceRequest&, const ResourceRespons
e&) override; | 85 void redirectReceived(Resource*, ResourceRequest&, const ResourceRespons
e&) override; |
84 void dataDownloaded(Resource*, int) override; | 86 void dataDownloaded(Resource*, int) override; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // Set to true if the current request is cross-origin and not simple. | 144 // Set to true if the current request is cross-origin and not simple. |
143 bool m_crossOriginNonSimpleRequest; | 145 bool m_crossOriginNonSimpleRequest; |
144 | 146 |
145 // Set to true when the response data is given to a data consumer | 147 // Set to true when the response data is given to a data consumer |
146 // handle. | 148 // handle. |
147 bool m_isUsingDataConsumerHandle; | 149 bool m_isUsingDataConsumerHandle; |
148 | 150 |
149 const bool m_async; | 151 const bool m_async; |
150 | 152 |
151 // Holds the original request context (used for sanity checks). | 153 // Holds the original request context (used for sanity checks). |
152 const WebURLRequest::RequestContext m_requestContext; | 154 WebURLRequest::RequestContext m_requestContext; |
153 | 155 |
154 // Holds the original request for fallback in case the Service Worker | 156 // Holds the original request for fallback in case the Service Worker |
155 // does not respond. | 157 // does not respond. |
156 OwnPtr<ResourceRequest> m_fallbackRequestForServiceWorker; | 158 OwnPtr<ResourceRequest> m_fallbackRequestForServiceWorker; |
157 | 159 |
158 // Holds the original request and options for it during preflight | 160 // Holds the original request and options for it during preflight |
159 // request handling phase. | 161 // request handling phase. |
160 OwnPtr<ResourceRequest> m_actualRequest; | 162 OwnPtr<ResourceRequest> m_actualRequest; |
161 OwnPtr<ResourceLoaderOptions> m_actualOptions; | 163 OwnPtr<ResourceLoaderOptions> m_actualOptions; |
162 | 164 |
163 HTTPHeaderMap m_simpleRequestHeaders; // stores simple request headers i
n case of a cross-origin redirect. | 165 HTTPHeaderMap m_simpleRequestHeaders; // stores simple request headers i
n case of a cross-origin redirect. |
164 Timer<DocumentThreadableLoader> m_timeoutTimer; | 166 Timer<DocumentThreadableLoader> m_timeoutTimer; |
165 double m_requestStartedSeconds; // Time an asynchronous fetch request is
started | 167 double m_requestStartedSeconds; // Time an asynchronous fetch request is
started |
166 | 168 |
167 // Max number of times that this DocumentThreadableLoader can follow | 169 // Max number of times that this DocumentThreadableLoader can follow |
168 // cross-origin redirects. | 170 // cross-origin redirects. |
169 // This is used to limit the number of redirects. | 171 // This is used to limit the number of redirects. |
170 // But this value is not the max number of total redirects allowed, | 172 // But this value is not the max number of total redirects allowed, |
171 // because same-origin redirects are not counted here. | 173 // because same-origin redirects are not counted here. |
172 int m_corsRedirectLimit; | 174 int m_corsRedirectLimit; |
173 }; | 175 }; |
174 | 176 |
175 } // namespace blink | 177 } // namespace blink |
176 | 178 |
177 #endif // DocumentThreadableLoader_h | 179 #endif // DocumentThreadableLoader_h |
OLD | NEW |