diff options
Diffstat (limited to 'google_apis/drive/base_requests.h')
-rw-r--r-- | google_apis/drive/base_requests.h | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/google_apis/drive/base_requests.h b/google_apis/drive/base_requests.h index d7f46ab..2cfddf0 100644 --- a/google_apis/drive/base_requests.h +++ b/google_apis/drive/base_requests.h @@ -30,6 +30,8 @@ namespace google_apis { class FileResource; class RequestSender; +typedef base::Callback<void(DriveApiErrorCode)> PrepareCallback; + // Callback used for requests that the server returns FileResource data // formatted into JSON value. typedef base::Callback<void(DriveApiErrorCode error, @@ -140,6 +142,10 @@ class UrlFetchRequestBase : public AuthenticatedRequestInterface, explicit UrlFetchRequestBase(RequestSender* sender); ~UrlFetchRequestBase() override; + // Does async initialization for the request. |Start| calls this method so you + // don't need to call this before |Start|. + virtual void Prepare(const PrepareCallback& callback); + // Gets URL for the request. virtual GURL GetURL() const = 0; @@ -200,6 +206,16 @@ class UrlFetchRequestBase : public AuthenticatedRequestInterface, base::SequencedTaskRunner* blocking_task_runner() const; private: + // Continues |Start| function after |Prepare|. + void StartAfterPrepare(const std::string& access_token, + const std::string& custom_user_agent, + const ReAuthenticateCallback& callback, + DriveApiErrorCode code); + + // Invokes callback with |code| and request to delete the request to + // |sender_|. + void CompleteRequestWithError(DriveApiErrorCode code); + // URLFetcherDelegate overrides. void OnURLFetchComplete(const net::URLFetcher* source) override; @@ -458,12 +474,8 @@ class MultipartUploadRequestBase : public UrlFetchRequestBase { const ProgressCallback& progress_callback); ~MultipartUploadRequestBase() override; - // Overridden from AuthenticatedRequestInterface. - void Start(const std::string& access_token, - const std::string& custom_user_agent, - const ReAuthenticateCallback& callback) override; - // Overridden from UrlFetchRequestBase. + void Prepare(const PrepareCallback& callback) override; bool GetContentData(std::string* upload_content_type, std::string* upload_content) override; void ProcessURLFetchResults(const net::URLFetcher* source) override; @@ -480,9 +492,7 @@ class MultipartUploadRequestBase : public UrlFetchRequestBase { private: // Continues to rest part of |Start| method after determining boundary string // of multipart/related. - void OnPrepareUploadContent(const std::string& access_token, - const std::string& custom_user_agent, - const ReAuthenticateCallback& callback, + void OnPrepareUploadContent(const PrepareCallback& callback, std::string* upload_content_type, std::string* upload_content_data, bool result); |