| 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" | 25 #include "net/filter/sdch_policy_delegate.h" |
| 26 #include "net/http/http_request_info.h" | 26 #include "net/http/http_request_info.h" |
| 27 #include "net/socket/connection_attempts.h" | 27 #include "net/socket/connection_attempts.h" |
| 28 #include "net/url_request/url_request_job.h" | 28 #include "net/url_request/url_request_job.h" |
| 29 #include "net/url_request/url_request_throttler_entry_interface.h" | 29 #include "net/url_request/url_request_throttler_entry_interface.h" |
| 30 | 30 |
| 31 namespace net { | 31 namespace net { |
| 32 | 32 |
| 33 class HttpRequestHeaders; | 33 class HttpRequestHeaders; |
| 34 class HttpResponseHeaders; | 34 class HttpResponseHeaders; |
| 35 class HttpResponseInfo; | 35 class HttpResponseInfo; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 53 NetworkDelegate* network_delegate, | 53 NetworkDelegate* network_delegate, |
| 54 const HttpUserAgentSettings* http_user_agent_settings); | 54 const HttpUserAgentSettings* http_user_agent_settings); |
| 55 | 55 |
| 56 ~URLRequestHttpJob() override; | 56 ~URLRequestHttpJob() override; |
| 57 | 57 |
| 58 // Overridden from URLRequestJob: | 58 // Overridden from URLRequestJob: |
| 59 void SetPriority(RequestPriority priority) override; | 59 void SetPriority(RequestPriority priority) override; |
| 60 void Start() override; | 60 void Start() override; |
| 61 void Kill() override; | 61 void Kill() override; |
| 62 void GetConnectionAttempts(ConnectionAttempts* out) const override; | 62 void GetConnectionAttempts(ConnectionAttempts* out) const override; |
| 63 std::unique_ptr<SourceStream> SetUpSourceStream() override; |
| 63 | 64 |
| 64 RequestPriority priority() const { | 65 RequestPriority priority() const { |
| 65 return priority_; | 66 return priority_; |
| 66 } | 67 } |
| 67 | 68 |
| 68 private: | 69 private: |
| 69 enum CompletionCause { | 70 enum CompletionCause { |
| 70 ABORTED, | 71 ABORTED, |
| 71 FINISHED | 72 FINISHED |
| 72 }; | 73 }; |
| 73 | 74 |
| 74 typedef base::RefCountedData<bool> SharedBoolean; | 75 typedef base::RefCountedData<bool> SharedBoolean; |
| 75 | 76 |
| 76 class HttpFilterContext; | 77 class SdchContext; |
| 77 | 78 |
| 78 // 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. |
| 79 void NotifyHeadersComplete(); | 80 void NotifyHeadersComplete(); |
| 80 | 81 |
| 81 void DestroyTransaction(); | 82 void DestroyTransaction(); |
| 82 | 83 |
| 83 void AddExtraHeaders(); | 84 void AddExtraHeaders(); |
| 84 void AddCookieHeaderAndStart(); | 85 void AddCookieHeaderAndStart(); |
| 85 void SaveCookiesAndNotifyHeadersComplete(int result); | 86 void SaveCookiesAndNotifyHeadersComplete(int result); |
| 86 void FetchResponseCookies(std::vector<std::string>* cookies); | 87 void FetchResponseCookies(std::vector<std::string>* cookies); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 114 void SetExtraRequestHeaders(const HttpRequestHeaders& headers) override; | 115 void SetExtraRequestHeaders(const HttpRequestHeaders& headers) override; |
| 115 LoadState GetLoadState() const override; | 116 LoadState GetLoadState() const override; |
| 116 UploadProgress GetUploadProgress() const override; | 117 UploadProgress GetUploadProgress() const override; |
| 117 bool GetMimeType(std::string* mime_type) const override; | 118 bool GetMimeType(std::string* mime_type) const override; |
| 118 bool GetCharset(std::string* charset) override; | 119 bool GetCharset(std::string* charset) override; |
| 119 void GetResponseInfo(HttpResponseInfo* info) override; | 120 void GetResponseInfo(HttpResponseInfo* info) override; |
| 120 void GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override; | 121 void GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override; |
| 121 bool GetRemoteEndpoint(IPEndPoint* endpoint) const override; | 122 bool GetRemoteEndpoint(IPEndPoint* endpoint) const override; |
| 122 int GetResponseCode() const override; | 123 int GetResponseCode() const override; |
| 123 void PopulateNetErrorDetails(NetErrorDetails* details) const override; | 124 void PopulateNetErrorDetails(NetErrorDetails* details) const override; |
| 124 std::unique_ptr<Filter> SetupFilter() const override; | |
| 125 bool CopyFragmentOnRedirect(const GURL& location) const override; | 125 bool CopyFragmentOnRedirect(const GURL& location) const override; |
| 126 bool IsSafeRedirect(const GURL& location) override; | 126 bool IsSafeRedirect(const GURL& location) override; |
| 127 bool NeedsAuth() override; | 127 bool NeedsAuth() override; |
| 128 void GetAuthChallengeInfo(scoped_refptr<AuthChallengeInfo>*) override; | 128 void GetAuthChallengeInfo(scoped_refptr<AuthChallengeInfo>*) override; |
| 129 void SetAuth(const AuthCredentials& credentials) override; | 129 void SetAuth(const AuthCredentials& credentials) override; |
| 130 void CancelAuth() override; | 130 void CancelAuth() override; |
| 131 void ContinueWithCertificate(X509Certificate* client_cert, | 131 void ContinueWithCertificate(X509Certificate* client_cert, |
| 132 SSLPrivateKey* client_private_key) override; | 132 SSLPrivateKey* client_private_key) override; |
| 133 void ContinueDespiteLastError() override; | 133 void ContinueDespiteLastError() override; |
| 134 void ResumeNetworkStart() override; | 134 void ResumeNetworkStart() override; |
| 135 int ReadRawData(IOBuffer* buf, int buf_size) override; | 135 int ReadRawData(IOBuffer* buf, int buf_size) override; |
| 136 void StopCaching() override; | 136 void StopCaching() override; |
| 137 bool GetFullRequestHeaders(HttpRequestHeaders* headers) const override; | 137 bool GetFullRequestHeaders(HttpRequestHeaders* headers) const override; |
| 138 int64_t GetTotalReceivedBytes() const override; | 138 int64_t GetTotalReceivedBytes() const override; |
| 139 int64_t GetTotalSentBytes() const override; | 139 int64_t GetTotalSentBytes() const override; |
| 140 void DoneReading() override; | 140 void DoneReading() override; |
| 141 void DoneReadingRedirectResponse() override; | 141 void DoneReadingRedirectResponse() override; |
| 142 | 142 |
| 143 HostPortPair GetSocketAddress() const override; | 143 HostPortPair GetSocketAddress() const override; |
| 144 void NotifyURLRequestDestroyed() override; | 144 void NotifyURLRequestDestroyed() override; |
| 145 | 145 |
| 146 void RecordTimer(); | 146 void RecordTimer(); |
| 147 void ResetTimer(); | 147 void ResetTimer(); |
| 148 | 148 |
| 149 void UpdatePacketReadTimes() override; | 149 void UpdatePacketReadTimes() override; |
| 150 void RecordPacketStats(FilterContext::StatisticSelector statistic) const; | 150 void RecordPacketStats( |
| 151 SdchPolicyDelegate::Context::StatisticSelector statistic) const; |
| 151 | 152 |
| 152 // Starts the transaction if extensions using the webrequest API do not | 153 // Starts the transaction if extensions using the webrequest API do not |
| 153 // object. | 154 // object. |
| 154 void StartTransaction(); | 155 void StartTransaction(); |
| 155 // If |result| is OK, calls StartTransactionInternal. Otherwise notifies | 156 // If |result| is OK, calls StartTransactionInternal. Otherwise notifies |
| 156 // cancellation. | 157 // cancellation. |
| 157 void MaybeStartTransactionInternal(int result); | 158 void MaybeStartTransactionInternal(int result); |
| 158 void StartTransactionInternal(); | 159 void StartTransactionInternal(); |
| 159 | 160 |
| 160 void RecordPerfHistograms(CompletionCause reason); | 161 void RecordPerfHistograms(CompletionCause reason); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // Since we don't save all packet times in packet_times_, we save the | 236 // Since we don't save all packet times in packet_times_, we save the |
| 236 // last time for use in histograms. | 237 // last time for use in histograms. |
| 237 base::Time final_packet_time_; | 238 base::Time final_packet_time_; |
| 238 | 239 |
| 239 // The start time for the job, ignoring re-starts. | 240 // The start time for the job, ignoring re-starts. |
| 240 base::TimeTicks start_time_; | 241 base::TimeTicks start_time_; |
| 241 | 242 |
| 242 // When the transaction finished reading the request headers. | 243 // When the transaction finished reading the request headers. |
| 243 base::TimeTicks receive_headers_end_; | 244 base::TimeTicks receive_headers_end_; |
| 244 | 245 |
| 245 std::unique_ptr<HttpFilterContext> filter_context_; | 246 std::unique_ptr<SdchPolicyDelegate> sdch_delegate_; |
| 246 | 247 |
| 247 CompletionCallback on_headers_received_callback_; | 248 CompletionCallback on_headers_received_callback_; |
| 248 | 249 |
| 249 // We allow the network delegate to modify a copy of the response headers. | 250 // We allow the network delegate to modify a copy of the response headers. |
| 250 // This prevents modifications of headers that are shared with the underlying | 251 // This prevents modifications of headers that are shared with the underlying |
| 251 // layers of the network stack. | 252 // layers of the network stack. |
| 252 scoped_refptr<HttpResponseHeaders> override_response_headers_; | 253 scoped_refptr<HttpResponseHeaders> override_response_headers_; |
| 253 | 254 |
| 254 // The network delegate can mark a URL as safe for redirection. | 255 // The network delegate can mark a URL as safe for redirection. |
| 255 // The reference fragment of the original URL is not appended to the redirect | 256 // The reference fragment of the original URL is not appended to the redirect |
| (...skipping 17 matching lines...) Expand all Loading... |
| 273 int64_t total_sent_bytes_from_previous_transactions_; | 274 int64_t total_sent_bytes_from_previous_transactions_; |
| 274 | 275 |
| 275 base::WeakPtrFactory<URLRequestHttpJob> weak_factory_; | 276 base::WeakPtrFactory<URLRequestHttpJob> weak_factory_; |
| 276 | 277 |
| 277 DISALLOW_COPY_AND_ASSIGN(URLRequestHttpJob); | 278 DISALLOW_COPY_AND_ASSIGN(URLRequestHttpJob); |
| 278 }; | 279 }; |
| 279 | 280 |
| 280 } // namespace net | 281 } // namespace net |
| 281 | 282 |
| 282 #endif // NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ | 283 #endif // NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ |
| OLD | NEW |