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

Unified Diff: net/url_request/url_request_job.h

Issue 1662763002: [ON HOLD] Implement pull-based design for content decoding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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
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 9555b67f0f2b7ac4ced49e411d34f59ac34cd5fa..8bc3d52a7a654849c1268ccdf5a7a5be928ea082 100644
--- a/net/url_request/url_request_job.h
+++ b/net/url_request/url_request_job.h
@@ -22,6 +22,7 @@
#include "net/base/request_priority.h"
#include "net/base/upload_progress.h"
#include "net/cookies/canonical_cookie.h"
+#include "net/filter/stream_source.h"
#include "net/socket/connection_attempts.h"
#include "net/url_request/redirect_info.h"
#include "net/url_request/url_request.h"
@@ -47,6 +48,7 @@ class X509Certificate;
class NET_EXPORT URLRequestJob : public base::PowerObserver {
public:
+ typedef base::Callback<void(net::Error, size_t)> ReadRawCompleteCallback;
explicit URLRequestJob(URLRequest* request,
NetworkDelegate* network_delegate);
~URLRequestJob() override;
@@ -155,7 +157,9 @@ class NET_EXPORT URLRequestJob : public base::PowerObserver {
// This class takes ownership of the returned Filter.
//
// The default implementation returns NULL.
- virtual Filter* SetupFilter() const;
+ // virtual Filter* SetupFilter() const;
+
+ virtual scoped_ptr<StreamSource> SetupSource();
// Called to determine if this response is a redirect. Only makes sense
// for some types of requests. This method returns true if the response
@@ -252,6 +256,10 @@ class NET_EXPORT URLRequestJob : public base::PowerObserver {
const GURL& redirect_destination);
protected:
+ // Call: req->NotifyReadCompleted
+ // By: NotifyReadComplete
+ void SourceReadComplete(Error error, size_t bytes_read);
+
// Notifies the job that a certificate is requested.
void NotifyCertificateRequested(SSLCertRequestInfo* cert_request_info);
@@ -312,15 +320,6 @@ class NET_EXPORT URLRequestJob : public base::PowerObserver {
// 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);
-
// Whether the response is being filtered in this job.
// Only valid after NotifyHeadersComplete() has been called.
bool HasFilter() { return filter_ != NULL; }
@@ -342,11 +341,11 @@ class NET_EXPORT URLRequestJob : public base::PowerObserver {
// The number of bytes read before passing to the filter. This value reflects
// bytes read even when there is no filter.
- int64_t prefilter_bytes_read() const { return prefilter_bytes_read_; }
+ int64_t prefilter_bytes_read() const;
// The number of bytes read after passing through the filter. This value
// reflects bytes read even when there is no filter.
- int64_t postfilter_bytes_read() const { return postfilter_bytes_read_; }
+ int64_t postfilter_bytes_read() const;
// Turns an integer result code into an Error and a count of bytes read.
// The semantics are:
@@ -363,21 +362,20 @@ class NET_EXPORT URLRequestJob : public base::PowerObserver {
URLRequest* request_;
private:
+ friend class URLRequestJobStreamSource;
mmenke 2016/02/18 22:58:28 Seems like this should just be an inner class inst
xunjieli 2016/03/03 23:00:09 Done.
// Set the status of the associated URLRequest.
// TODO(mmenke): Make the URLRequest manage its own status.
void SetStatus(const URLRequestStatus& status);
- // 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);
// Invokes ReadRawData and records bytes read if the read completes
// synchronously.
- Error ReadRawDataHelper(IOBuffer* buf, int buf_size, int* bytes_read);
+ Error ReadRawDataHelper(IOBuffer* buf,
+ int buf_size,
+ int* bytes_read,
+ const StreamSource::OnReadCompleteCallback& callback);
// 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
@@ -427,11 +425,10 @@ class NET_EXPORT URLRequestJob : public base::PowerObserver {
// NotifyDone so that it is kept in sync with the request.
bool done_;
- int64_t prefilter_bytes_read_;
- int64_t postfilter_bytes_read_;
-
// The data stream filter which is enabled on demand.
scoped_ptr<Filter> filter_;
+ // TODO doc
+ scoped_ptr<StreamSource> source_;
// If the filter filled its output buffer, then there is a change that it
// still has internal data to emit, and this flag is set.
@@ -471,6 +468,11 @@ class NET_EXPORT URLRequestJob : public base::PowerObserver {
// notification.
int64_t last_notified_total_sent_bytes_;
+ ReadRawCompleteCallback read_raw_callback_;
+
+ // Raw network bytes read from job subclass.
+ size_t raw_bytes_read_;
+
base::WeakPtrFactory<URLRequestJob> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(URLRequestJob);

Powered by Google App Engine
This is Rietveld 408576698