Commit dbfab928 authored by Charlie Harrison's avatar Charlie Harrison Committed by Commit Bot

Remove deprecated URLRequest::Read

The last caller, URLLoader, can be changed simply to the new API.

Bug: 423484
Change-Id: Idd0233b098aeb78bc246580fca542e5f542b12a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1893431
Commit-Queue: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711327}
parent f3c2f1da
...@@ -764,23 +764,6 @@ int URLRequest::Read(IOBuffer* dest, int dest_size) { ...@@ -764,23 +764,6 @@ int URLRequest::Read(IOBuffer* dest, int dest_size) {
return rv; return rv;
} }
// Deprecated.
bool URLRequest::Read(IOBuffer* dest, int dest_size, int* bytes_read) {
int result = Read(dest, dest_size);
if (result >= 0) {
*bytes_read = result;
return true;
}
if (result == ERR_IO_PENDING) {
*bytes_read = 0;
} else {
*bytes_read = -1;
}
return false;
}
void URLRequest::NotifyReceivedRedirect(const RedirectInfo& redirect_info, void URLRequest::NotifyReceivedRedirect(const RedirectInfo& redirect_info,
bool* defer_redirect) { bool* defer_redirect) {
is_redirecting_ = true; is_redirecting_ = true;
......
...@@ -153,12 +153,9 @@ class NET_EXPORT URLRequest : public base::SupportsUserData { ...@@ -153,12 +153,9 @@ class NET_EXPORT URLRequest : public base::SupportsUserData {
// Read() initiated by delegate // Read() initiated by delegate
// - OnReadCompleted* (zero or more calls until all data is read) // - OnReadCompleted* (zero or more calls until all data is read)
// //
// Read() must be called at least once. Read() returns true when it completed // Read() must be called at least once. Read() returns bytes read when it
// immediately, and false if an IO is pending or if there is an error. When // completes immediately, and a negative error value if an IO is pending or if
// Read() returns false, the caller can check the Request's status() to see // there is an error.
// if an error occurred, or if the IO is just pending. When Read() returns
// true with zero bytes read, it indicates the end of the response.
//
class NET_EXPORT Delegate { class NET_EXPORT Delegate {
public: public:
// Called upon receiving a redirect. The delegate may call the request's // Called upon receiving a redirect. The delegate may call the request's
...@@ -602,7 +599,7 @@ class NET_EXPORT URLRequest : public base::SupportsUserData { ...@@ -602,7 +599,7 @@ class NET_EXPORT URLRequest : public base::SupportsUserData {
// request. // request.
void CancelWithSSLError(int error, const SSLInfo& ssl_info); void CancelWithSSLError(int error, const SSLInfo& ssl_info);
// Read initiates an asynchronous read from the response, and must only be // Read initiates an asynchronous read from the response, and must only be
// called after the OnResponseStarted callback is received with a net::OK. If // called after the OnResponseStarted callback is received with a net::OK. If
// data is available, length and the data will be returned immediately. If the // data is available, length and the data will be returned immediately. If the
// request has failed, an error code will be returned. If data is not yet // request has failed, an error code will be returned. If data is not yet
...@@ -617,9 +614,6 @@ class NET_EXPORT URLRequest : public base::SupportsUserData { ...@@ -617,9 +614,6 @@ class NET_EXPORT URLRequest : public base::SupportsUserData {
// //
// The |max_bytes| parameter is the maximum number of bytes to read. // The |max_bytes| parameter is the maximum number of bytes to read.
int Read(IOBuffer* buf, int max_bytes); int Read(IOBuffer* buf, int max_bytes);
// Deprecated.
// TODO(maksims): Remove this.
bool Read(IOBuffer* buf, int max_bytes, int* bytes_read);
// This method may be called to follow a redirect that was deferred in // This method may be called to follow a redirect that was deferred in
// response to an OnReceivedRedirect call. If non-null, // response to an OnReceivedRedirect call. If non-null,
......
...@@ -1067,14 +1067,10 @@ void URLLoader::ReadMore() { ...@@ -1067,14 +1067,10 @@ void URLLoader::ReadMore() {
auto buf = base::MakeRefCounted<NetToMojoIOBuffer>( auto buf = base::MakeRefCounted<NetToMojoIOBuffer>(
pending_write_.get(), pending_write_buffer_offset_); pending_write_.get(), pending_write_buffer_offset_);
int bytes_read; int bytes_read = url_request_->Read(
url_request_->Read(buf.get(), buf.get(), static_cast<int>(pending_write_buffer_size_ -
static_cast<int>(pending_write_buffer_size_ - pending_write_buffer_offset_));
pending_write_buffer_offset_), if (bytes_read != net::ERR_IO_PENDING) {
&bytes_read);
if (url_request_->status().is_io_pending()) {
// Wait for OnReadCompleted.
} else {
DidRead(bytes_read, true); DidRead(bytes_read, true);
// |this| may have been deleted. // |this| may have been deleted.
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment