| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ |
| 6 #define NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "net/base/auth.h" | 19 #include "net/base/auth.h" |
| 20 #include "net/base/completion_callback.h" | 20 #include "net/base/completion_callback.h" |
| 21 #include "net/base/net_error_details.h" | 21 #include "net/base/net_error_details.h" |
| 22 #include "net/base/net_export.h" | 22 #include "net/base/net_export.h" |
| 23 #include "net/base/sdch_manager.h" | 23 #include "net/base/sdch_manager.h" |
| 24 #include "net/cookies/cookie_store.h" | 24 #include "net/cookies/cookie_store.h" |
| 25 #include "net/filter/filter.h" | |
| 26 #include "net/http/http_request_info.h" | 25 #include "net/http/http_request_info.h" |
| 27 #include "net/socket/connection_attempts.h" | 26 #include "net/socket/connection_attempts.h" |
| 28 #include "net/url_request/url_request_backoff_manager.h" | 27 #include "net/url_request/url_request_backoff_manager.h" |
| 29 #include "net/url_request/url_request_job.h" | 28 #include "net/url_request/url_request_job.h" |
| 30 #include "net/url_request/url_request_throttler_entry_interface.h" | 29 #include "net/url_request/url_request_throttler_entry_interface.h" |
| 31 | 30 |
| 32 namespace net { | 31 namespace net { |
| 33 | 32 |
| 34 class HttpRequestHeaders; | 33 class HttpRequestHeaders; |
| 35 class HttpResponseHeaders; | 34 class HttpResponseHeaders; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 66 } |
| 68 | 67 |
| 69 private: | 68 private: |
| 70 enum CompletionCause { | 69 enum CompletionCause { |
| 71 ABORTED, | 70 ABORTED, |
| 72 FINISHED | 71 FINISHED |
| 73 }; | 72 }; |
| 74 | 73 |
| 75 typedef base::RefCountedData<bool> SharedBoolean; | 74 typedef base::RefCountedData<bool> SharedBoolean; |
| 76 | 75 |
| 77 class HttpFilterContext; | |
| 78 | |
| 79 // Shadows URLRequestJob's version of this method. | 76 // Shadows URLRequestJob's version of this method. |
| 80 void NotifyBeforeNetworkStart(bool* defer); | 77 void NotifyBeforeNetworkStart(bool* defer); |
| 81 | 78 |
| 82 // Shadows URLRequestJob's version of this method so we can grab cookies. | 79 // Shadows URLRequestJob's version of this method so we can grab cookies. |
| 83 void NotifyHeadersComplete(); | 80 void NotifyHeadersComplete(); |
| 84 | 81 |
| 85 void DestroyTransaction(); | 82 void DestroyTransaction(); |
| 86 | 83 |
| 87 void AddExtraHeaders(); | 84 void AddExtraHeaders(); |
| 88 void AddCookieHeaderAndStart(); | 85 void AddCookieHeaderAndStart(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 LoadState GetLoadState() const override; | 117 LoadState GetLoadState() const override; |
| 121 UploadProgress GetUploadProgress() const override; | 118 UploadProgress GetUploadProgress() const override; |
| 122 bool GetMimeType(std::string* mime_type) const override; | 119 bool GetMimeType(std::string* mime_type) const override; |
| 123 bool GetCharset(std::string* charset) override; | 120 bool GetCharset(std::string* charset) override; |
| 124 void GetResponseInfo(HttpResponseInfo* info) override; | 121 void GetResponseInfo(HttpResponseInfo* info) override; |
| 125 void GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override; | 122 void GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override; |
| 126 bool GetRemoteEndpoint(IPEndPoint* endpoint) const override; | 123 bool GetRemoteEndpoint(IPEndPoint* endpoint) const override; |
| 127 bool GetResponseCookies(std::vector<std::string>* cookies) override; | 124 bool GetResponseCookies(std::vector<std::string>* cookies) override; |
| 128 int GetResponseCode() const override; | 125 int GetResponseCode() const override; |
| 129 void PopulateNetErrorDetails(NetErrorDetails* details) const override; | 126 void PopulateNetErrorDetails(NetErrorDetails* details) const override; |
| 130 Filter* SetupFilter() const override; | 127 std::unique_ptr<StreamSource> SetupSource() override; |
| 131 bool CopyFragmentOnRedirect(const GURL& location) const override; | 128 bool CopyFragmentOnRedirect(const GURL& location) const override; |
| 132 bool IsSafeRedirect(const GURL& location) override; | 129 bool IsSafeRedirect(const GURL& location) override; |
| 133 bool NeedsAuth() override; | 130 bool NeedsAuth() override; |
| 134 void GetAuthChallengeInfo(scoped_refptr<AuthChallengeInfo>*) override; | 131 void GetAuthChallengeInfo(scoped_refptr<AuthChallengeInfo>*) override; |
| 135 void SetAuth(const AuthCredentials& credentials) override; | 132 void SetAuth(const AuthCredentials& credentials) override; |
| 136 void CancelAuth() override; | 133 void CancelAuth() override; |
| 137 void ContinueWithCertificate(X509Certificate* client_cert, | 134 void ContinueWithCertificate(X509Certificate* client_cert, |
| 138 SSLPrivateKey* client_private_key) override; | 135 SSLPrivateKey* client_private_key) override; |
| 139 void ContinueDespiteLastError() override; | 136 void ContinueDespiteLastError() override; |
| 140 void ResumeNetworkStart() override; | 137 void ResumeNetworkStart() override; |
| 141 int ReadRawData(IOBuffer* buf, int buf_size) override; | 138 int ReadRawData(IOBuffer* buf, int buf_size) override; |
| 142 void StopCaching() override; | 139 void StopCaching() override; |
| 143 bool GetFullRequestHeaders(HttpRequestHeaders* headers) const override; | 140 bool GetFullRequestHeaders(HttpRequestHeaders* headers) const override; |
| 144 int64_t GetTotalReceivedBytes() const override; | 141 int64_t GetTotalReceivedBytes() const override; |
| 145 int64_t GetTotalSentBytes() const override; | 142 int64_t GetTotalSentBytes() const override; |
| 146 void DoneReading() override; | 143 void DoneReading() override; |
| 147 void DoneReadingRedirectResponse() override; | 144 void DoneReadingRedirectResponse() override; |
| 148 | 145 |
| 149 HostPortPair GetSocketAddress() const override; | 146 HostPortPair GetSocketAddress() const override; |
| 150 void NotifyURLRequestDestroyed() override; | 147 void NotifyURLRequestDestroyed() override; |
| 151 | 148 |
| 152 void RecordTimer(); | 149 void RecordTimer(); |
| 153 void ResetTimer(); | 150 void ResetTimer(); |
| 154 | 151 |
| 155 void UpdatePacketReadTimes() override; | 152 void UpdatePacketReadTimes() override; |
| 156 void RecordPacketStats(FilterContext::StatisticSelector statistic) const; | |
| 157 | 153 |
| 158 // Starts the transaction if extensions using the webrequest API do not | 154 // Starts the transaction if extensions using the webrequest API do not |
| 159 // object. | 155 // object. |
| 160 void StartTransaction(); | 156 void StartTransaction(); |
| 161 // If |result| is OK, calls StartTransactionInternal. Otherwise notifies | 157 // If |result| is OK, calls StartTransactionInternal. Otherwise notifies |
| 162 // cancellation. | 158 // cancellation. |
| 163 void MaybeStartTransactionInternal(int result); | 159 void MaybeStartTransactionInternal(int result); |
| 164 void StartTransactionInternal(); | 160 void StartTransactionInternal(); |
| 165 | 161 |
| 166 void RecordPerfHistograms(CompletionCause reason); | 162 void RecordPerfHistograms(CompletionCause reason); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // Since we don't save all packet times in packet_times_, we save the | 237 // Since we don't save all packet times in packet_times_, we save the |
| 242 // last time for use in histograms. | 238 // last time for use in histograms. |
| 243 base::Time final_packet_time_; | 239 base::Time final_packet_time_; |
| 244 | 240 |
| 245 // The start time for the job, ignoring re-starts. | 241 // The start time for the job, ignoring re-starts. |
| 246 base::TimeTicks start_time_; | 242 base::TimeTicks start_time_; |
| 247 | 243 |
| 248 // When the transaction finished reading the request headers. | 244 // When the transaction finished reading the request headers. |
| 249 base::TimeTicks receive_headers_end_; | 245 base::TimeTicks receive_headers_end_; |
| 250 | 246 |
| 251 std::unique_ptr<HttpFilterContext> filter_context_; | |
| 252 | |
| 253 CompletionCallback on_headers_received_callback_; | 247 CompletionCallback on_headers_received_callback_; |
| 254 | 248 |
| 255 // We allow the network delegate to modify a copy of the response headers. | 249 // We allow the network delegate to modify a copy of the response headers. |
| 256 // This prevents modifications of headers that are shared with the underlying | 250 // This prevents modifications of headers that are shared with the underlying |
| 257 // layers of the network stack. | 251 // layers of the network stack. |
| 258 scoped_refptr<HttpResponseHeaders> override_response_headers_; | 252 scoped_refptr<HttpResponseHeaders> override_response_headers_; |
| 259 | 253 |
| 260 // The network delegate can mark a URL as safe for redirection. | 254 // The network delegate can mark a URL as safe for redirection. |
| 261 // The reference fragment of the original URL is not appended to the redirect | 255 // The reference fragment of the original URL is not appended to the redirect |
| 262 // URL when the redirect URL is equal to |allowed_unsafe_redirect_url_|. | 256 // URL when the redirect URL is equal to |allowed_unsafe_redirect_url_|. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 281 int64_t total_sent_bytes_from_previous_transactions_; | 275 int64_t total_sent_bytes_from_previous_transactions_; |
| 282 | 276 |
| 283 base::WeakPtrFactory<URLRequestHttpJob> weak_factory_; | 277 base::WeakPtrFactory<URLRequestHttpJob> weak_factory_; |
| 284 | 278 |
| 285 DISALLOW_COPY_AND_ASSIGN(URLRequestHttpJob); | 279 DISALLOW_COPY_AND_ASSIGN(URLRequestHttpJob); |
| 286 }; | 280 }; |
| 287 | 281 |
| 288 } // namespace net | 282 } // namespace net |
| 289 | 283 |
| 290 #endif // NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ | 284 #endif // NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ |
| OLD | NEW |