| 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 26 matching lines...) Expand all Loading... |
| 113 void SetUpload(UploadDataStream* upload) override; | 114 void SetUpload(UploadDataStream* upload) override; |
| 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 bool GetMimeType(std::string* mime_type) const override; | 117 bool GetMimeType(std::string* mime_type) const override; |
| 117 bool GetCharset(std::string* charset) override; | 118 bool GetCharset(std::string* charset) override; |
| 118 void GetResponseInfo(HttpResponseInfo* info) override; | 119 void GetResponseInfo(HttpResponseInfo* info) override; |
| 119 void GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override; | 120 void GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override; |
| 120 bool GetRemoteEndpoint(IPEndPoint* endpoint) const override; | 121 bool GetRemoteEndpoint(IPEndPoint* endpoint) const override; |
| 121 int GetResponseCode() const override; | 122 int GetResponseCode() const override; |
| 122 void PopulateNetErrorDetails(NetErrorDetails* details) const override; | 123 void PopulateNetErrorDetails(NetErrorDetails* details) const override; |
| 123 std::unique_ptr<Filter> SetupFilter() const override; | |
| 124 bool CopyFragmentOnRedirect(const GURL& location) const override; | 124 bool CopyFragmentOnRedirect(const GURL& location) const override; |
| 125 bool IsSafeRedirect(const GURL& location) override; | 125 bool IsSafeRedirect(const GURL& location) override; |
| 126 bool NeedsAuth() override; | 126 bool NeedsAuth() override; |
| 127 void GetAuthChallengeInfo(scoped_refptr<AuthChallengeInfo>*) override; | 127 void GetAuthChallengeInfo(scoped_refptr<AuthChallengeInfo>*) override; |
| 128 void SetAuth(const AuthCredentials& credentials) override; | 128 void SetAuth(const AuthCredentials& credentials) override; |
| 129 void CancelAuth() override; | 129 void CancelAuth() override; |
| 130 void ContinueWithCertificate(X509Certificate* client_cert, | 130 void ContinueWithCertificate(X509Certificate* client_cert, |
| 131 SSLPrivateKey* client_private_key) override; | 131 SSLPrivateKey* client_private_key) override; |
| 132 void ContinueDespiteLastError() override; | 132 void ContinueDespiteLastError() override; |
| 133 int ReadRawData(IOBuffer* buf, int buf_size) override; | 133 int ReadRawData(IOBuffer* buf, int buf_size) override; |
| 134 void StopCaching() override; | 134 void StopCaching() override; |
| 135 bool GetFullRequestHeaders(HttpRequestHeaders* headers) const override; | 135 bool GetFullRequestHeaders(HttpRequestHeaders* headers) const override; |
| 136 int64_t GetTotalReceivedBytes() const override; | 136 int64_t GetTotalReceivedBytes() const override; |
| 137 int64_t GetTotalSentBytes() const override; | 137 int64_t GetTotalSentBytes() const override; |
| 138 void DoneReading() override; | 138 void DoneReading() override; |
| 139 void DoneReadingRedirectResponse() override; | 139 void DoneReadingRedirectResponse() override; |
| 140 | 140 |
| 141 HostPortPair GetSocketAddress() const override; | 141 HostPortPair GetSocketAddress() const override; |
| 142 void NotifyURLRequestDestroyed() override; | 142 void NotifyURLRequestDestroyed() override; |
| 143 | 143 |
| 144 void RecordTimer(); | 144 void RecordTimer(); |
| 145 void ResetTimer(); | 145 void ResetTimer(); |
| 146 | 146 |
| 147 void UpdatePacketReadTimes() override; | 147 void UpdatePacketReadTimes() override; |
| 148 void RecordPacketStats(FilterContext::StatisticSelector statistic) const; | 148 void RecordPacketStats( |
| 149 SdchPolicyDelegate::Context::StatisticSelector statistic) const; |
| 149 | 150 |
| 150 // Starts the transaction if extensions using the webrequest API do not | 151 // Starts the transaction if extensions using the webrequest API do not |
| 151 // object. | 152 // object. |
| 152 void StartTransaction(); | 153 void StartTransaction(); |
| 153 // If |result| is OK, calls StartTransactionInternal. Otherwise notifies | 154 // If |result| is OK, calls StartTransactionInternal. Otherwise notifies |
| 154 // cancellation. | 155 // cancellation. |
| 155 void MaybeStartTransactionInternal(int result); | 156 void MaybeStartTransactionInternal(int result); |
| 156 void StartTransactionInternal(); | 157 void StartTransactionInternal(); |
| 157 | 158 |
| 158 void RecordPerfHistograms(CompletionCause reason); | 159 void RecordPerfHistograms(CompletionCause reason); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // Since we don't save all packet times in packet_times_, we save the | 234 // Since we don't save all packet times in packet_times_, we save the |
| 234 // last time for use in histograms. | 235 // last time for use in histograms. |
| 235 base::Time final_packet_time_; | 236 base::Time final_packet_time_; |
| 236 | 237 |
| 237 // The start time for the job, ignoring re-starts. | 238 // The start time for the job, ignoring re-starts. |
| 238 base::TimeTicks start_time_; | 239 base::TimeTicks start_time_; |
| 239 | 240 |
| 240 // When the transaction finished reading the request headers. | 241 // When the transaction finished reading the request headers. |
| 241 base::TimeTicks receive_headers_end_; | 242 base::TimeTicks receive_headers_end_; |
| 242 | 243 |
| 243 std::unique_ptr<HttpFilterContext> filter_context_; | 244 std::unique_ptr<SdchPolicyDelegate> sdch_delegate_; |
| 244 | 245 |
| 245 CompletionCallback on_headers_received_callback_; | 246 CompletionCallback on_headers_received_callback_; |
| 246 | 247 |
| 247 // We allow the network delegate to modify a copy of the response headers. | 248 // We allow the network delegate to modify a copy of the response headers. |
| 248 // This prevents modifications of headers that are shared with the underlying | 249 // This prevents modifications of headers that are shared with the underlying |
| 249 // layers of the network stack. | 250 // layers of the network stack. |
| 250 scoped_refptr<HttpResponseHeaders> override_response_headers_; | 251 scoped_refptr<HttpResponseHeaders> override_response_headers_; |
| 251 | 252 |
| 252 // The network delegate can mark a URL as safe for redirection. | 253 // The network delegate can mark a URL as safe for redirection. |
| 253 // The reference fragment of the original URL is not appended to the redirect | 254 // The reference fragment of the original URL is not appended to the redirect |
| (...skipping 17 matching lines...) Expand all Loading... |
| 271 int64_t total_sent_bytes_from_previous_transactions_; | 272 int64_t total_sent_bytes_from_previous_transactions_; |
| 272 | 273 |
| 273 base::WeakPtrFactory<URLRequestHttpJob> weak_factory_; | 274 base::WeakPtrFactory<URLRequestHttpJob> weak_factory_; |
| 274 | 275 |
| 275 DISALLOW_COPY_AND_ASSIGN(URLRequestHttpJob); | 276 DISALLOW_COPY_AND_ASSIGN(URLRequestHttpJob); |
| 276 }; | 277 }; |
| 277 | 278 |
| 278 } // namespace net | 279 } // namespace net |
| 279 | 280 |
| 280 #endif // NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ | 281 #endif // NET_URL_REQUEST_URL_REQUEST_HTTP_JOB_H_ |
| OLD | NEW |