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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 ResourceRequest&, const ThreadableLoaderOptions&, const Res
ourceLoaderOptions&); |
61 ~DocumentThreadableLoader() override; | 61 ~DocumentThreadableLoader() override; |
62 | 62 |
63 void overrideTimeout(unsigned long timeout) override; | 63 void overrideTimeout(unsigned long timeout) override; |
64 | 64 |
| 65 // |this| may be dead after calling this method in async mode. |
65 void cancel() override; | 66 void cancel() override; |
66 void setDefersLoading(bool); | 67 void setDefersLoading(bool); |
67 | 68 |
68 private: | 69 private: |
69 enum BlockingBehavior { | 70 enum BlockingBehavior { |
70 LoadSynchronously, | 71 LoadSynchronously, |
71 LoadAsynchronously | 72 LoadAsynchronously |
72 }; | 73 }; |
73 | 74 |
74 DocumentThreadableLoader(Document&, ThreadableLoaderClient*, BlockingBeh
avior, const ResourceRequest&, const ThreadableLoaderOptions&, const ResourceLoa
derOptions&); | 75 DocumentThreadableLoader(Document&, ThreadableLoaderClient*, BlockingBeh
avior, const ResourceRequest&, const ThreadableLoaderOptions&, const ResourceLoa
derOptions&); |
75 | 76 |
| 77 void clear(); |
| 78 |
76 // ResourceClient | 79 // ResourceClient |
| 80 // |
| 81 // |this| may be dead after calling this method. |
77 void notifyFinished(Resource*) override; | 82 void notifyFinished(Resource*) override; |
| 83 |
78 // RawResourceClient | 84 // RawResourceClient |
| 85 // |
| 86 // |this| may be dead after calling these methods. |
79 void dataSent(Resource*, unsigned long long bytesSent, unsigned long lon
g totalBytesToBeSent) override; | 87 void dataSent(Resource*, unsigned long long bytesSent, unsigned long lon
g totalBytesToBeSent) override; |
80 void responseReceived(Resource*, const ResourceResponse&, PassOwnPtr<Web
DataConsumerHandle>) override; | 88 void responseReceived(Resource*, const ResourceResponse&, PassOwnPtr<Web
DataConsumerHandle>) override; |
81 void setSerializedCachedMetadata(Resource*, const char*, size_t) overrid
e; | 89 void setSerializedCachedMetadata(Resource*, const char*, size_t) overrid
e; |
82 void dataReceived(Resource*, const char* data, unsigned dataLength) over
ride; | 90 void dataReceived(Resource*, const char* data, unsigned dataLength) over
ride; |
83 void redirectReceived(Resource*, ResourceRequest&, const ResourceRespons
e&) override; | 91 void redirectReceived(Resource*, ResourceRequest&, const ResourceRespons
e&) override; |
84 void dataDownloaded(Resource*, int) override; | 92 void dataDownloaded(Resource*, int) override; |
85 void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) over
ride; | 93 void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) over
ride; |
86 | 94 |
| 95 // |this| may be dead after calling this method in async mode. |
87 void cancelWithError(const ResourceError&); | 96 void cancelWithError(const ResourceError&); |
88 | 97 |
89 // Notify Inspector and log to console about resource response. Use | 98 // Notify Inspector and log to console about resource response. Use |
90 // this method if response is not going to be finished normally. | 99 // this method if response is not going to be finished normally. |
91 void reportResponseReceived(unsigned long identifier, const ResourceResp
onse&); | 100 void reportResponseReceived(unsigned long identifier, const ResourceResp
onse&); |
92 | 101 |
93 // Methods containing code to handle resource fetch results which is | 102 // Methods containing code to handle resource fetch results which are |
94 // common to both sync and async mode. | 103 // common to both sync and async mode. |
| 104 // |
| 105 // |this| may be dead after calling these method in async mode. |
95 void handleResponse(unsigned long identifier, const ResourceResponse&, P
assOwnPtr<WebDataConsumerHandle>); | 106 void handleResponse(unsigned long identifier, const ResourceResponse&, P
assOwnPtr<WebDataConsumerHandle>); |
96 void handleReceivedData(const char* data, unsigned dataLength); | 107 void handleReceivedData(const char* data, unsigned dataLength); |
| 108 void handleSuccessfulActualRequestFinish(unsigned long identifier, doubl
e finishTime); |
97 void handleSuccessfulFinish(unsigned long identifier, double finishTime)
; | 109 void handleSuccessfulFinish(unsigned long identifier, double finishTime)
; |
98 | 110 |
| 111 // |this| may be dead after calling this method. |
99 void didTimeout(Timer<DocumentThreadableLoader>*); | 112 void didTimeout(Timer<DocumentThreadableLoader>*); |
100 // Calls the appropriate loading method according to policy and data | 113 // Calls the appropriate loading method according to policy and data |
101 // about origin. Only for handling the initial load (including fallback | 114 // about origin. Only for handling the initial load (including fallback |
102 // after consulting ServiceWorker). | 115 // after consulting ServiceWorker). |
| 116 // |
| 117 // |this| may be dead after calling this method in async mode. |
103 void dispatchInitialRequest(const ResourceRequest&); | 118 void dispatchInitialRequest(const ResourceRequest&); |
| 119 // |this| may be dead after calling this method in async mode. |
104 void makeCrossOriginAccessRequest(const ResourceRequest&); | 120 void makeCrossOriginAccessRequest(const ResourceRequest&); |
105 // Loads m_fallbackRequestForServiceWorker. | 121 // Loads m_fallbackRequestForServiceWorker. |
| 122 // |
| 123 // |this| may be dead after calling this method in async mode. |
106 void loadFallbackRequestForServiceWorker(); | 124 void loadFallbackRequestForServiceWorker(); |
107 // Loads m_actualRequest. | 125 // Loads m_actualRequest. |
108 void loadActualRequest(); | 126 void loadActualRequest(); |
109 // Clears m_actualRequest and reports access control check failure to | 127 // Clears m_actualRequest and reports access control check failure to |
110 // m_client. | 128 // m_client. |
| 129 // |
| 130 // |this| may be dead after calling this method in async mode. |
111 void handlePreflightFailure(const String& url, const String& errorDescri
ption); | 131 void handlePreflightFailure(const String& url, const String& errorDescri
ption); |
112 // Investigates the response for the preflight request. If successful, | 132 // Investigates the response for the preflight request. If successful, |
113 // the actual request will be made later in handleSuccessfulFinish(). | 133 // the actual request will be made later in handleSuccessfulFinish(). |
| 134 // |
| 135 // |this| may be dead after calling this method in async mode. |
114 void handlePreflightResponse(const ResourceResponse&); | 136 void handlePreflightResponse(const ResourceResponse&); |
| 137 // |this| may be dead after calling this method. |
| 138 void handleError(const ResourceError&); |
115 | 139 |
116 void loadRequest(const ResourceRequest&, ResourceLoaderOptions); | 140 void loadRequest(const ResourceRequest&, ResourceLoaderOptions); |
117 bool isAllowedRedirect(const KURL&) const; | 141 bool isAllowedRedirect(const KURL&) const; |
118 bool isAllowedByContentSecurityPolicy(const KURL&, ContentSecurityPolicy
::RedirectStatus) const; | 142 bool isAllowedByContentSecurityPolicy(const KURL&, ContentSecurityPolicy
::RedirectStatus) const; |
119 // Returns DoNotAllowStoredCredentials | 143 // Returns DoNotAllowStoredCredentials |
120 // if m_forceDoNotAllowStoredCredentials is set. Otherwise, just | 144 // if m_forceDoNotAllowStoredCredentials is set. Otherwise, just |
121 // returns allowCredentials value of m_resourceLoaderOptions. | 145 // returns allowCredentials value of m_resourceLoaderOptions. |
122 StoredCredentials effectiveAllowCredentials() const; | 146 StoredCredentials effectiveAllowCredentials() const; |
123 | 147 |
124 SecurityOrigin* securityOrigin() const; | 148 SecurityOrigin* securityOrigin() const; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // But this value is not the max number of total redirects allowed, | 194 // But this value is not the max number of total redirects allowed, |
171 // because same-origin redirects are not counted here. | 195 // because same-origin redirects are not counted here. |
172 int m_corsRedirectLimit; | 196 int m_corsRedirectLimit; |
173 | 197 |
174 const WebURLRequest::FetchRedirectMode m_redirectMode; | 198 const WebURLRequest::FetchRedirectMode m_redirectMode; |
175 }; | 199 }; |
176 | 200 |
177 } // namespace blink | 201 } // namespace blink |
178 | 202 |
179 #endif // DocumentThreadableLoader_h | 203 #endif // DocumentThreadableLoader_h |
OLD | NEW |