Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1925)

Unified Diff: google_apis/drive/drive_api_requests.h

Issue 1084523002: Files.app: Implement sending batch requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | google_apis/drive/drive_api_requests.cc » ('j') | google_apis/drive/drive_api_requests.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2af587bab4e1e52fc735023ea6b1ba029c4fd267..6a94369c6af7fc3a94a8e2b1cd8853168c078032 100644
--- a/google_apis/drive/drive_api_requests.h
+++ b/google_apis/drive/drive_api_requests.h
@@ -1097,9 +1097,10 @@ class PermissionsInsertRequest : public EntryActionRequest {
//========================== BatchUploadRequest ==========================
struct BatchUploadChildEntry {
- explicit BatchUploadChildEntry(UrlFetchRequestBase* request)
+ BatchUploadChildEntry() : request(NULL), prepared(false) {}
+ explicit BatchUploadChildEntry(BatchableRequestBase* request)
: request(request), prepared(false) {}
- UrlFetchRequestBase* request;
+ BatchableRequestBase* request;
bool prepared;
};
@@ -1110,7 +1111,7 @@ class BatchUploadRequest : public UrlFetchRequestBase {
~BatchUploadRequest() override;
// Adds request to the batch request.
- void AddRequest(UrlFetchRequestBase* request);
+ void AddRequest(BatchableRequestBase* request);
// Completes building batch upload request, and starts to send the request to
// server.
@@ -1119,20 +1120,50 @@ class BatchUploadRequest : public UrlFetchRequestBase {
// Obtains weak pointer of this.
base::WeakPtr<BatchUploadRequest> GetWeakPtrAsBatchUploadRequest();
+ // Set boundary. Only tests can use this method.
+ void SetBoundaryForTesting(const std::string& boundary);
+
// Obtains reference to RequestSender that owns the request.
RequestSender* sender() const { return sender_; }
+
+ // Obtains URLGenerator.
DriveApiUrlGenerator url_generator() const { return url_generator_; }
kinaba 2015/04/13 08:25:27 const DriveApiUrlGenerator& ?
hirono 2015/04/13 09:16:10 Done.
- // Returns URL of this request.
+ // UrlFetchRequestBase overrides.
+ void Prepare(const PrepareCallback& callback) override;
+ void Cancel() override;
GURL GetURL() const override;
-
+ net::URLFetcher::RequestType GetRequestType() const override;
+ std::vector<std::string> GetExtraRequestHeaders() const override;
+ bool GetContentData(
+ std::string* upload_content_type,
+ std::string* upload_content) override;
void ProcessURLFetchResults(const net::URLFetcher* source) override;
void RunCallbackOnPrematureFailure(DriveApiErrorCode code) override;
private:
+ typedef void* RequestID;
+ // Called after child requests' |Prepare| method.
+ void OnChildRequestPrepared(RequestID request_id, DriveApiErrorCode result);
+
+ // Complete |Prepare| if possible.
+ void MayCompletePrepare();
+
+ // Process result for each child.
+ void ProcessURLFetchResultsForChild(RequestID id, const std::string& body);
+
RequestSender* const sender_;
const DriveApiUrlGenerator url_generator_;
- std::vector<BatchUploadChildEntry> child_requests_;
+ std::map<RequestID, BatchUploadChildEntry> child_requests_;
+
+ PrepareCallback prepare_callback_;
+ bool committed_;
+
+ // Boundary of multipart body.
+ std::string boundary_;
+
+ // Multipart of child requests.
+ ContentTypeAndData upload_content_;
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
« no previous file with comments | « no previous file | google_apis/drive/drive_api_requests.cc » ('j') | google_apis/drive/drive_api_requests.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698