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|. Returns true on succcess. | |
78 // https://www.ietf.org/rfc/rfc2046.txt | |
79 // The |response| should consists of multiple parts split by specific boundary | |
80 // string. It looks like: | |
kinaba
2015/04/27 08:09:37
In addition to the RFC, you are assuming that the
hirono
2015/04/27 12:32:45
Done.
| |
81 // --Boundary | |
82 // Content-type: text/plain | |
83 // | |
84 // Content 1 | |
85 // --Boundary | |
86 // Content-type: text/plain | |
87 // | |
88 // Content 2 | |
89 // --Boundary-- | |
90 bool ParseMultipartResponse(const std::string& boundary, | |
91 const std::string& response, | |
92 std::vector<MultipartHttpResponse>* parts); | |
93 | |
69 //============================ DriveApiPartialFieldRequest ==================== | 94 //============================ DriveApiPartialFieldRequest ==================== |
70 | 95 |
71 // This is base class of the Drive API related requests. All Drive API requests | 96 // 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 | 97 // support partial request (to improve the performance). The function can be |
73 // shared among the Drive API requests. | 98 // shared among the Drive API requests. |
74 // See also https://developers.google.com/drive/performance | 99 // See also https://developers.google.com/drive/performance |
75 class DriveApiPartialFieldRequest : public UrlFetchRequestBase { | 100 class DriveApiPartialFieldRequest : public UrlFetchRequestBase { |
76 public: | 101 public: |
77 explicit DriveApiPartialFieldRequest(RequestSender* sender); | 102 explicit DriveApiPartialFieldRequest(RequestSender* sender); |
78 ~DriveApiPartialFieldRequest() override; | 103 ~DriveApiPartialFieldRequest() override; |
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1128 | 1153 |
1129 // Obtains URLGenerator. | 1154 // Obtains URLGenerator. |
1130 const DriveApiUrlGenerator& url_generator() const { return url_generator_; } | 1155 const DriveApiUrlGenerator& url_generator() const { return url_generator_; } |
1131 | 1156 |
1132 // UrlFetchRequestBase overrides. | 1157 // UrlFetchRequestBase overrides. |
1133 void Prepare(const PrepareCallback& callback) override; | 1158 void Prepare(const PrepareCallback& callback) override; |
1134 void Cancel() override; | 1159 void Cancel() override; |
1135 GURL GetURL() const override; | 1160 GURL GetURL() const override; |
1136 net::URLFetcher::RequestType GetRequestType() const override; | 1161 net::URLFetcher::RequestType GetRequestType() const override; |
1137 std::vector<std::string> GetExtraRequestHeaders() const override; | 1162 std::vector<std::string> GetExtraRequestHeaders() const override; |
1138 bool GetContentData( | 1163 bool GetContentData(std::string* upload_content_type, |
1139 std::string* upload_content_type, | 1164 std::string* upload_content) override; |
1140 std::string* upload_content) override; | |
1141 void ProcessURLFetchResults(const net::URLFetcher* source) override; | 1165 void ProcessURLFetchResults(const net::URLFetcher* source) override; |
1142 void RunCallbackOnPrematureFailure(DriveApiErrorCode code) override; | 1166 void RunCallbackOnPrematureFailure(DriveApiErrorCode code) override; |
1143 | 1167 |
1144 private: | 1168 private: |
1145 typedef void* RequestID; | 1169 typedef void* RequestID; |
1146 // Obtains corresponding child entry of |request_id|. Returns NULL if the | 1170 // Obtains corresponding child entry of |request_id|. Returns NULL if the |
1147 // entry is not found. | 1171 // entry is not found. |
1148 std::vector<BatchUploadChildEntry>::iterator | 1172 std::vector<BatchUploadChildEntry>::iterator GetChildEntry( |
1149 GetChildEntry(RequestID request_id); | 1173 RequestID request_id); |
1150 | 1174 |
1151 // Called after child requests' |Prepare| method. | 1175 // Called after child requests' |Prepare| method. |
1152 void OnChildRequestPrepared(RequestID request_id, DriveApiErrorCode result); | 1176 void OnChildRequestPrepared(RequestID request_id, DriveApiErrorCode result); |
1153 | 1177 |
1154 // Complete |Prepare| if possible. | 1178 // Complete |Prepare| if possible. |
1155 void MayCompletePrepare(); | 1179 void MayCompletePrepare(); |
1156 | 1180 |
1157 // Process result for each child. | 1181 // Process result for each child. |
1158 void ProcessURLFetchResultsForChild(RequestID id, const std::string& body); | 1182 void ProcessURLFetchResultsForChild(RequestID id, const std::string& body); |
1159 | 1183 |
(...skipping 14 matching lines...) Expand all Loading... | |
1174 // invalidate its weak pointers before any other members are destroyed. | 1198 // invalidate its weak pointers before any other members are destroyed. |
1175 base::WeakPtrFactory<BatchUploadRequest> weak_ptr_factory_; | 1199 base::WeakPtrFactory<BatchUploadRequest> weak_ptr_factory_; |
1176 | 1200 |
1177 DISALLOW_COPY_AND_ASSIGN(BatchUploadRequest); | 1201 DISALLOW_COPY_AND_ASSIGN(BatchUploadRequest); |
1178 }; | 1202 }; |
1179 | 1203 |
1180 } // namespace drive | 1204 } // namespace drive |
1181 } // namespace google_apis | 1205 } // namespace google_apis |
1182 | 1206 |
1183 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ | 1207 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ |
OLD | NEW |