| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ | 5 #ifndef GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ |
| 6 #define GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ | 6 #define GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 Visibility visibility_; | 61 Visibility visibility_; |
| 62 std::string key_; | 62 std::string key_; |
| 63 std::string value_; | 63 std::string value_; |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 // List of properties for a single file or a directory. | 66 // List of properties for a single file or a directory. |
| 67 typedef std::vector<Property> Properties; | 67 typedef std::vector<Property> Properties; |
| 68 | 68 |
| 69 // Child response embedded in multipart parent response. |
| 70 struct MultipartHttpResponse { |
| 71 MultipartHttpResponse(); |
| 72 ~MultipartHttpResponse(); |
| 73 DriveApiErrorCode code; |
| 74 std::string body; |
| 75 }; |
| 76 |
| 77 // Splits multipart |response| into |parts|. Each part must be HTTP sub-response |
| 78 // of drive batch request. |content_type| is a value of Content-Type response |
| 79 // header. Returns true on succcess. |
| 80 bool ParseMultipartResponse(const std::string& content_type, |
| 81 const std::string& response, |
| 82 std::vector<MultipartHttpResponse>* parts); |
| 83 |
| 69 //============================ DriveApiPartialFieldRequest ==================== | 84 //============================ DriveApiPartialFieldRequest ==================== |
| 70 | 85 |
| 71 // This is base class of the Drive API related requests. All Drive API requests | 86 // This is base class of the Drive API related requests. All Drive API requests |
| 72 // support partial request (to improve the performance). The function can be | 87 // support partial request (to improve the performance). The function can be |
| 73 // shared among the Drive API requests. | 88 // shared among the Drive API requests. |
| 74 // See also https://developers.google.com/drive/performance | 89 // See also https://developers.google.com/drive/performance |
| 75 class DriveApiPartialFieldRequest : public UrlFetchRequestBase { | 90 class DriveApiPartialFieldRequest : public UrlFetchRequestBase { |
| 76 public: | 91 public: |
| 77 explicit DriveApiPartialFieldRequest(RequestSender* sender); | 92 explicit DriveApiPartialFieldRequest(RequestSender* sender); |
| 78 ~DriveApiPartialFieldRequest() override; | 93 ~DriveApiPartialFieldRequest() override; |
| (...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 | 1143 |
| 1129 // Obtains URLGenerator. | 1144 // Obtains URLGenerator. |
| 1130 const DriveApiUrlGenerator& url_generator() const { return url_generator_; } | 1145 const DriveApiUrlGenerator& url_generator() const { return url_generator_; } |
| 1131 | 1146 |
| 1132 // UrlFetchRequestBase overrides. | 1147 // UrlFetchRequestBase overrides. |
| 1133 void Prepare(const PrepareCallback& callback) override; | 1148 void Prepare(const PrepareCallback& callback) override; |
| 1134 void Cancel() override; | 1149 void Cancel() override; |
| 1135 GURL GetURL() const override; | 1150 GURL GetURL() const override; |
| 1136 net::URLFetcher::RequestType GetRequestType() const override; | 1151 net::URLFetcher::RequestType GetRequestType() const override; |
| 1137 std::vector<std::string> GetExtraRequestHeaders() const override; | 1152 std::vector<std::string> GetExtraRequestHeaders() const override; |
| 1138 bool GetContentData( | 1153 bool GetContentData(std::string* upload_content_type, |
| 1139 std::string* upload_content_type, | 1154 std::string* upload_content) override; |
| 1140 std::string* upload_content) override; | |
| 1141 void ProcessURLFetchResults(const net::URLFetcher* source) override; | 1155 void ProcessURLFetchResults(const net::URLFetcher* source) override; |
| 1142 void RunCallbackOnPrematureFailure(DriveApiErrorCode code) override; | 1156 void RunCallbackOnPrematureFailure(DriveApiErrorCode code) override; |
| 1143 | 1157 |
| 1144 private: | 1158 private: |
| 1145 typedef void* RequestID; | 1159 typedef void* RequestID; |
| 1146 // Obtains corresponding child entry of |request_id|. Returns NULL if the | 1160 // Obtains corresponding child entry of |request_id|. Returns NULL if the |
| 1147 // entry is not found. | 1161 // entry is not found. |
| 1148 std::vector<BatchUploadChildEntry>::iterator | 1162 std::vector<BatchUploadChildEntry>::iterator GetChildEntry( |
| 1149 GetChildEntry(RequestID request_id); | 1163 RequestID request_id); |
| 1150 | 1164 |
| 1151 // Called after child requests' |Prepare| method. | 1165 // Called after child requests' |Prepare| method. |
| 1152 void OnChildRequestPrepared(RequestID request_id, DriveApiErrorCode result); | 1166 void OnChildRequestPrepared(RequestID request_id, DriveApiErrorCode result); |
| 1153 | 1167 |
| 1154 // Complete |Prepare| if possible. | 1168 // Complete |Prepare| if possible. |
| 1155 void MayCompletePrepare(); | 1169 void MayCompletePrepare(); |
| 1156 | 1170 |
| 1157 // Process result for each child. | 1171 // Process result for each child. |
| 1158 void ProcessURLFetchResultsForChild(RequestID id, const std::string& body); | 1172 void ProcessURLFetchResultsForChild(RequestID id, const std::string& body); |
| 1159 | 1173 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1174 // invalidate its weak pointers before any other members are destroyed. | 1188 // invalidate its weak pointers before any other members are destroyed. |
| 1175 base::WeakPtrFactory<BatchUploadRequest> weak_ptr_factory_; | 1189 base::WeakPtrFactory<BatchUploadRequest> weak_ptr_factory_; |
| 1176 | 1190 |
| 1177 DISALLOW_COPY_AND_ASSIGN(BatchUploadRequest); | 1191 DISALLOW_COPY_AND_ASSIGN(BatchUploadRequest); |
| 1178 }; | 1192 }; |
| 1179 | 1193 |
| 1180 } // namespace drive | 1194 } // namespace drive |
| 1181 } // namespace google_apis | 1195 } // namespace google_apis |
| 1182 | 1196 |
| 1183 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ | 1197 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ |
| OLD | NEW |