| Index: google_apis/drive/drive_api_requests.h
|
| diff --git a/google_apis/drive/drive_api_requests.h b/google_apis/drive/drive_api_requests.h
|
| index d930f4e87048528ab85dbb60bc66d02236d566bf..fb74d4c79de436516ac95a49592e3d27b6dac799 100644
|
| --- a/google_apis/drive/drive_api_requests.h
|
| +++ b/google_apis/drive/drive_api_requests.h
|
| @@ -968,28 +968,28 @@ class GetUploadStatusRequest : public GetUploadStatusRequestBase {
|
| DISALLOW_COPY_AND_ASSIGN(GetUploadStatusRequest);
|
| };
|
|
|
| -//======================= MultipartUploadNewFileRequest =======================
|
| +//======================= MultipartUploadNewFileDelegate =======================
|
|
|
| // This class performs the request for initiating the upload of a new file.
|
| -class MultipartUploadNewFileRequest : public MultipartUploadRequestBase {
|
| +class MultipartUploadNewFileDelegate : public MultipartUploadRequestBase {
|
| public:
|
| // |parent_resource_id| should be the resource id of the parent directory.
|
| // |title| should be set.
|
| // See also the comments of MultipartUploadRequestBase for more details
|
| // about the other parameters.
|
| - MultipartUploadNewFileRequest(RequestSender* sender,
|
| - const std::string& title,
|
| - const std::string& parent_resource_id,
|
| - const std::string& content_type,
|
| - int64 content_length,
|
| - const base::Time& modified_date,
|
| - const base::Time& last_viewed_by_me_date,
|
| - const base::FilePath& local_file_path,
|
| - const Properties& properties,
|
| - const DriveApiUrlGenerator& url_generator,
|
| - const FileResourceCallback& callback,
|
| - const ProgressCallback& progress_callback);
|
| - ~MultipartUploadNewFileRequest() override;
|
| + MultipartUploadNewFileDelegate(RequestSender* sender,
|
| + const std::string& title,
|
| + const std::string& parent_resource_id,
|
| + const std::string& content_type,
|
| + int64 content_length,
|
| + const base::Time& modified_date,
|
| + const base::Time& last_viewed_by_me_date,
|
| + const base::FilePath& local_file_path,
|
| + const Properties& properties,
|
| + const DriveApiUrlGenerator& url_generator,
|
| + const FileResourceCallback& callback,
|
| + const ProgressCallback& progress_callback);
|
| + ~MultipartUploadNewFileDelegate() override;
|
|
|
| protected:
|
| // UrlFetchRequestBase overrides.
|
| @@ -1000,33 +1000,34 @@ class MultipartUploadNewFileRequest : public MultipartUploadRequestBase {
|
| const bool has_modified_date_;
|
| const DriveApiUrlGenerator url_generator_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(MultipartUploadNewFileRequest);
|
| + DISALLOW_COPY_AND_ASSIGN(MultipartUploadNewFileDelegate);
|
| };
|
|
|
| -//======================= MultipartUploadExistingFileRequest ===================
|
| +//====================== MultipartUploadExistingFileDelegate ===================
|
|
|
| // This class performs the request for initiating the upload of a new file.
|
| -class MultipartUploadExistingFileRequest : public MultipartUploadRequestBase {
|
| +class MultipartUploadExistingFileDelegate : public MultipartUploadRequestBase {
|
| public:
|
| // |parent_resource_id| should be the resource id of the parent directory.
|
| // |title| should be set.
|
| // See also the comments of MultipartUploadRequestBase for more details
|
| // about the other parameters.
|
| - MultipartUploadExistingFileRequest(RequestSender* sender,
|
| - const std::string& title,
|
| - const std::string& resource_id,
|
| - const std::string& parent_resource_id,
|
| - const std::string& content_type,
|
| - int64 content_length,
|
| - const base::Time& modified_date,
|
| - const base::Time& last_viewed_by_me_date,
|
| - const base::FilePath& local_file_path,
|
| - const std::string& etag,
|
| - const Properties& properties,
|
| - const DriveApiUrlGenerator& url_generator,
|
| - const FileResourceCallback& callback,
|
| - const ProgressCallback& progress_callback);
|
| - ~MultipartUploadExistingFileRequest() override;
|
| + MultipartUploadExistingFileDelegate(
|
| + RequestSender* sender,
|
| + const std::string& title,
|
| + const std::string& resource_id,
|
| + const std::string& parent_resource_id,
|
| + const std::string& content_type,
|
| + int64 content_length,
|
| + const base::Time& modified_date,
|
| + const base::Time& last_viewed_by_me_date,
|
| + const base::FilePath& local_file_path,
|
| + const std::string& etag,
|
| + const Properties& properties,
|
| + const DriveApiUrlGenerator& url_generator,
|
| + const FileResourceCallback& callback,
|
| + const ProgressCallback& progress_callback);
|
| + ~MultipartUploadExistingFileDelegate() override;
|
|
|
| protected:
|
| // UrlFetchRequestBase overrides.
|
| @@ -1040,7 +1041,7 @@ class MultipartUploadExistingFileRequest : public MultipartUploadRequestBase {
|
| const bool has_modified_date_;
|
| const DriveApiUrlGenerator url_generator_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(MultipartUploadExistingFileRequest);
|
| + DISALLOW_COPY_AND_ASSIGN(MultipartUploadExistingFileDelegate);
|
| };
|
|
|
| //========================== DownloadFileRequest ==========================
|
| @@ -1109,16 +1110,50 @@ class PermissionsInsertRequest : public EntryActionRequest {
|
| DISALLOW_COPY_AND_ASSIGN(PermissionsInsertRequest);
|
| };
|
|
|
| +//======================= SingleBatchableDelegateRequest =======================
|
| +
|
| +// Request that is operated by single BatchableDelegate.
|
| +class SingleBatchableDelegateRequest : public UrlFetchRequestBase {
|
| + public:
|
| + // The instance takes ownership of |delegate|.
|
| + SingleBatchableDelegateRequest(RequestSender* sender,
|
| + BatchableDelegate* delegate);
|
| + ~SingleBatchableDelegateRequest() override;
|
| +
|
| + private:
|
| + GURL GetURL() const override;
|
| + net::URLFetcher::RequestType GetRequestType() const override;
|
| + std::vector<std::string> GetExtraRequestHeaders() const override;
|
| + void Prepare(const PrepareCallback& callback) override;
|
| + bool GetContentData(std::string* upload_content_type,
|
| + std::string* upload_content) override;
|
| + void RunCallbackOnPrematureFailure(DriveApiErrorCode code) override;
|
| + void ProcessURLFetchResults(const net::URLFetcher* source) override;
|
| + void OnURLFetchUploadProgress(const net::URLFetcher* source,
|
| + int64 current,
|
| + int64 total) override;
|
| + scoped_ptr<BatchableDelegate> delegate_;
|
| +
|
| + // Note: This should remain the last member so it'll be destroyed and
|
| + // invalidate its weak pointers before any other members are destroyed.
|
| + base::WeakPtrFactory<SingleBatchableDelegateRequest> weak_ptr_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(SingleBatchableDelegateRequest);
|
| +};
|
| +
|
| //========================== BatchUploadRequest ==========================
|
|
|
| -struct BatchUploadChildEntry {
|
| - BatchUploadChildEntry() : request(NULL), prepared(false) {}
|
| - explicit BatchUploadChildEntry(BatchableRequestBase* request)
|
| - : request(request), prepared(false), data_offset(0), data_size(0) {}
|
| - BatchableRequestBase* request;
|
| +class BatchUploadChildEntry {
|
| + public:
|
| + explicit BatchUploadChildEntry(BatchableDelegate* request);
|
| + ~BatchUploadChildEntry();
|
| + scoped_ptr<BatchableDelegate> request;
|
| bool prepared;
|
| int64 data_offset;
|
| int64 data_size;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(BatchUploadChildEntry);
|
| };
|
|
|
| class BatchUploadRequest : public UrlFetchRequestBase {
|
| @@ -1127,8 +1162,9 @@ class BatchUploadRequest : public UrlFetchRequestBase {
|
| const DriveApiUrlGenerator& url_generator);
|
| ~BatchUploadRequest() override;
|
|
|
| - // Adds request to the batch request.
|
| - void AddRequest(BatchableRequestBase* request);
|
| + // Adds request to the batch request. The instance takes ownership of
|
| + // |request|.
|
| + void AddRequest(BatchableDelegate* request);
|
|
|
| // Completes building batch upload request, and starts to send the request to
|
| // server. Must add at least one request before calling |Commit|.
|
| @@ -1166,7 +1202,7 @@ class BatchUploadRequest : public UrlFetchRequestBase {
|
| typedef void* RequestID;
|
| // Obtains corresponding child entry of |request_id|. Returns NULL if the
|
| // entry is not found.
|
| - std::vector<BatchUploadChildEntry>::iterator GetChildEntry(
|
| + ScopedVector<BatchUploadChildEntry>::iterator GetChildEntry(
|
| RequestID request_id);
|
|
|
| // Called after child requests' |Prepare| method.
|
| @@ -1180,7 +1216,7 @@ class BatchUploadRequest : public UrlFetchRequestBase {
|
|
|
| RequestSender* const sender_;
|
| const DriveApiUrlGenerator url_generator_;
|
| - std::vector<BatchUploadChildEntry> child_requests_;
|
| + ScopedVector<BatchUploadChildEntry> child_requests_;
|
|
|
| PrepareCallback prepare_callback_;
|
| bool committed_;
|
|
|