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

Side by Side Diff: google_apis/drive/base_requests.h

Issue 881403003: Rename gdata_errorcode.h to drive_api_error_codes.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typos in BUILD.gn Created 5 years, 10 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 unified diff | Download patch
OLDNEW
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 // This file provides base classes used to issue HTTP requests for Google 5 // This file provides base classes used to issue HTTP requests for Google
6 // APIs. 6 // APIs.
7 7
8 #ifndef GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ 8 #ifndef GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_
9 #define GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ 9 #define GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_
10 10
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
18 #include "google_apis/drive/gdata_errorcode.h" 18 #include "google_apis/drive/drive_api_error_codes.h"
19 #include "net/url_request/url_fetcher.h" 19 #include "net/url_request/url_fetcher.h"
20 #include "net/url_request/url_fetcher_delegate.h" 20 #include "net/url_request/url_fetcher_delegate.h"
21 #include "net/url_request/url_fetcher_response_writer.h" 21 #include "net/url_request/url_fetcher_response_writer.h"
22 #include "url/gurl.h" 22 #include "url/gurl.h"
23 23
24 namespace base { 24 namespace base {
25 class Value; 25 class Value;
26 } // namespace base 26 } // namespace base
27 27
28 namespace google_apis { 28 namespace google_apis {
29 29
30 class FileResource; 30 class FileResource;
31 class RequestSender; 31 class RequestSender;
32 32
33 // Callback used for requests that the server returns FileResource data 33 // Callback used for requests that the server returns FileResource data
34 // formatted into JSON value. 34 // formatted into JSON value.
35 typedef base::Callback<void(GDataErrorCode error, 35 typedef base::Callback<void(DriveApiErrorCode error,
36 scoped_ptr<FileResource> entry)> 36 scoped_ptr<FileResource> entry)>
37 FileResourceCallback; 37 FileResourceCallback;
38 38
39 // Callback used for DownloadFileRequest and ResumeUploadRequestBase. 39 // Callback used for DownloadFileRequest and ResumeUploadRequestBase.
40 typedef base::Callback<void(int64 progress, int64 total)> ProgressCallback; 40 typedef base::Callback<void(int64 progress, int64 total)> ProgressCallback;
41 41
42 // Callback used to get the content from DownloadFileRequest. 42 // Callback used to get the content from DownloadFileRequest.
43 typedef base::Callback<void( 43 typedef base::Callback<void(
44 GDataErrorCode error, 44 DriveApiErrorCode error,
45 scoped_ptr<std::string> content)> GetContentCallback; 45 scoped_ptr<std::string> content)> GetContentCallback;
46 46
47 // Parses JSON passed in |json|. Returns NULL on failure. 47 // Parses JSON passed in |json|. Returns NULL on failure.
48 scoped_ptr<base::Value> ParseJson(const std::string& json); 48 scoped_ptr<base::Value> ParseJson(const std::string& json);
49 49
50 //======================= AuthenticatedRequestInterface ====================== 50 //======================= AuthenticatedRequestInterface ======================
51 51
52 // An interface class for implementing a request which requires OAuth2 52 // An interface class for implementing a request which requires OAuth2
53 // authentication. 53 // authentication.
54 class AuthenticatedRequestInterface { 54 class AuthenticatedRequestInterface {
(...skipping 10 matching lines...) Expand all
65 // |callback| is called when re-authentication is needed for a certain 65 // |callback| is called when re-authentication is needed for a certain
66 // number of times (see kMaxReAuthenticateAttemptsPerRequest in .cc). 66 // number of times (see kMaxReAuthenticateAttemptsPerRequest in .cc).
67 // The callback should retry by calling Start() again with a new access 67 // The callback should retry by calling Start() again with a new access
68 // token, or just call OnAuthFailed() if a retry is not attempted. 68 // token, or just call OnAuthFailed() if a retry is not attempted.
69 // |callback| must not be null. 69 // |callback| must not be null.
70 virtual void Start(const std::string& access_token, 70 virtual void Start(const std::string& access_token,
71 const std::string& custom_user_agent, 71 const std::string& custom_user_agent,
72 const ReAuthenticateCallback& callback) = 0; 72 const ReAuthenticateCallback& callback) = 0;
73 73
74 // Invoked when the authentication failed with an error code |code|. 74 // Invoked when the authentication failed with an error code |code|.
75 virtual void OnAuthFailed(GDataErrorCode code) = 0; 75 virtual void OnAuthFailed(DriveApiErrorCode code) = 0;
76 76
77 // Gets a weak pointer to this request object. Since requests may be 77 // Gets a weak pointer to this request object. Since requests may be
78 // deleted when it is canceled by user action, for posting asynchronous tasks 78 // deleted when it is canceled by user action, for posting asynchronous tasks
79 // on the authentication request object, weak pointers have to be used. 79 // on the authentication request object, weak pointers have to be used.
80 // TODO(kinaba): crbug.com/134814 use more clean life time management than 80 // TODO(kinaba): crbug.com/134814 use more clean life time management than
81 // using weak pointers. 81 // using weak pointers.
82 virtual base::WeakPtr<AuthenticatedRequestInterface> GetWeakPtr() = 0; 82 virtual base::WeakPtr<AuthenticatedRequestInterface> GetWeakPtr() = 0;
83 83
84 // Cancels the request. It will invoke the callback object passed in 84 // Cancels the request. It will invoke the callback object passed in
85 // each request's constructor with error code GDATA_CANCELLED. 85 // each request's constructor with error code DRIVE_CANCELLED.
86 virtual void Cancel() = 0; 86 virtual void Cancel() = 0;
87 }; 87 };
88 88
89 //=========================== ResponseWriter ================================== 89 //=========================== ResponseWriter ==================================
90 90
91 // Saves the response for the request to a file or string. 91 // Saves the response for the request to a file or string.
92 class ResponseWriter : public net::URLFetcherResponseWriter { 92 class ResponseWriter : public net::URLFetcherResponseWriter {
93 public: 93 public:
94 // If file_path is not empty, the response will be saved with file_writer_, 94 // If file_path is not empty, the response will be saved with file_writer_,
95 // otherwise it will be saved to data_. 95 // otherwise it will be saved to data_.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // is read. 174 // is read.
175 virtual void GetOutputFilePath(base::FilePath* local_file_path, 175 virtual void GetOutputFilePath(base::FilePath* local_file_path,
176 GetContentCallback* get_content_callback); 176 GetContentCallback* get_content_callback);
177 177
178 // Invoked by OnURLFetchComplete when the request completes without an 178 // Invoked by OnURLFetchComplete when the request completes without an
179 // authentication error. Must be implemented by a derived class. 179 // authentication error. Must be implemented by a derived class.
180 virtual void ProcessURLFetchResults(const net::URLFetcher* source) = 0; 180 virtual void ProcessURLFetchResults(const net::URLFetcher* source) = 0;
181 181
182 // Invoked by this base class upon an authentication error or cancel by 182 // Invoked by this base class upon an authentication error or cancel by
183 // a user request. Must be implemented by a derived class. 183 // a user request. Must be implemented by a derived class.
184 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) = 0; 184 virtual void RunCallbackOnPrematureFailure(DriveApiErrorCode code) = 0;
185 185
186 // Invoked from derived classes when ProcessURLFetchResults() is completed. 186 // Invoked from derived classes when ProcessURLFetchResults() is completed.
187 void OnProcessURLFetchResultsComplete(); 187 void OnProcessURLFetchResultsComplete();
188 188
189 // Returns an appropriate GDataErrorCode based on the HTTP response code and 189 // Returns an appropriate DriveApiErrorCode based on the HTTP response code
190 // the status of the URLFetcher. 190 // and the status of the URLFetcher.
191 GDataErrorCode GetErrorCode(); 191 DriveApiErrorCode GetErrorCode();
192 192
193 // Returns true if called on the thread where the constructor was called. 193 // Returns true if called on the thread where the constructor was called.
194 bool CalledOnValidThread(); 194 bool CalledOnValidThread();
195 195
196 // Returns the writer which is used to save the response for the request. 196 // Returns the writer which is used to save the response for the request.
197 ResponseWriter* response_writer() const { return response_writer_; } 197 ResponseWriter* response_writer() const { return response_writer_; }
198 198
199 // Returns the task runner that should be used for blocking tasks. 199 // Returns the task runner that should be used for blocking tasks.
200 base::SequencedTaskRunner* blocking_task_runner() const; 200 base::SequencedTaskRunner* blocking_task_runner() const;
201 201
202 private: 202 private:
203 // URLFetcherDelegate overrides. 203 // URLFetcherDelegate overrides.
204 void OnURLFetchComplete(const net::URLFetcher* source) override; 204 void OnURLFetchComplete(const net::URLFetcher* source) override;
205 205
206 // AuthenticatedRequestInterface overrides. 206 // AuthenticatedRequestInterface overrides.
207 void OnAuthFailed(GDataErrorCode code) override; 207 void OnAuthFailed(DriveApiErrorCode code) override;
208 208
209 ReAuthenticateCallback re_authenticate_callback_; 209 ReAuthenticateCallback re_authenticate_callback_;
210 int re_authenticate_count_; 210 int re_authenticate_count_;
211 scoped_ptr<net::URLFetcher> url_fetcher_; 211 scoped_ptr<net::URLFetcher> url_fetcher_;
212 ResponseWriter* response_writer_; // Owned by |url_fetcher_|. 212 ResponseWriter* response_writer_; // Owned by |url_fetcher_|.
213 RequestSender* sender_; 213 RequestSender* sender_;
214 GDataErrorCode error_code_; 214 DriveApiErrorCode error_code_;
215 215
216 base::ThreadChecker thread_checker_; 216 base::ThreadChecker thread_checker_;
217 217
218 // Note: This should remain the last member so it'll be destroyed and 218 // Note: This should remain the last member so it'll be destroyed and
219 // invalidate its weak pointers before any other members are destroyed. 219 // invalidate its weak pointers before any other members are destroyed.
220 base::WeakPtrFactory<UrlFetchRequestBase> weak_ptr_factory_; 220 base::WeakPtrFactory<UrlFetchRequestBase> weak_ptr_factory_;
221 221
222 DISALLOW_COPY_AND_ASSIGN(UrlFetchRequestBase); 222 DISALLOW_COPY_AND_ASSIGN(UrlFetchRequestBase);
223 }; 223 };
224 224
225 //============================ EntryActionRequest ============================ 225 //============================ EntryActionRequest ============================
226 226
227 // Callback type for requests that return only error status, like: Delete/Move. 227 // Callback type for requests that return only error status, like: Delete/Move.
228 typedef base::Callback<void(GDataErrorCode error)> EntryActionCallback; 228 typedef base::Callback<void(DriveApiErrorCode error)> EntryActionCallback;
229 229
230 // This class performs a simple action over a given entry (document/file). 230 // This class performs a simple action over a given entry (document/file).
231 // It is meant to be used for requests that return no JSON blobs. 231 // It is meant to be used for requests that return no JSON blobs.
232 class EntryActionRequest : public UrlFetchRequestBase { 232 class EntryActionRequest : public UrlFetchRequestBase {
233 public: 233 public:
234 // |callback| is called when the request is finished either by success or by 234 // |callback| is called when the request is finished either by success or by
235 // failure. It must not be null. 235 // failure. It must not be null.
236 EntryActionRequest(RequestSender* sender, 236 EntryActionRequest(RequestSender* sender,
237 const EntryActionCallback& callback); 237 const EntryActionCallback& callback);
238 ~EntryActionRequest() override; 238 ~EntryActionRequest() override;
239 239
240 protected: 240 protected:
241 // Overridden from UrlFetchRequestBase. 241 // Overridden from UrlFetchRequestBase.
242 void ProcessURLFetchResults(const net::URLFetcher* source) override; 242 void ProcessURLFetchResults(const net::URLFetcher* source) override;
243 void RunCallbackOnPrematureFailure(GDataErrorCode code) override; 243 void RunCallbackOnPrematureFailure(DriveApiErrorCode code) override;
244 244
245 private: 245 private:
246 const EntryActionCallback callback_; 246 const EntryActionCallback callback_;
247 247
248 DISALLOW_COPY_AND_ASSIGN(EntryActionRequest); 248 DISALLOW_COPY_AND_ASSIGN(EntryActionRequest);
249 }; 249 };
250 250
251 //=========================== InitiateUploadRequestBase======================= 251 //=========================== InitiateUploadRequestBase=======================
252 252
253 // Callback type for DriveServiceInterface::InitiateUpload. 253 // Callback type for DriveServiceInterface::InitiateUpload.
254 typedef base::Callback<void(GDataErrorCode error, 254 typedef base::Callback<void(DriveApiErrorCode error,
255 const GURL& upload_url)> InitiateUploadCallback; 255 const GURL& upload_url)> InitiateUploadCallback;
256 256
257 // This class provides base implementation for performing the request for 257 // This class provides base implementation for performing the request for
258 // initiating the upload of a file. 258 // initiating the upload of a file.
259 // |callback| will be called with the obtained upload URL. The URL will be 259 // |callback| will be called with the obtained upload URL. The URL will be
260 // used with requests for resuming the file uploading. 260 // used with requests for resuming the file uploading.
261 // 261 //
262 // Here's the flow of uploading: 262 // Here's the flow of uploading:
263 // 1) Get the upload URL with a class inheriting InitiateUploadRequestBase. 263 // 1) Get the upload URL with a class inheriting InitiateUploadRequestBase.
264 // 2) Upload the first 1GB (see kUploadChunkSize in drive_uploader.cc) 264 // 2) Upload the first 1GB (see kUploadChunkSize in drive_uploader.cc)
265 // of the target file to the upload URL 265 // of the target file to the upload URL
266 // 3) If there is more data to upload, go to 2). 266 // 3) If there is more data to upload, go to 2).
267 // 267 //
268 class InitiateUploadRequestBase : public UrlFetchRequestBase { 268 class InitiateUploadRequestBase : public UrlFetchRequestBase {
269 protected: 269 protected:
270 // |callback| will be called with the upload URL, where upload data is 270 // |callback| will be called with the upload URL, where upload data is
271 // uploaded to with ResumeUploadRequestBase. It must not be null. 271 // uploaded to with ResumeUploadRequestBase. It must not be null.
272 // |content_type| and |content_length| should be the attributes of the 272 // |content_type| and |content_length| should be the attributes of the
273 // uploading file. 273 // uploading file.
274 InitiateUploadRequestBase(RequestSender* sender, 274 InitiateUploadRequestBase(RequestSender* sender,
275 const InitiateUploadCallback& callback, 275 const InitiateUploadCallback& callback,
276 const std::string& content_type, 276 const std::string& content_type,
277 int64 content_length); 277 int64 content_length);
278 ~InitiateUploadRequestBase() override; 278 ~InitiateUploadRequestBase() override;
279 279
280 // UrlFetchRequestBase overrides. 280 // UrlFetchRequestBase overrides.
281 void ProcessURLFetchResults(const net::URLFetcher* source) override; 281 void ProcessURLFetchResults(const net::URLFetcher* source) override;
282 void RunCallbackOnPrematureFailure(GDataErrorCode code) override; 282 void RunCallbackOnPrematureFailure(DriveApiErrorCode code) override;
283 std::vector<std::string> GetExtraRequestHeaders() const override; 283 std::vector<std::string> GetExtraRequestHeaders() const override;
284 284
285 private: 285 private:
286 const InitiateUploadCallback callback_; 286 const InitiateUploadCallback callback_;
287 const std::string content_type_; 287 const std::string content_type_;
288 const int64 content_length_; 288 const int64 content_length_;
289 289
290 DISALLOW_COPY_AND_ASSIGN(InitiateUploadRequestBase); 290 DISALLOW_COPY_AND_ASSIGN(InitiateUploadRequestBase);
291 }; 291 };
292 292
293 //========================== UploadRangeRequestBase ========================== 293 //========================== UploadRangeRequestBase ==========================
294 294
295 // Struct for response to ResumeUpload and GetUploadStatus. 295 // Struct for response to ResumeUpload and GetUploadStatus.
296 struct UploadRangeResponse { 296 struct UploadRangeResponse {
297 UploadRangeResponse(); 297 UploadRangeResponse();
298 UploadRangeResponse(GDataErrorCode code, 298 UploadRangeResponse(DriveApiErrorCode code,
299 int64 start_position_received, 299 int64 start_position_received,
300 int64 end_position_received); 300 int64 end_position_received);
301 ~UploadRangeResponse(); 301 ~UploadRangeResponse();
302 302
303 GDataErrorCode code; 303 DriveApiErrorCode code;
304 // The values of "Range" header returned from the server. The values are 304 // The values of "Range" header returned from the server. The values are
305 // used to continue uploading more data. These are set to -1 if an upload 305 // used to continue uploading more data. These are set to -1 if an upload
306 // is complete. 306 // is complete.
307 // |start_position_received| is inclusive and |end_position_received| is 307 // |start_position_received| is inclusive and |end_position_received| is
308 // exclusive to follow the common C++ manner, although the response from 308 // exclusive to follow the common C++ manner, although the response from
309 // the server has "Range" header in inclusive format at both sides. 309 // the server has "Range" header in inclusive format at both sides.
310 int64 start_position_received; 310 int64 start_position_received;
311 int64 end_position_received; 311 int64 end_position_received;
312 }; 312 };
313 313
314 // Base class for a URL fetch request expecting the response containing the 314 // Base class for a URL fetch request expecting the response containing the
315 // current uploading range. This class processes the response containing 315 // current uploading range. This class processes the response containing
316 // "Range" header and invoke OnRangeRequestComplete. 316 // "Range" header and invoke OnRangeRequestComplete.
317 class UploadRangeRequestBase : public UrlFetchRequestBase { 317 class UploadRangeRequestBase : public UrlFetchRequestBase {
318 protected: 318 protected:
319 // |upload_url| is the URL of where to upload the file to. 319 // |upload_url| is the URL of where to upload the file to.
320 UploadRangeRequestBase(RequestSender* sender, const GURL& upload_url); 320 UploadRangeRequestBase(RequestSender* sender, const GURL& upload_url);
321 ~UploadRangeRequestBase() override; 321 ~UploadRangeRequestBase() override;
322 322
323 // UrlFetchRequestBase overrides. 323 // UrlFetchRequestBase overrides.
324 GURL GetURL() const override; 324 GURL GetURL() const override;
325 net::URLFetcher::RequestType GetRequestType() const override; 325 net::URLFetcher::RequestType GetRequestType() const override;
326 void ProcessURLFetchResults(const net::URLFetcher* source) override; 326 void ProcessURLFetchResults(const net::URLFetcher* source) override;
327 void RunCallbackOnPrematureFailure(GDataErrorCode code) override; 327 void RunCallbackOnPrematureFailure(DriveApiErrorCode code) override;
328 328
329 // This method will be called when the request is done, regardless of 329 // This method will be called when the request is done, regardless of
330 // whether it is succeeded or failed. 330 // whether it is succeeded or failed.
331 // 331 //
332 // 1) If there is more data to upload, |code| of |response| is set to 332 // 1) If there is more data to upload, |code| of |response| is set to
333 // HTTP_RESUME_INCOMPLETE, and positions are set appropriately. Also, |value| 333 // HTTP_RESUME_INCOMPLETE, and positions are set appropriately. Also, |value|
334 // will be set to NULL. 334 // will be set to NULL.
335 // 2) If the upload is complete, |code| is set to HTTP_CREATED for a new file 335 // 2) If the upload is complete, |code| is set to HTTP_CREATED for a new file
336 // or HTTP_SUCCESS for an existing file. Positions are set to -1, and |value| 336 // or HTTP_SUCCESS for an existing file. Positions are set to -1, and |value|
337 // is set to a parsed JSON value representing the uploaded file. 337 // is set to a parsed JSON value representing the uploaded file.
338 // 3) If a premature failure is found, |code| is set to a value representing 338 // 3) If a premature failure is found, |code| is set to a value representing
339 // the situation. Positions are set to 0, and |value| is set to NULL. 339 // the situation. Positions are set to 0, and |value| is set to NULL.
340 // 340 //
341 // See also the comments for UploadRangeResponse. 341 // See also the comments for UploadRangeResponse.
342 // Note: Subclasses should have responsibility to run some callback 342 // Note: Subclasses should have responsibility to run some callback
343 // in this method to notify the finish status to its clients (or ignore it 343 // in this method to notify the finish status to its clients (or ignore it
344 // under its responsibility). 344 // under its responsibility).
345 virtual void OnRangeRequestComplete( 345 virtual void OnRangeRequestComplete(
346 const UploadRangeResponse& response, scoped_ptr<base::Value> value) = 0; 346 const UploadRangeResponse& response, scoped_ptr<base::Value> value) = 0;
347 347
348 private: 348 private:
349 // Called when ParseJson() is completed. 349 // Called when ParseJson() is completed.
350 void OnDataParsed(GDataErrorCode code, scoped_ptr<base::Value> value); 350 void OnDataParsed(DriveApiErrorCode code, scoped_ptr<base::Value> value);
351 351
352 const GURL upload_url_; 352 const GURL upload_url_;
353 353
354 // Note: This should remain the last member so it'll be destroyed and 354 // Note: This should remain the last member so it'll be destroyed and
355 // invalidate its weak pointers before any other members are destroyed. 355 // invalidate its weak pointers before any other members are destroyed.
356 base::WeakPtrFactory<UploadRangeRequestBase> weak_ptr_factory_; 356 base::WeakPtrFactory<UploadRangeRequestBase> weak_ptr_factory_;
357 357
358 DISALLOW_COPY_AND_ASSIGN(UploadRangeRequestBase); 358 DISALLOW_COPY_AND_ASSIGN(UploadRangeRequestBase);
359 }; 359 };
360 360
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 464
465 // Overridden from AuthenticatedRequestInterface. 465 // Overridden from AuthenticatedRequestInterface.
466 void Start(const std::string& access_token, 466 void Start(const std::string& access_token,
467 const std::string& custom_user_agent, 467 const std::string& custom_user_agent,
468 const ReAuthenticateCallback& callback) override; 468 const ReAuthenticateCallback& callback) override;
469 469
470 // Overridden from UrlFetchRequestBase. 470 // Overridden from UrlFetchRequestBase.
471 bool GetContentData(std::string* upload_content_type, 471 bool GetContentData(std::string* upload_content_type,
472 std::string* upload_content) override; 472 std::string* upload_content) override;
473 void ProcessURLFetchResults(const net::URLFetcher* source) override; 473 void ProcessURLFetchResults(const net::URLFetcher* source) override;
474 void RunCallbackOnPrematureFailure(GDataErrorCode code) override; 474 void RunCallbackOnPrematureFailure(DriveApiErrorCode code) override;
475 475
476 // content::UrlFetcherDelegate overrides. 476 // content::UrlFetcherDelegate overrides.
477 void OnURLFetchUploadProgress(const net::URLFetcher* source, 477 void OnURLFetchUploadProgress(const net::URLFetcher* source,
478 int64 current, 478 int64 current,
479 int64 total) override; 479 int64 total) override;
480 480
481 // Parses the response value and invokes |callback_| with |FileResource|. 481 // Parses the response value and invokes |callback_| with |FileResource|.
482 void OnDataParsed(GDataErrorCode code, scoped_ptr<base::Value> value); 482 void OnDataParsed(DriveApiErrorCode code, scoped_ptr<base::Value> value);
483 483
484 // Whether to the request has modified date information or not. 484 // Whether to the request has modified date information or not.
485 bool has_modified_date() const { return has_modified_date_; } 485 bool has_modified_date() const { return has_modified_date_; }
486 486
487 private: 487 private:
488 // Continues to rest part of |Start| method after determining boundary string 488 // Continues to rest part of |Start| method after determining boundary string
489 // of multipart/related. 489 // of multipart/related.
490 void OnPrepareUploadContent(const std::string& access_token, 490 void OnPrepareUploadContent(const std::string& access_token,
491 const std::string& custom_user_agent, 491 const std::string& custom_user_agent,
492 const ReAuthenticateCallback& callback, 492 const ReAuthenticateCallback& callback,
(...skipping 18 matching lines...) Expand all
511 // Note: This should remain the last member so it'll be destroyed and 511 // Note: This should remain the last member so it'll be destroyed and
512 // invalidate its weak pointers before any other members are destroyed. 512 // invalidate its weak pointers before any other members are destroyed.
513 base::WeakPtrFactory<MultipartUploadRequestBase> weak_ptr_factory_; 513 base::WeakPtrFactory<MultipartUploadRequestBase> weak_ptr_factory_;
514 514
515 DISALLOW_COPY_AND_ASSIGN(MultipartUploadRequestBase); 515 DISALLOW_COPY_AND_ASSIGN(MultipartUploadRequestBase);
516 }; 516 };
517 517
518 //============================ DownloadFileRequest =========================== 518 //============================ DownloadFileRequest ===========================
519 519
520 // Callback type for receiving the completion of DownloadFileRequest. 520 // Callback type for receiving the completion of DownloadFileRequest.
521 typedef base::Callback<void(GDataErrorCode error, 521 typedef base::Callback<void(DriveApiErrorCode error,
522 const base::FilePath& temp_file)> 522 const base::FilePath& temp_file)>
523 DownloadActionCallback; 523 DownloadActionCallback;
524 524
525 // This is a base class for performing the request for downloading a file. 525 // This is a base class for performing the request for downloading a file.
526 class DownloadFileRequestBase : public UrlFetchRequestBase { 526 class DownloadFileRequestBase : public UrlFetchRequestBase {
527 public: 527 public:
528 // download_action_callback: 528 // download_action_callback:
529 // This callback is called when the download is complete. Must not be null. 529 // This callback is called when the download is complete. Must not be null.
530 // 530 //
531 // get_content_callback: 531 // get_content_callback:
(...skipping 18 matching lines...) Expand all
550 const GURL& download_url, 550 const GURL& download_url,
551 const base::FilePath& output_file_path); 551 const base::FilePath& output_file_path);
552 ~DownloadFileRequestBase() override; 552 ~DownloadFileRequestBase() override;
553 553
554 protected: 554 protected:
555 // UrlFetchRequestBase overrides. 555 // UrlFetchRequestBase overrides.
556 GURL GetURL() const override; 556 GURL GetURL() const override;
557 void GetOutputFilePath(base::FilePath* local_file_path, 557 void GetOutputFilePath(base::FilePath* local_file_path,
558 GetContentCallback* get_content_callback) override; 558 GetContentCallback* get_content_callback) override;
559 void ProcessURLFetchResults(const net::URLFetcher* source) override; 559 void ProcessURLFetchResults(const net::URLFetcher* source) override;
560 void RunCallbackOnPrematureFailure(GDataErrorCode code) override; 560 void RunCallbackOnPrematureFailure(DriveApiErrorCode code) override;
561 561
562 // net::URLFetcherDelegate overrides. 562 // net::URLFetcherDelegate overrides.
563 void OnURLFetchDownloadProgress(const net::URLFetcher* source, 563 void OnURLFetchDownloadProgress(const net::URLFetcher* source,
564 int64 current, 564 int64 current,
565 int64 total) override; 565 int64 total) override;
566 566
567 private: 567 private:
568 const DownloadActionCallback download_action_callback_; 568 const DownloadActionCallback download_action_callback_;
569 const GetContentCallback get_content_callback_; 569 const GetContentCallback get_content_callback_;
570 const ProgressCallback progress_callback_; 570 const ProgressCallback progress_callback_;
571 const GURL download_url_; 571 const GURL download_url_;
572 const base::FilePath output_file_path_; 572 const base::FilePath output_file_path_;
573 573
574 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequestBase); 574 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequestBase);
575 }; 575 };
576 576
577 } // namespace google_apis 577 } // namespace google_apis
578 578
579 #endif // GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ 579 #endif // GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698