Commit b4926927 authored by Hiroshi Ichikawa's avatar Hiroshi Ichikawa Committed by Commit Bot

Improve an error message and comments of URLFetcherResponseWriter.

Change-Id: Ie761770f99a66885afce13c662d8a84dfc85e83c
Reviewed-on: https://chromium-review.googlesource.com/c/1319210Reviewed-by: default avatarRyan Hamilton <rch@chromium.org>
Commit-Queue: Hiroshi Ichikawa <ichikawa@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605926}
parent 42dae1b6
...@@ -102,7 +102,7 @@ int URLFetcherFileWriter::Initialize(CompletionOnceCallback callback) { ...@@ -102,7 +102,7 @@ int URLFetcherFileWriter::Initialize(CompletionOnceCallback callback) {
int URLFetcherFileWriter::Write(IOBuffer* buffer, int URLFetcherFileWriter::Write(IOBuffer* buffer,
int num_bytes, int num_bytes,
CompletionOnceCallback callback) { CompletionOnceCallback callback) {
DCHECK(file_stream_); DCHECK(file_stream_) << "Call Initialize() first.";
DCHECK(owns_file_); DCHECK(owns_file_);
DCHECK(!callback_); DCHECK(!callback_);
......
...@@ -32,14 +32,17 @@ class NET_EXPORT URLFetcherResponseWriter { ...@@ -32,14 +32,17 @@ class NET_EXPORT URLFetcherResponseWriter {
public: public:
virtual ~URLFetcherResponseWriter() {} virtual ~URLFetcherResponseWriter() {}
// Initializes this instance. If ERR_IO_PENDING is returned, |callback| will // Initializes this instance. Returns an error code defined in
// be run later with the result. Calling this method again after a // //net/base/net_errors.h. If ERR_IO_PENDING is returned, |callback| will be
// Initialize() success results in discarding already written data. // run later with the result. If anything else is returned, |callback| will
// *not* be called. Calling this method again after a Initialize() success
// results in discarding already written data.
virtual int Initialize(CompletionOnceCallback callback) = 0; virtual int Initialize(CompletionOnceCallback callback) = 0;
// Writes |num_bytes| bytes in |buffer|, and returns the number of bytes // Writes |num_bytes| bytes in |buffer|, and returns the number of bytes
// written or an error code. If ERR_IO_PENDING is returned, |callback| will be // written or an error code defined in //net/base/net_errors.h. If
// run later with the result. // ERR_IO_PENDING is returned, |callback| will be run later with the result.
// If anything else is returned, |callback| will *not* be called.
virtual int Write(IOBuffer* buffer, virtual int Write(IOBuffer* buffer,
int num_bytes, int num_bytes,
CompletionOnceCallback callback) = 0; CompletionOnceCallback callback) = 0;
...@@ -49,8 +52,10 @@ class NET_EXPORT URLFetcherResponseWriter { ...@@ -49,8 +52,10 @@ class NET_EXPORT URLFetcherResponseWriter {
// errors (|net_error| not OK), this method may be called before the previous // errors (|net_error| not OK), this method may be called before the previous
// operation completed. In this case, URLFetcherResponseWriter may skip // operation completed. In this case, URLFetcherResponseWriter may skip
// graceful shutdown and completion of the pending operation. After such a // graceful shutdown and completion of the pending operation. After such a
// failure, the URLFetcherResponseWriter may be reused. If ERR_IO_PENDING is // failure, the URLFetcherResponseWriter may be reused. Returns an error code
// returned, |callback| will be run later with the result. // defined in //net/base/net_errors.h. If ERR_IO_PENDING is returned,
// |callback| will be run later with the result. If anything else is returned,
// |callback| will *not* be called.
virtual int Finish(int net_error, CompletionOnceCallback callback) = 0; virtual int Finish(int net_error, CompletionOnceCallback callback) = 0;
// Returns this instance's pointer as URLFetcherStringWriter when possible. // Returns this instance's pointer as URLFetcherStringWriter when possible.
...@@ -86,7 +91,9 @@ class NET_EXPORT URLFetcherStringWriter : public URLFetcherResponseWriter { ...@@ -86,7 +91,9 @@ class NET_EXPORT URLFetcherStringWriter : public URLFetcherResponseWriter {
class NET_EXPORT URLFetcherFileWriter : public URLFetcherResponseWriter { class NET_EXPORT URLFetcherFileWriter : public URLFetcherResponseWriter {
public: public:
// |file_path| is used as the destination path. If |file_path| is empty, // |file_path| is used as the destination path. If |file_path| is empty,
// Initialize() will create a temporary file. // Initialize() will create a temporary file. The destination file is deleted
// when a URLFetcherFileWriter instance is destructed unless DisownFile() is
// called.
URLFetcherFileWriter( URLFetcherFileWriter(
scoped_refptr<base::SequencedTaskRunner> file_task_runner, scoped_refptr<base::SequencedTaskRunner> file_task_runner,
const base::FilePath& file_path); const base::FilePath& file_path);
......
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