| Index: net/base/upload_data_stream.h
|
| diff --git a/net/base/upload_data_stream.h b/net/base/upload_data_stream.h
|
| index ad70b098b4aeac982ee7247ebc7e69f64acb4ddf..05c37deb9032bbc03d6dc0781c6b4d32b4b959cb 100644
|
| --- a/net/base/upload_data_stream.h
|
| +++ b/net/base/upload_data_stream.h
|
| @@ -6,7 +6,10 @@
|
| #define NET_BASE_UPLOAD_DATA_STREAM_H_
|
| #pragma once
|
|
|
| +#include "base/callback_forward.h"
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "net/base/completion_callback.h"
|
| #include "net/base/net_export.h"
|
| #include "net/base/upload_data.h"
|
|
|
| @@ -20,14 +23,29 @@ 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
|
| + // 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
|
| + // |on_completion| with a result code on the original thread once the
|
| + // initialization is done.
|
| + //
|
| + // ERR_UPLOAD_FILE_CHANGED is passed to |on_completion| if the expected
|
| // file modification time is set (usually not set, but set for sliced
|
| // files) and the target file is changed.
|
| - int Init();
|
| + int Init(const CompletionCallback & on_completion);
|
| +
|
| + // Similar to Init() but performs the operation always synchronously. This
|
| + // version may perform file IO on the current thread. This function will
|
| + // fail if called on a thread where file IO is prohibited. 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
|
| @@ -72,6 +90,12 @@ class NET_EXPORT UploadDataStream {
|
| // Advances to the next element. Updates the internal states.
|
| void AdvanceToNextElement();
|
|
|
| + // Called when GetContentLength() is completed. Used to implement Init().
|
| + void OnGetContentLengthComplete(uint64 content_length);
|
| +
|
| + // Called when CheckModifiedFiles() is completed. Used to implement Init().
|
| + void OnCheckModifiedFilesComplete(int* result);
|
| +
|
| scoped_refptr<UploadData> upload_data_;
|
|
|
| // Index of the current upload element (i.e. the element currently being
|
| @@ -98,10 +122,15 @@ class NET_EXPORT UploadDataStream {
|
| // True if the initialization was successful.
|
| bool initialized_successfully_;
|
|
|
| + // The user supplied callback for asynchronous operations.
|
| + CompletionCallback user_callback_;
|
| +
|
| // TODO(satish): Remove this once we have a better way to unit test POST
|
| // requests with chunked uploads.
|
| static bool merge_chunks_;
|
|
|
| + base::WeakPtrFactory<UploadDataStream> weak_ptr_factory_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(UploadDataStream);
|
| };
|
|
|
|
|