| Index: net/base/upload_data_stream.h
|
| diff --git a/net/base/upload_data_stream.h b/net/base/upload_data_stream.h
|
| index 3d060f97cfad65ea236db0bbf7db10809ab2a235..81ab9e445f516859f10589fe579dfcd45569081c 100644
|
| --- a/net/base/upload_data_stream.h
|
| +++ b/net/base/upload_data_stream.h
|
| @@ -6,6 +6,7 @@
|
| #define NET_BASE_UPLOAD_DATA_STREAM_H_
|
|
|
| #include "base/memory/ref_counted.h"
|
| +#include "net/base/completion_callback.h"
|
| #include "net/base/net_export.h"
|
| #include "net/base/upload_data.h"
|
|
|
| @@ -19,14 +20,27 @@ class NET_EXPORT UploadDataStream {
|
| explicit UploadDataStream(UploadData* upload_data);
|
| ~UploadDataStream();
|
|
|
| - // Initializes the stream. This function must be called exactly once,
|
| - // before calling any other method. It is not valid to call any method
|
| - // (other than the destructor) if Init() returns a failure.
|
| + // Initializes the stream synchronously or asynchronously depending on
|
| + // whether the upload data is in memory or not. This function must be called
|
| + // exactly once, before calling any other method. It is not valid to call any
|
| + // method (other than the destructor) if the initialization failed.
|
| //
|
| - // Returns OK on success. Returns ERR_UPLOAD_FILE_CHANGED if the expected
|
| - // file modification time is set (usually not set, but set for sliced
|
| - // files) and the target file is changed.
|
| - int Init();
|
| + // If the upload data is in memory, the initialization is done synchronously.
|
| + // Returns OK or some other error code.
|
| + //
|
| + // If initialization requires file IO, returns ERR_IO_PENDING, and runs
|
| + // |callback| with a result code on the original thread once the
|
| + // initialization is done.
|
| + //
|
| + // ERR_UPLOAD_FILE_CHANGED is passed to |callback| if the expected file
|
| + // modification time is set (usually not set, but set for sliced files) and
|
| + // the target file is changed.
|
| + int Init(const CompletionCallback& callback);
|
| +
|
| + // Similar to Init() but performs the operation always synchronously. This
|
| + // version may perform file IO on the current thread. Usually used for
|
| + // testing, but Chrome Frame also uses this version.
|
| + int InitSync();
|
|
|
| // Reads up to |buf_len| bytes from the upload data stream to |buf|. The
|
| // number of bytes read is returned. Partial reads are allowed. Zero is
|
| @@ -74,6 +88,11 @@ class NET_EXPORT UploadDataStream {
|
| static void ResetMergeChunks();
|
| static void set_merge_chunks(bool merge) { merge_chunks_ = merge; }
|
|
|
| + // Called when InitInternal() is completed. Used to implement Init().
|
| + void OnInitComplete(const CompletionCallback& callback,
|
| + uint64* content_length,
|
| + int* result);
|
| +
|
| scoped_refptr<UploadData> upload_data_;
|
|
|
| // Index of the current upload element (i.e. the element currently being
|
| @@ -92,6 +111,8 @@ class NET_EXPORT UploadDataStream {
|
| // requests with chunked uploads.
|
| static bool merge_chunks_;
|
|
|
| + base::WeakPtrFactory<UploadDataStream> weak_ptr_factory_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(UploadDataStream);
|
| };
|
|
|
|
|