| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 static DocumentThreadableLoader* create(Document&, | 66 static DocumentThreadableLoader* create(Document&, |
| 67 ThreadableLoaderClient*, | 67 ThreadableLoaderClient*, |
| 68 const ThreadableLoaderOptions&, | 68 const ThreadableLoaderOptions&, |
| 69 const ResourceLoaderOptions&); | 69 const ResourceLoaderOptions&); |
| 70 ~DocumentThreadableLoader() override; | 70 ~DocumentThreadableLoader() override; |
| 71 | 71 |
| 72 void start(const ResourceRequest&) override; | 72 void start(const ResourceRequest&) override; |
| 73 | 73 |
| 74 void overrideTimeout(unsigned long timeout) override; | 74 void overrideTimeout(unsigned long timeout) override; |
| 75 | 75 |
| 76 // |this| may be dead after calling this method in async mode. | |
| 77 void cancel() override; | 76 void cancel() override; |
| 78 void setDefersLoading(bool); | 77 void setDefersLoading(bool); |
| 79 | 78 |
| 80 DECLARE_TRACE(); | 79 DECLARE_TRACE(); |
| 81 | 80 |
| 82 private: | 81 private: |
| 83 enum BlockingBehavior { LoadSynchronously, LoadAsynchronously }; | 82 enum BlockingBehavior { LoadSynchronously, LoadAsynchronously }; |
| 84 | 83 |
| 85 DocumentThreadableLoader(Document&, | 84 DocumentThreadableLoader(Document&, |
| 86 ThreadableLoaderClient*, | 85 ThreadableLoaderClient*, |
| 87 BlockingBehavior, | 86 BlockingBehavior, |
| 88 const ThreadableLoaderOptions&, | 87 const ThreadableLoaderOptions&, |
| 89 const ResourceLoaderOptions&); | 88 const ResourceLoaderOptions&); |
| 90 | 89 |
| 91 void clear(); | 90 void clear(); |
| 92 | 91 |
| 93 // ResourceClient | 92 // ResourceClient |
| 94 // | |
| 95 // |this| may be dead after calling this method. | |
| 96 void notifyFinished(Resource*) override; | 93 void notifyFinished(Resource*) override; |
| 97 | 94 |
| 98 String debugName() const override { return "DocumentThreadableLoader"; } | 95 String debugName() const override { return "DocumentThreadableLoader"; } |
| 99 | 96 |
| 100 // RawResourceClient | 97 // RawResourceClient |
| 101 // | |
| 102 // |this| may be dead after calling these methods. | |
| 103 void dataSent(Resource*, | 98 void dataSent(Resource*, |
| 104 unsigned long long bytesSent, | 99 unsigned long long bytesSent, |
| 105 unsigned long long totalBytesToBeSent) override; | 100 unsigned long long totalBytesToBeSent) override; |
| 106 void responseReceived(Resource*, | 101 void responseReceived(Resource*, |
| 107 const ResourceResponse&, | 102 const ResourceResponse&, |
| 108 std::unique_ptr<WebDataConsumerHandle>) override; | 103 std::unique_ptr<WebDataConsumerHandle>) override; |
| 109 void setSerializedCachedMetadata(Resource*, const char*, size_t) override; | 104 void setSerializedCachedMetadata(Resource*, const char*, size_t) override; |
| 110 void dataReceived(Resource*, const char* data, size_t dataLength) override; | 105 void dataReceived(Resource*, const char* data, size_t dataLength) override; |
| 111 bool redirectReceived(Resource*, | 106 bool redirectReceived(Resource*, |
| 112 const ResourceRequest&, | 107 const ResourceRequest&, |
| 113 const ResourceResponse&) override; | 108 const ResourceResponse&) override; |
| 114 void redirectBlocked() override; | 109 void redirectBlocked() override; |
| 115 void dataDownloaded(Resource*, int) override; | 110 void dataDownloaded(Resource*, int) override; |
| 116 void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) override; | 111 void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) override; |
| 117 | 112 |
| 118 // |this| may be dead after calling this method in async mode. | |
| 119 void cancelWithError(const ResourceError&); | 113 void cancelWithError(const ResourceError&); |
| 120 | 114 |
| 121 // Notify Inspector and log to console about resource response. Use this | 115 // Notify Inspector and log to console about resource response. Use this |
| 122 // method if response is not going to be finished normally. | 116 // method if response is not going to be finished normally. |
| 123 void reportResponseReceived(unsigned long identifier, | 117 void reportResponseReceived(unsigned long identifier, |
| 124 const ResourceResponse&); | 118 const ResourceResponse&); |
| 125 | 119 |
| 126 // Methods containing code to handle resource fetch results which are common | 120 // Methods containing code to handle resource fetch results which are common |
| 127 // to both sync and async mode. | 121 // to both sync and async mode. |
| 128 // | |
| 129 // |this| may be dead after calling these method in async mode. | |
| 130 void handleResponse(unsigned long identifier, | 122 void handleResponse(unsigned long identifier, |
| 131 const ResourceResponse&, | 123 const ResourceResponse&, |
| 132 std::unique_ptr<WebDataConsumerHandle>); | 124 std::unique_ptr<WebDataConsumerHandle>); |
| 133 void handleReceivedData(const char* data, size_t dataLength); | 125 void handleReceivedData(const char* data, size_t dataLength); |
| 134 void handleSuccessfulFinish(unsigned long identifier, double finishTime); | 126 void handleSuccessfulFinish(unsigned long identifier, double finishTime); |
| 135 | 127 |
| 136 // |this| may be dead after calling this method. | |
| 137 void didTimeout(TimerBase*); | 128 void didTimeout(TimerBase*); |
| 138 // Calls the appropriate loading method according to policy and data about | 129 // Calls the appropriate loading method according to policy and data about |
| 139 // origin. Only for handling the initial load (including fallback after | 130 // origin. Only for handling the initial load (including fallback after |
| 140 // consulting ServiceWorker). | 131 // consulting ServiceWorker). |
| 141 // | |
| 142 // |this| may be dead after calling this method in async mode. | |
| 143 void dispatchInitialRequest(const ResourceRequest&); | 132 void dispatchInitialRequest(const ResourceRequest&); |
| 144 // |this| may be dead after calling this method in async mode. | |
| 145 void makeCrossOriginAccessRequest(const ResourceRequest&); | 133 void makeCrossOriginAccessRequest(const ResourceRequest&); |
| 146 // Loads m_fallbackRequestForServiceWorker. | 134 // Loads m_fallbackRequestForServiceWorker. |
| 147 // | |
| 148 // |this| may be dead after calling this method in async mode. | |
| 149 void loadFallbackRequestForServiceWorker(); | 135 void loadFallbackRequestForServiceWorker(); |
| 150 // Loads m_actualRequest. | 136 // Loads m_actualRequest. |
| 151 void loadActualRequest(); | 137 void loadActualRequest(); |
| 152 // Clears m_actualRequest and reports access control check failure to | 138 // Clears m_actualRequest and reports access control check failure to |
| 153 // m_client. | 139 // m_client. |
| 154 // | |
| 155 // |this| may be dead after calling this method in async mode. | |
| 156 void handlePreflightFailure(const String& url, | 140 void handlePreflightFailure(const String& url, |
| 157 const String& errorDescription); | 141 const String& errorDescription); |
| 158 // Investigates the response for the preflight request. If successful, | 142 // Investigates the response for the preflight request. If successful, |
| 159 // the actual request will be made later in handleSuccessfulFinish(). | 143 // the actual request will be made later in handleSuccessfulFinish(). |
| 160 // | |
| 161 // |this| may be dead after calling this method in async mode. | |
| 162 void handlePreflightResponse(const ResourceResponse&); | 144 void handlePreflightResponse(const ResourceResponse&); |
| 163 // |this| may be dead after calling this method. | |
| 164 void handleError(const ResourceError&); | 145 void handleError(const ResourceError&); |
| 165 | 146 |
| 166 void loadRequestAsync(const ResourceRequest&, ResourceLoaderOptions); | 147 void loadRequestAsync(const ResourceRequest&, ResourceLoaderOptions); |
| 167 void loadRequestSync(const ResourceRequest&, ResourceLoaderOptions); | 148 void loadRequestSync(const ResourceRequest&, ResourceLoaderOptions); |
| 168 void loadRequest(const ResourceRequest&, ResourceLoaderOptions); | 149 void loadRequest(const ResourceRequest&, ResourceLoaderOptions); |
| 169 bool isAllowedRedirect(const KURL&) const; | 150 bool isAllowedRedirect(const KURL&) const; |
| 170 // Returns DoNotAllowStoredCredentials if m_forceDoNotAllowStoredCredentials | 151 // Returns DoNotAllowStoredCredentials if m_forceDoNotAllowStoredCredentials |
| 171 // is set. Otherwise, just returns allowCredentials value of | 152 // is set. Otherwise, just returns allowCredentials value of |
| 172 // m_resourceLoaderOptions. | 153 // m_resourceLoaderOptions. |
| 173 StoredCredentials effectiveAllowCredentials() const; | 154 StoredCredentials effectiveAllowCredentials() const; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 // used to populate the HTTP Referer header when following the redirect. | 236 // used to populate the HTTP Referer header when following the redirect. |
| 256 bool m_didRedirect; | 237 bool m_didRedirect; |
| 257 Referrer m_referrerAfterRedirect; | 238 Referrer m_referrerAfterRedirect; |
| 258 | 239 |
| 259 RawResourceClientStateChecker m_checker; | 240 RawResourceClientStateChecker m_checker; |
| 260 }; | 241 }; |
| 261 | 242 |
| 262 } // namespace blink | 243 } // namespace blink |
| 263 | 244 |
| 264 #endif // DocumentThreadableLoader_h | 245 #endif // DocumentThreadableLoader_h |
| OLD | NEW |