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 // 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 |
(...skipping 11 matching lines...) Expand all Loading... |
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 RequestSender; | 30 class RequestSender; |
31 | 31 |
32 // Callback used to pass parsed JSON from ParseJson(). If parsing error occurs, | |
33 // then the passed argument is null. | |
34 typedef base::Callback<void(scoped_ptr<base::Value> value)> ParseJsonCallback; | |
35 | |
36 // Callback used for DownloadFileRequest and ResumeUploadRequestBase. | 32 // Callback used for DownloadFileRequest and ResumeUploadRequestBase. |
37 typedef base::Callback<void(int64 progress, int64 total)> ProgressCallback; | 33 typedef base::Callback<void(int64 progress, int64 total)> ProgressCallback; |
38 | 34 |
39 // Callback used to get the content from DownloadFileRequest. | 35 // Callback used to get the content from DownloadFileRequest. |
40 typedef base::Callback<void( | 36 typedef base::Callback<void( |
41 GDataErrorCode error, | 37 GDataErrorCode error, |
42 scoped_ptr<std::string> content)> GetContentCallback; | 38 scoped_ptr<std::string> content)> GetContentCallback; |
43 | 39 |
44 // Parses JSON passed in |json| on |blocking_task_runner|. Runs |callback| on | 40 // Parses JSON passed in |json|. Returns NULL on failure. |
45 // the calling thread when finished with either success or failure. | 41 scoped_ptr<base::Value> ParseJson(const std::string& json); |
46 // The callback must not be null. | |
47 void ParseJson(base::TaskRunner* blocking_task_runner, | |
48 const std::string& json, | |
49 const ParseJsonCallback& callback); | |
50 | 42 |
51 //======================= AuthenticatedRequestInterface ====================== | 43 //======================= AuthenticatedRequestInterface ====================== |
52 | 44 |
53 // An interface class for implementing a request which requires OAuth2 | 45 // An interface class for implementing a request which requires OAuth2 |
54 // authentication. | 46 // authentication. |
55 class AuthenticatedRequestInterface { | 47 class AuthenticatedRequestInterface { |
56 public: | 48 public: |
57 // Called when re-authentication is required. See Start() for details. | 49 // Called when re-authentication is required. See Start() for details. |
58 typedef base::Callback<void(AuthenticatedRequestInterface* request)> | 50 typedef base::Callback<void(AuthenticatedRequestInterface* request)> |
59 ReAuthenticateCallback; | 51 ReAuthenticateCallback; |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 const ProgressCallback progress_callback_; | 522 const ProgressCallback progress_callback_; |
531 const GURL download_url_; | 523 const GURL download_url_; |
532 const base::FilePath output_file_path_; | 524 const base::FilePath output_file_path_; |
533 | 525 |
534 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequestBase); | 526 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequestBase); |
535 }; | 527 }; |
536 | 528 |
537 } // namespace google_apis | 529 } // namespace google_apis |
538 | 530 |
539 #endif // GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ | 531 #endif // GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ |
OLD | NEW |