Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Unified Diff: net/url_request/url_request_job.h

Issue 1459333002: Revert "Reland: URLRequestJob: change ReadRawData contract" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | net/url_request/url_request_job.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 002dc62558b49c6071e1bd95c7cacb6decf2d448..a81ea08ef8648df2829af1b31f1820e28127d7f2 100644
--- a/net/url_request/url_request_job.h
+++ b/net/url_request/url_request_job.h
@@ -17,7 +17,6 @@
#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"
@@ -277,9 +276,23 @@ 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();
@@ -292,19 +305,17 @@ class NET_EXPORT URLRequestJob
void OnCallToDelegate();
void OnCallToDelegateComplete();
- // 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 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 tell the job that a filter has successfully reached the end of
// the stream.
@@ -315,14 +326,14 @@ class NET_EXPORT URLRequestJob
// bodies are never read.
virtual void DoneReadingRedirectResponse();
- // 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);
+ // 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);
// Whether the response is being filtered in this job.
// Only valid after NotifyHeadersComplete() has been called.
@@ -354,33 +365,19 @@ 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 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);
+ // 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);
// Invokes ReadRawData and records bytes read if the read completes
// synchronously.
- Error ReadRawDataHelper(IOBuffer* buf, int buf_size, int* bytes_read);
+ bool 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
@@ -389,9 +386,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. |error|
- // specifies whether an error occurred and no bytes were read.
- void GatherRawReadStats(Error error, int 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);
// Updates the profiling info and notifies observers that an additional
// |bytes_read| unfiltered bytes have been read for this job.
@@ -401,16 +398,6 @@ 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.
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | net/url_request/url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698