| 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); |
| 97 void handleSuccessfulFinish(unsigned long identifier, double finishTime)
; | 108 void handleSuccessfulFinish(unsigned long identifier, double finishTime)
; |
| 98 | 109 |
| 110 // |this| may be dead after calling this method. |
| 99 void didTimeout(Timer<DocumentThreadableLoader>*); | 111 void didTimeout(Timer<DocumentThreadableLoader>*); |
| 100 // Calls the appropriate loading method according to policy and data | 112 // Calls the appropriate loading method according to policy and data |
| 101 // about origin. Only for handling the initial load (including fallback | 113 // about origin. Only for handling the initial load (including fallback |
| 102 // after consulting ServiceWorker). | 114 // after consulting ServiceWorker). |
| 115 // |
| 116 // |this| may be dead after calling this method in async mode. |
| 103 void dispatchInitialRequest(const ResourceRequest&); | 117 void dispatchInitialRequest(const ResourceRequest&); |
| 118 // |this| may be dead after calling this method in async mode. |
| 104 void makeCrossOriginAccessRequest(const ResourceRequest&); | 119 void makeCrossOriginAccessRequest(const ResourceRequest&); |
| 105 // Loads m_fallbackRequestForServiceWorker. | 120 // Loads m_fallbackRequestForServiceWorker. |
| 121 // |
| 122 // |this| may be dead after calling this method in async mode. |
| 106 void loadFallbackRequestForServiceWorker(); | 123 void loadFallbackRequestForServiceWorker(); |
| 107 // Loads m_actualRequest. | 124 // Loads m_actualRequest. |
| 108 void loadActualRequest(); | 125 void loadActualRequest(); |
| 109 // Clears m_actualRequest and reports access control check failure to | 126 // Clears m_actualRequest and reports access control check failure to |
| 110 // m_client. | 127 // m_client. |
| 128 // |
| 129 // |this| may be dead after calling this method in async mode. |
| 111 void handlePreflightFailure(const String& url, const String& errorDescri
ption); | 130 void handlePreflightFailure(const String& url, const String& errorDescri
ption); |
| 112 // Investigates the response for the preflight request. If successful, | 131 // Investigates the response for the preflight request. If successful, |
| 113 // the actual request will be made later in handleSuccessfulFinish(). | 132 // the actual request will be made later in handleSuccessfulFinish(). |
| 133 // |
| 134 // |this| may be dead after calling this method in async mode. |
| 114 void handlePreflightResponse(const ResourceResponse&); | 135 void handlePreflightResponse(const ResourceResponse&); |
| 136 // |this| may be dead after calling this method. |
| 137 void handleError(const ResourceError&); |
| 115 | 138 |
| 116 void loadRequest(const ResourceRequest&, ResourceLoaderOptions); | 139 void loadRequest(const ResourceRequest&, ResourceLoaderOptions); |
| 117 bool isAllowedRedirect(const KURL&) const; | 140 bool isAllowedRedirect(const KURL&) const; |
| 118 bool isAllowedByContentSecurityPolicy(const KURL&, ContentSecurityPolicy
::RedirectStatus) const; | 141 bool isAllowedByContentSecurityPolicy(const KURL&, ContentSecurityPolicy
::RedirectStatus) const; |
| 119 // Returns DoNotAllowStoredCredentials | 142 // Returns DoNotAllowStoredCredentials |
| 120 // if m_forceDoNotAllowStoredCredentials is set. Otherwise, just | 143 // if m_forceDoNotAllowStoredCredentials is set. Otherwise, just |
| 121 // returns allowCredentials value of m_resourceLoaderOptions. | 144 // returns allowCredentials value of m_resourceLoaderOptions. |
| 122 StoredCredentials effectiveAllowCredentials() const; | 145 StoredCredentials effectiveAllowCredentials() const; |
| 123 | 146 |
| 124 SecurityOrigin* securityOrigin() const; | 147 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, | 193 // But this value is not the max number of total redirects allowed, |
| 171 // because same-origin redirects are not counted here. | 194 // because same-origin redirects are not counted here. |
| 172 int m_corsRedirectLimit; | 195 int m_corsRedirectLimit; |
| 173 | 196 |
| 174 const WebURLRequest::FetchRedirectMode m_redirectMode; | 197 const WebURLRequest::FetchRedirectMode m_redirectMode; |
| 175 }; | 198 }; |
| 176 | 199 |
| 177 } // namespace blink | 200 } // namespace blink |
| 178 | 201 |
| 179 #endif // DocumentThreadableLoader_h | 202 #endif // DocumentThreadableLoader_h |
| OLD | NEW |