| Index: net/url_request/url_request_job.h | 
| diff --git a/net/url_request/url_request_job.h b/net/url_request/url_request_job.h | 
| index f010913f47bd2a01e4820f6080432bc8681315cc..83358f3615e9409c2693e220e00dfb54f1409509 100644 | 
| --- a/net/url_request/url_request_job.h | 
| +++ b/net/url_request/url_request_job.h | 
| @@ -17,6 +17,7 @@ | 
| #include "base/power_monitor/power_observer.h" | 
| #include "net/base/host_port_pair.h" | 
| #include "net/base/load_states.h" | 
| +#include "net/base/net_errors.h" | 
| #include "net/base/net_export.h" | 
| #include "net/base/request_priority.h" | 
| #include "net/base/upload_progress.h" | 
| @@ -278,23 +279,9 @@ class NET_EXPORT URLRequestJob | 
| // Notifies the job that headers have been received. | 
| void NotifyHeadersComplete(); | 
|  | 
| -  // Notifies the request that the job has completed a Read operation. | 
| -  void NotifyReadComplete(int bytes_read); | 
| - | 
| // Notifies the request that a start error has occurred. | 
| void NotifyStartError(const URLRequestStatus& status); | 
|  | 
| -  // NotifyDone marks when we are done with a request.  It is really | 
| -  // a glorified set_status, but also does internal state checking and | 
| -  // job tracking.  It should be called once per request, when the job is | 
| -  // finished doing all IO. | 
| -  void NotifyDone(const URLRequestStatus& status); | 
| - | 
| -  // Some work performed by NotifyDone must be completed on a separate task | 
| -  // so as to avoid re-entering the delegate.  This method exists to perform | 
| -  // that work. | 
| -  void CompleteNotifyDone(); | 
| - | 
| // Used as an asynchronous callback for Kill to notify the URLRequest | 
| // that we were canceled. | 
| void NotifyCanceled(); | 
| @@ -307,17 +294,19 @@ class NET_EXPORT URLRequestJob | 
| void OnCallToDelegate(); | 
| void OnCallToDelegateComplete(); | 
|  | 
| -  // Called to read raw (pre-filtered) data from this Job. | 
| -  // If returning true, data was read from the job.  buf will contain | 
| -  // the data, and bytes_read will receive the number of bytes read. | 
| -  // If returning true, and bytes_read is returned as 0, there is no | 
| -  // additional data to be read. | 
| -  // If returning false, an error occurred or an async IO is now pending. | 
| -  // If async IO is pending, the status of the request will be | 
| -  // URLRequestStatus::IO_PENDING, and buf must remain available until the | 
| -  // operation is completed.  See comments on URLRequest::Read for more | 
| -  // info. | 
| -  virtual bool ReadRawData(IOBuffer* buf, int buf_size, int* bytes_read); | 
| +  // Called to read raw (pre-filtered) data from this Job. Reads at most | 
| +  // |buf_size| bytes into |buf|. | 
| +  // Possible return values: | 
| +  //   >= 0: Read completed synchronously. Return value is the number of bytes | 
| +  //         read. 0 means eof. | 
| +  //   ERR_IO_PENDING: Read pending asynchronously. | 
| +  //                   When the read completes, |ReadRawDataComplete| should be | 
| +  //                   called. | 
| +  //   Any other negative number: Read failed synchronously. Return value is a | 
| +  //                   network error code. | 
| +  // This method might hold onto a reference to |buf| (by incrementing the | 
| +  // refcount) until the method completes or is cancelled. | 
| +  virtual int ReadRawData(IOBuffer* buf, int buf_size); | 
|  | 
| // Called to tell the job that a filter has successfully reached the end of | 
| // the stream. | 
| @@ -328,14 +317,14 @@ class NET_EXPORT URLRequestJob | 
| // bodies are never read. | 
| virtual void DoneReadingRedirectResponse(); | 
|  | 
| -  // Informs the filter that data has been read into its buffer | 
| -  void FilteredDataRead(int bytes_read); | 
| - | 
| -  // Reads filtered data from the request.  Returns true if successful, | 
| -  // false otherwise.  Note, if there is not enough data received to | 
| -  // return data, this call can issue a new async IO request under | 
| -  // the hood. | 
| -  bool ReadFilteredData(int* bytes_read); | 
| +  // Reads filtered data from the request. Returns OK if immediately successful, | 
| +  // ERR_IO_PENDING if the request couldn't complete synchronously, and some | 
| +  // other error code if the request failed synchronously. Note that this | 
| +  // function can issue new asynchronous requests if needed, in which case it | 
| +  // returns ERR_IO_PENDING. If this method completes synchronously, | 
| +  // |*bytes_read| is the number of bytes output by the filter chain if this | 
| +  // method returns OK, or zero if this method returns an error. | 
| +  Error ReadFilteredData(int* bytes_read); | 
|  | 
| // Whether the response is being filtered in this job. | 
| // Only valid after NotifyHeadersComplete() has been called. | 
| @@ -367,19 +356,33 @@ class NET_EXPORT URLRequestJob | 
| // reflects bytes read even when there is no filter. | 
| int64 postfilter_bytes_read() const { return postfilter_bytes_read_; } | 
|  | 
| +  // Turns an integer result code into an Error and a count of bytes read. | 
| +  // The semantics are: | 
| +  //   |result| >= 0: |*error| == OK, |*count| == |result| | 
| +  //   |result| < 0: |*error| = |result|, |*count| == 0 | 
| +  static void ConvertResultToError(int result, Error* error, int* count); | 
| + | 
| +  // Completion callback for raw reads. See |ReadRawData| for details. | 
| +  // |bytes_read| is either >= 0 to indicate a successful read and count of | 
| +  // bytes read, or < 0 to indicate an error. | 
| +  void ReadRawDataComplete(int bytes_read); | 
| + | 
| // The request that initiated this job. This value MAY BE NULL if the | 
| // request was released by DetachRequest(). | 
| URLRequest* request_; | 
|  | 
| private: | 
| // When data filtering is enabled, this function is used to read data | 
| -  // for the filter.  Returns true if raw data was read.  Returns false if | 
| -  // an error occurred (or we are waiting for IO to complete). | 
| -  bool ReadRawDataForFilter(int* bytes_read); | 
| +  // for the filter. Returns a net error code to indicate if raw data was | 
| +  // successfully read,  an error happened, or the IO is pending. | 
| +  Error ReadRawDataForFilter(int* bytes_read); | 
| + | 
| +  // Informs the filter chain that data has been read into its buffer. | 
| +  void PushInputToFilter(int bytes_read); | 
|  | 
| // Invokes ReadRawData and records bytes read if the read completes | 
| // synchronously. | 
| -  bool ReadRawDataHelper(IOBuffer* buf, int buf_size, int* bytes_read); | 
| +  Error ReadRawDataHelper(IOBuffer* buf, int buf_size, int* bytes_read); | 
|  | 
| // Called in response to a redirect that was not canceled to follow the | 
| // redirect. The current job will be replaced with a new job loading the | 
| @@ -388,9 +391,9 @@ class NET_EXPORT URLRequestJob | 
|  | 
| // Called after every raw read. If |bytes_read| is > 0, this indicates | 
| // a successful read of |bytes_read| unfiltered bytes. If |bytes_read| | 
| -  // is 0, this indicates that there is no additional data to read. If | 
| -  // |bytes_read| is < 0, an error occurred and no bytes were read. | 
| -  void OnRawReadComplete(int bytes_read); | 
| +  // is 0, this indicates that there is no additional data to read. |error| | 
| +  // specifies whether an error occurred and no bytes were read. | 
| +  void GatherRawReadStats(Error error, int bytes_read); | 
|  | 
| // Updates the profiling info and notifies observers that an additional | 
| // |bytes_read| unfiltered bytes have been read for this job. | 
| @@ -400,6 +403,16 @@ class NET_EXPORT URLRequestJob | 
| // out. | 
| bool FilterHasData(); | 
|  | 
| +  // NotifyDone marks that request is done. It is really a glorified | 
| +  // set_status, but also does internal state checking and job tracking. It | 
| +  // should be called once per request, when the job is finished doing all IO. | 
| +  void NotifyDone(const URLRequestStatus& status); | 
| + | 
| +  // Some work performed by NotifyDone must be completed asynchronously so | 
| +  // as to avoid re-entering URLRequest::Delegate. This method performs that | 
| +  // work. | 
| +  void CompleteNotifyDone(); | 
| + | 
| // Subclasses may implement this method to record packet arrival times. | 
| // The default implementation does nothing.  Only invoked when bytes have been | 
| // read since the last invocation. | 
|  |