Chromium Code Reviews| 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_JOB_H_ | 5 #ifndef NET_URL_REQUEST_URL_REQUEST_JOB_H_ |
| 6 #define NET_URL_REQUEST_URL_REQUEST_JOB_H_ | 6 #define NET_URL_REQUEST_URL_REQUEST_JOB_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/power_monitor/power_observer.h" | 17 #include "base/power_monitor/power_observer.h" |
| 18 #include "net/base/host_port_pair.h" | 18 #include "net/base/host_port_pair.h" |
| 19 #include "net/base/load_states.h" | 19 #include "net/base/load_states.h" |
| 20 #include "net/base/net_error_details.h" | 20 #include "net/base/net_error_details.h" |
| 21 #include "net/base/net_export.h" | 21 #include "net/base/net_export.h" |
| 22 #include "net/base/request_priority.h" | 22 #include "net/base/request_priority.h" |
| 23 #include "net/base/upload_progress.h" | 23 #include "net/base/upload_progress.h" |
| 24 #include "net/cookies/canonical_cookie.h" | 24 #include "net/cookies/canonical_cookie.h" |
| 25 #include "net/filter/stream_source.h" | |
| 25 #include "net/socket/connection_attempts.h" | 26 #include "net/socket/connection_attempts.h" |
| 26 #include "net/url_request/redirect_info.h" | 27 #include "net/url_request/redirect_info.h" |
| 27 #include "net/url_request/url_request.h" | 28 #include "net/url_request/url_request.h" |
| 28 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| 29 | 30 |
| 30 namespace net { | 31 namespace net { |
| 31 | 32 |
| 32 class AuthChallengeInfo; | 33 class AuthChallengeInfo; |
| 33 class AuthCredentials; | 34 class AuthCredentials; |
| 34 class CookieOptions; | 35 class CookieOptions; |
| 35 class Filter; | 36 class Filter; |
| 36 class HttpRequestHeaders; | 37 class HttpRequestHeaders; |
| 37 class HttpResponseInfo; | 38 class HttpResponseInfo; |
| 38 class IOBuffer; | 39 class IOBuffer; |
| 39 struct LoadTimingInfo; | 40 struct LoadTimingInfo; |
| 40 class NetworkDelegate; | 41 class NetworkDelegate; |
| 41 class SSLCertRequestInfo; | 42 class SSLCertRequestInfo; |
| 42 class SSLInfo; | 43 class SSLInfo; |
| 43 class SSLPrivateKey; | 44 class SSLPrivateKey; |
| 44 class UploadDataStream; | 45 class UploadDataStream; |
| 45 class URLRequestStatus; | 46 class URLRequestStatus; |
| 46 class X509Certificate; | 47 class X509Certificate; |
| 47 | 48 |
| 48 class NET_EXPORT URLRequestJob : public base::PowerObserver { | 49 class NET_EXPORT URLRequestJob : public base::PowerObserver { |
| 49 public: | 50 public: |
| 51 typedef base::Callback<void(net::Error, size_t)> ReadRawCompleteCallback; | |
|
mmenke
2016/07/21 18:14:10
Is this even used?
If not, remove it.
If so, nee
xunjieli
2016/07/27 20:32:04
Done. Sorry, it isn't used.
| |
| 50 explicit URLRequestJob(URLRequest* request, | 52 explicit URLRequestJob(URLRequest* request, |
| 51 NetworkDelegate* network_delegate); | 53 NetworkDelegate* network_delegate); |
| 52 ~URLRequestJob() override; | 54 ~URLRequestJob() override; |
| 53 | 55 |
| 54 // Returns the request that owns this job. | 56 // Returns the request that owns this job. |
| 55 URLRequest* request() const { | 57 URLRequest* request() const { |
| 56 return request_; | 58 return request_; |
| 57 } | 59 } |
| 58 | 60 |
| 59 // Sets the upload data, most requests have no upload data, so this is a NOP. | 61 // Sets the upload data, most requests have no upload data, so this is a NOP. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 | 138 |
| 137 // Gets the remote endpoint that the network stack is currently fetching the | 139 // Gets the remote endpoint that the network stack is currently fetching the |
| 138 // URL from. Returns true and fills in |endpoint| if it is available; returns | 140 // URL from. Returns true and fills in |endpoint| if it is available; returns |
| 139 // false and leaves |endpoint| unchanged if it is unavailable. | 141 // false and leaves |endpoint| unchanged if it is unavailable. |
| 140 virtual bool GetRemoteEndpoint(IPEndPoint* endpoint) const; | 142 virtual bool GetRemoteEndpoint(IPEndPoint* endpoint) const; |
| 141 | 143 |
| 142 // Populates the network error details of the most recent origin that the | 144 // Populates the network error details of the most recent origin that the |
| 143 // network stack makes the request to. | 145 // network stack makes the request to. |
| 144 virtual void PopulateNetErrorDetails(NetErrorDetails* details) const; | 146 virtual void PopulateNetErrorDetails(NetErrorDetails* details) const; |
| 145 | 147 |
| 146 // Called to setup a stream filter for this request. An example of filter is | 148 // Called to set up a StreamSource chain for this request. |
| 147 // content encoding/decoding. | 149 // Subclasses should return the appropriate first StreamSource of the chain, |
| 148 // Subclasses should return the appropriate Filter, or NULL for no Filter. | 150 // or nullptr if no StreamSource should be used. This class takes ownership of |
|
mmenke
2016/07/21 18:14:10
"... or nullptr on error"?
xunjieli
2016/07/27 20:32:04
Done.
| |
| 149 // This class takes ownership of the returned Filter. | 151 // the returned StreamSource. |
| 150 // | 152 virtual std::unique_ptr<StreamSource> SetupSource(); |
|
mmenke
2016/07/21 18:14:10
This should be private, right? It's an old commen
xunjieli
2016/07/27 20:32:05
Do you mean protected instead? The subclasses (htt
mmenke
2016/07/28 18:40:12
Oops...I didn't realize subclasses recursively cal
| |
| 151 // The default implementation returns NULL. | |
| 152 virtual std::unique_ptr<Filter> SetupFilter() const; | |
| 153 | 153 |
| 154 // Called to determine if this response is a redirect. Only makes sense | 154 // Called to determine if this response is a redirect. Only makes sense |
| 155 // for some types of requests. This method returns true if the response | 155 // for some types of requests. This method returns true if the response |
| 156 // is a redirect, and fills in the location param with the URL of the | 156 // is a redirect, and fills in the location param with the URL of the |
| 157 // redirect. The HTTP status code (e.g., 302) is filled into | 157 // redirect. The HTTP status code (e.g., 302) is filled into |
| 158 // |*http_status_code| to signify the type of redirect. | 158 // |*http_status_code| to signify the type of redirect. |
| 159 // | 159 // |
| 160 // The caller is responsible for following the redirect by setting up an | 160 // The caller is responsible for following the redirect by setting up an |
| 161 // appropriate replacement Job. Note that the redirected location may be | 161 // appropriate replacement Job. Note that the redirected location may be |
| 162 // invalid, the caller should be sure it can handle this. | 162 // invalid, the caller should be sure it can handle this. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 | 209 |
| 210 // Get/Set expected content size | 210 // Get/Set expected content size |
| 211 int64_t expected_content_size() const { return expected_content_size_; } | 211 int64_t expected_content_size() const { return expected_content_size_; } |
| 212 void set_expected_content_size(const int64_t& size) { | 212 void set_expected_content_size(const int64_t& size) { |
| 213 expected_content_size_ = size; | 213 expected_content_size_ = size; |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Whether we have processed the response for that request yet. | 216 // Whether we have processed the response for that request yet. |
| 217 bool has_response_started() const { return has_handled_response_; } | 217 bool has_response_started() const { return has_handled_response_; } |
| 218 | 218 |
| 219 // The number of bytes read before passing to the filter. This value reflects | |
| 220 // bytes read even when there is no filter. | |
| 221 int64_t prefilter_bytes_read() const { return prefilter_bytes_read_; } | |
| 222 | |
| 223 // These methods are not applicable to all connections. | 219 // These methods are not applicable to all connections. |
| 224 virtual bool GetMimeType(std::string* mime_type) const; | 220 virtual bool GetMimeType(std::string* mime_type) const; |
| 225 virtual int GetResponseCode() const; | 221 virtual int GetResponseCode() const; |
| 226 | 222 |
| 227 // Returns the socket address for the connection. | 223 // Returns the socket address for the connection. |
| 228 // See url_request.h for details. | 224 // See url_request.h for details. |
| 229 virtual HostPortPair GetSocketAddress() const; | 225 virtual HostPortPair GetSocketAddress() const; |
| 230 | 226 |
| 231 // base::PowerObserver methods: | 227 // base::PowerObserver methods: |
| 232 // We invoke URLRequestJob::Kill on suspend (crbug.com/4606). | 228 // We invoke URLRequestJob::Kill on suspend (crbug.com/4606). |
| 233 void OnSuspend() override; | 229 void OnSuspend() override; |
| 234 | 230 |
| 235 // Called after a NetworkDelegate has been informed that the URLRequest | 231 // Called after a NetworkDelegate has been informed that the URLRequest |
| 236 // will be destroyed. This is used to track that no pending callbacks | 232 // will be destroyed. This is used to track that no pending callbacks |
| 237 // exist at destruction time of the URLRequestJob, unless they have been | 233 // exist at destruction time of the URLRequestJob, unless they have been |
| 238 // canceled by an explicit NetworkDelegate::NotifyURLRequestDestroyed() call. | 234 // canceled by an explicit NetworkDelegate::NotifyURLRequestDestroyed() call. |
| 239 virtual void NotifyURLRequestDestroyed(); | 235 virtual void NotifyURLRequestDestroyed(); |
| 240 | 236 |
| 241 // Populates |out| with the connection attempts made at the socket layer in | 237 // Populates |out| with the connection attempts made at the socket layer in |
| 242 // the course of executing the URLRequestJob. Should be called after the job | 238 // the course of executing the URLRequestJob. Should be called after the job |
| 243 // has failed or the response headers have been received. | 239 // has failed or the response headers have been received. |
| 244 virtual void GetConnectionAttempts(ConnectionAttempts* out) const; | 240 virtual void GetConnectionAttempts(ConnectionAttempts* out) const; |
| 245 | 241 |
| 246 // Given |policy|, |referrer|, and |redirect_destination|, returns the | 242 // Given |policy|, |referrer|, and |redirect_destination|, returns the |
| 247 // referrer URL mandated by |request|'s referrer policy. | 243 // referrer URL mandated by |request|'s referrer policy. |
| 248 static GURL ComputeReferrerForRedirect(URLRequest::ReferrerPolicy policy, | 244 static GURL ComputeReferrerForRedirect(URLRequest::ReferrerPolicy policy, |
| 249 const std::string& referrer, | 245 const std::string& referrer, |
| 250 const GURL& redirect_destination); | 246 const GURL& redirect_destination); |
| 247 // The number of bytes read before passing to the filter. This value reflects | |
| 248 // bytes read even when there is no filter. | |
| 249 int64_t prefilter_bytes_read() const; | |
| 251 | 250 |
| 252 protected: | 251 protected: |
| 252 // Helper method used to perform tasks after reading from |source_| is | |
| 253 // completed. |synchronous| true if the read completed synchronously. | |
| 254 // See the documentation for |Read| above for the contract of this method. | |
| 255 void SourceReadComplete(bool synchronous, int result); | |
| 256 | |
| 253 // Notifies the job that a certificate is requested. | 257 // Notifies the job that a certificate is requested. |
| 254 void NotifyCertificateRequested(SSLCertRequestInfo* cert_request_info); | 258 void NotifyCertificateRequested(SSLCertRequestInfo* cert_request_info); |
| 255 | 259 |
| 256 // Notifies the job about an SSL certificate error. | 260 // Notifies the job about an SSL certificate error. |
| 257 void NotifySSLCertificateError(const SSLInfo& ssl_info, bool fatal); | 261 void NotifySSLCertificateError(const SSLInfo& ssl_info, bool fatal); |
| 258 | 262 |
| 259 // Delegates to URLRequest::Delegate. | 263 // Delegates to URLRequest::Delegate. |
| 260 bool CanGetCookies(const CookieList& cookie_list) const; | 264 bool CanGetCookies(const CookieList& cookie_list) const; |
| 261 | 265 |
| 262 // Delegates to URLRequest::Delegate. | 266 // Delegates to URLRequest::Delegate. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 | 304 |
| 301 // Called to tell the job that a filter has successfully reached the end of | 305 // Called to tell the job that a filter has successfully reached the end of |
| 302 // the stream. | 306 // the stream. |
| 303 virtual void DoneReading(); | 307 virtual void DoneReading(); |
| 304 | 308 |
| 305 // Called to tell the job that the body won't be read because it's a redirect. | 309 // Called to tell the job that the body won't be read because it's a redirect. |
| 306 // This is needed so that redirect headers can be cached even though their | 310 // This is needed so that redirect headers can be cached even though their |
| 307 // bodies are never read. | 311 // bodies are never read. |
| 308 virtual void DoneReadingRedirectResponse(); | 312 virtual void DoneReadingRedirectResponse(); |
| 309 | 313 |
| 310 // Reads filtered data from the request. Returns OK if immediately successful, | |
| 311 // ERR_IO_PENDING if the request couldn't complete synchronously, and some | |
| 312 // other error code if the request failed synchronously. Note that this | |
| 313 // function can issue new asynchronous requests if needed, in which case it | |
| 314 // returns ERR_IO_PENDING. If this method completes synchronously, | |
| 315 // |*bytes_read| is the number of bytes output by the filter chain if this | |
| 316 // method returns OK, or zero if this method returns an error. | |
| 317 Error ReadFilteredData(int* bytes_read); | |
| 318 | |
| 319 // Whether the response is being filtered in this job. | |
| 320 // Only valid after NotifyHeadersComplete() has been called. | |
| 321 bool HasFilter() { return filter_ != NULL; } | |
| 322 | |
| 323 // At or near destruction time, a derived class may request that the filters | |
| 324 // be destroyed so that statistics can be gathered while the derived class is | |
| 325 // still present to assist in calculations. This is used by URLRequestHttpJob | |
| 326 // to get SDCH to emit stats. | |
| 327 void DestroyFilters(); | |
| 328 | |
| 329 // Provides derived classes with access to the request's network delegate. | 314 // Provides derived classes with access to the request's network delegate. |
| 330 NetworkDelegate* network_delegate() { return network_delegate_; } | 315 NetworkDelegate* network_delegate() { return network_delegate_; } |
| 331 | 316 |
| 332 // The status of the job. | 317 // The status of the job. |
| 333 const URLRequestStatus GetStatus(); | 318 const URLRequestStatus GetStatus(); |
| 334 | 319 |
| 335 // Set the proxy server that was used, if any. | 320 // Set the proxy server that was used, if any. |
| 336 void SetProxyServer(const HostPortPair& proxy_server); | 321 void SetProxyServer(const HostPortPair& proxy_server); |
| 337 | 322 |
| 338 // The number of bytes read after passing through the filter. This value | 323 // The number of bytes read after passing through the filter. This value |
| 339 // reflects bytes read even when there is no filter. | 324 // reflects bytes read even when there is no filter. |
| 340 int64_t postfilter_bytes_read() const { return postfilter_bytes_read_; } | 325 int64_t postfilter_bytes_read() const; |
| 341 | 326 |
| 342 // Turns an integer result code into an Error and a count of bytes read. | 327 // Turns an integer result code into an Error and a count of bytes read. |
| 343 // The semantics are: | 328 // The semantics are: |
| 344 // |result| >= 0: |*error| == OK, |*count| == |result| | 329 // |result| >= 0: |*error| == OK, |*count| == |result| |
| 345 // |result| < 0: |*error| = |result|, |*count| == 0 | 330 // |result| < 0: |*error| = |result|, |*count| == 0 |
| 346 static void ConvertResultToError(int result, Error* error, int* count); | 331 static void ConvertResultToError(int result, Error* error, int* count); |
| 347 | 332 |
| 348 // Completion callback for raw reads. See |ReadRawData| for details. | 333 // Completion callback for raw reads. See |ReadRawData| for details. |
| 349 // |bytes_read| is either >= 0 to indicate a successful read and count of | 334 // |bytes_read| is either >= 0 to indicate a successful read and count of |
| 350 // bytes read, or < 0 to indicate an error. | 335 // bytes read, or < 0 to indicate an error. |
| 351 void ReadRawDataComplete(int bytes_read); | 336 void ReadRawDataComplete(int bytes_read); |
| 352 | 337 |
| 353 // The request that initiated this job. This value will never be nullptr. | 338 // The request that initiated this job. This value will never be nullptr. |
| 354 URLRequest* request_; | 339 URLRequest* request_; |
| 355 | 340 |
| 356 private: | 341 private: |
| 342 class URLRequestJobStreamSource; | |
| 357 // Set the status of the associated URLRequest. | 343 // Set the status of the associated URLRequest. |
| 358 // TODO(mmenke): Make the URLRequest manage its own status. | 344 // TODO(mmenke): Make the URLRequest manage its own status. |
| 359 void SetStatus(const URLRequestStatus& status); | 345 void SetStatus(const URLRequestStatus& status); |
| 360 | 346 |
| 361 // When data filtering is enabled, this function is used to read data | |
| 362 // for the filter. Returns a net error code to indicate if raw data was | |
| 363 // successfully read, an error happened, or the IO is pending. | |
| 364 Error ReadRawDataForFilter(int* bytes_read); | |
| 365 | |
| 366 // Informs the filter chain that data has been read into its buffer. | |
| 367 void PushInputToFilter(int bytes_read); | |
| 368 | |
| 369 // Invokes ReadRawData and records bytes read if the read completes | 347 // Invokes ReadRawData and records bytes read if the read completes |
| 370 // synchronously. | 348 // synchronously. |
| 371 Error ReadRawDataHelper(IOBuffer* buf, int buf_size, int* bytes_read); | 349 int ReadRawDataHelper(IOBuffer* buf, |
| 350 int buf_size, | |
| 351 const CompletionCallback& callback); | |
| 372 | 352 |
| 373 // Called in response to a redirect that was not canceled to follow the | 353 // Called in response to a redirect that was not canceled to follow the |
| 374 // redirect. The current job will be replaced with a new job loading the | 354 // redirect. The current job will be replaced with a new job loading the |
| 375 // given redirect destination. | 355 // given redirect destination. |
| 376 void FollowRedirect(const RedirectInfo& redirect_info); | 356 void FollowRedirect(const RedirectInfo& redirect_info); |
| 377 | 357 |
| 378 // Called after every raw read. If |bytes_read| is > 0, this indicates | 358 // Called after every raw read. If |bytes_read| is > 0, this indicates |
| 379 // a successful read of |bytes_read| unfiltered bytes. If |bytes_read| | 359 // a successful read of |bytes_read| unfiltered bytes. If |bytes_read| |
| 380 // is 0, this indicates that there is no additional data to read. |error| | 360 // is 0, this indicates that there is no additional data to read. |
| 381 // specifies whether an error occurred and no bytes were read. | 361 // If |bytes_read| is negative, no bytes were read. |
| 382 void GatherRawReadStats(Error error, int bytes_read); | 362 void GatherRawReadStats(int bytes_read); |
| 383 | 363 |
| 384 // Updates the profiling info and notifies observers that an additional | 364 // Updates the profiling info and notifies observers that an additional |
| 385 // |bytes_read| unfiltered bytes have been read for this job. | 365 // |bytes_read| unfiltered bytes have been read for this job. |
| 386 void RecordBytesRead(int bytes_read); | 366 void RecordBytesRead(int bytes_read); |
| 387 | 367 |
| 388 // Called to query whether there is data available in the filter to be read | |
| 389 // out. | |
| 390 bool FilterHasData(); | |
| 391 | |
| 392 // NotifyDone marks that request is done. It is really a glorified | 368 // NotifyDone marks that request is done. It is really a glorified |
| 393 // set_status, but also does internal state checking and job tracking. It | 369 // set_status, but also does internal state checking and job tracking. It |
| 394 // should be called once per request, when the job is finished doing all IO. | 370 // should be called once per request, when the job is finished doing all IO. |
| 395 void NotifyDone(const URLRequestStatus& status); | 371 void NotifyDone(const URLRequestStatus& status); |
| 396 | 372 |
| 397 // Some work performed by NotifyDone must be completed asynchronously so | 373 // Some work performed by NotifyDone must be completed asynchronously so |
| 398 // as to avoid re-entering URLRequest::Delegate. This method performs that | 374 // as to avoid re-entering URLRequest::Delegate. This method performs that |
| 399 // work. | 375 // work. |
| 400 void CompleteNotifyDone(); | 376 void CompleteNotifyDone(); |
| 401 | 377 |
| 402 // Subclasses may implement this method to record packet arrival times. | 378 // Subclasses may implement this method to record packet arrival times. |
| 403 // The default implementation does nothing. Only invoked when bytes have been | 379 // The default implementation does nothing. Only invoked when bytes have been |
| 404 // read since the last invocation. | 380 // read since the last invocation. |
| 405 virtual void UpdatePacketReadTimes(); | 381 virtual void UpdatePacketReadTimes(); |
| 406 | 382 |
| 407 // Computes a new RedirectInfo based on receiving a redirect response of | 383 // Computes a new RedirectInfo based on receiving a redirect response of |
| 408 // |location| and |http_status_code|. | 384 // |location| and |http_status_code|. |
| 409 RedirectInfo ComputeRedirectInfo(const GURL& location, int http_status_code); | 385 RedirectInfo ComputeRedirectInfo(const GURL& location, int http_status_code); |
| 410 | 386 |
| 411 // Notify the network delegate that more bytes have been received or sent over | 387 // Notify the network delegate that more bytes have been received or sent over |
| 412 // the network, if bytes have been received or sent since the previous | 388 // the network, if bytes have been received or sent since the previous |
| 413 // notification. | 389 // notification. |
| 414 void MaybeNotifyNetworkBytes(); | 390 void MaybeNotifyNetworkBytes(); |
| 415 | 391 |
| 416 // Indicates that the job is done producing data, either it has completed | 392 // Indicates that the job is done producing data, either it has completed |
| 417 // all the data or an error has been encountered. Set exclusively by | 393 // all the data or an error has been encountered. Set exclusively by |
| 418 // NotifyDone so that it is kept in sync with the request. | 394 // NotifyDone so that it is kept in sync with the request. |
| 419 bool done_; | 395 bool done_; |
| 420 | 396 |
| 421 int64_t prefilter_bytes_read_; | 397 // The first StreamSource of the StreamSource chain used. |
| 422 int64_t postfilter_bytes_read_; | 398 std::unique_ptr<StreamSource> source_; |
| 423 | 399 |
| 424 // The data stream filter which is enabled on demand. | 400 // Keep a reference to the buffer passed in via URLRequestJob::Read() so it |
| 425 std::unique_ptr<Filter> filter_; | 401 // doesn't get destroyed when the read has not completed. |
| 426 | 402 scoped_refptr<IOBuffer> pending_read_buffer_; |
| 427 // If the filter filled its output buffer, then there is a change that it | |
| 428 // still has internal data to emit, and this flag is set. | |
| 429 bool filter_needs_more_output_space_; | |
| 430 | |
| 431 // When we filter data, we receive data into the filter buffers. After | |
| 432 // processing the filtered data, we return the data in the caller's buffer. | |
| 433 // While the async IO is in progress, we save the user buffer here, and | |
| 434 // when the IO completes, we fill this in. | |
| 435 scoped_refptr<IOBuffer> filtered_read_buffer_; | |
| 436 int filtered_read_buffer_len_; | |
| 437 | 403 |
| 438 // We keep a pointer to the read buffer while asynchronous reads are | 404 // We keep a pointer to the read buffer while asynchronous reads are |
| 439 // in progress, so we are able to pass those bytes to job observers. | 405 // in progress, so we are able to pass those bytes to job observers. |
| 440 scoped_refptr<IOBuffer> raw_read_buffer_; | 406 scoped_refptr<IOBuffer> raw_read_buffer_; |
| 441 | 407 |
| 442 // Used by HandleResponseIfNecessary to track whether we've sent the | 408 // Used by HandleResponseIfNecessary to track whether we've sent the |
| 443 // OnResponseStarted callback and potentially redirect callbacks as well. | 409 // OnResponseStarted callback and potentially redirect callbacks as well. |
| 444 bool has_handled_response_; | 410 bool has_handled_response_; |
| 445 | 411 |
| 446 // Expected content size | 412 // Expected content size |
| 447 int64_t expected_content_size_; | 413 int64_t expected_content_size_; |
| 448 | 414 |
| 449 // Set when a redirect is deferred. | 415 // Set when a redirect is deferred. |
| 450 RedirectInfo deferred_redirect_info_; | 416 RedirectInfo deferred_redirect_info_; |
| 451 | 417 |
| 452 // The network delegate to use with this request, if any. | 418 // The network delegate to use with this request, if any. |
| 453 NetworkDelegate* network_delegate_; | 419 NetworkDelegate* network_delegate_; |
| 454 | 420 |
| 455 // The value from GetTotalReceivedBytes() the last time | 421 // The value from GetTotalReceivedBytes() the last time |
| 456 // MaybeNotifyNetworkBytes() was called. Used to calculate how bytes have been | 422 // MaybeNotifyNetworkBytes() was called. Used to calculate how bytes have been |
| 457 // newly received since the last notification. | 423 // newly received since the last notification. |
| 458 int64_t last_notified_total_received_bytes_; | 424 int64_t last_notified_total_received_bytes_; |
| 459 | 425 |
| 460 // The value from GetTotalSentBytes() the last time MaybeNotifyNetworkBytes() | 426 // The value from GetTotalSentBytes() the last time MaybeNotifyNetworkBytes() |
| 461 // was called. Used to calculate how bytes have been newly sent since the last | 427 // was called. Used to calculate how bytes have been newly sent since the last |
| 462 // notification. | 428 // notification. |
| 463 int64_t last_notified_total_sent_bytes_; | 429 int64_t last_notified_total_sent_bytes_; |
| 464 | 430 |
| 431 // None null if ReadRawData() returned ERR_IO_PENDING, and the read has not | |
|
mmenke
2016/07/21 18:14:10
Non-null if...
xunjieli
2016/07/27 20:32:04
Done.
| |
| 432 // completed. | |
| 433 CompletionCallback read_raw_callback_; | |
| 434 | |
| 435 // Number of raw network bytes read from job subclass. | |
| 436 size_t prefilter_bytes_read_; | |
| 437 | |
| 438 // Number of bytes after applying filters. | |
| 439 size_t postfilter_bytes_read_; | |
| 440 | |
| 465 base::WeakPtrFactory<URLRequestJob> weak_factory_; | 441 base::WeakPtrFactory<URLRequestJob> weak_factory_; |
| 466 | 442 |
| 467 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); | 443 DISALLOW_COPY_AND_ASSIGN(URLRequestJob); |
| 468 }; | 444 }; |
| 469 | 445 |
| 470 } // namespace net | 446 } // namespace net |
| 471 | 447 |
| 472 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ | 448 #endif // NET_URL_REQUEST_URL_REQUEST_JOB_H_ |
| OLD | NEW |