OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_FILES_LIST_REQUEST_RUNNER_H_ | 5 #ifndef GOOGLE_APIS_DRIVE_FILES_LIST_REQUEST_RUNNER_H_ |
6 #define GOOGLE_APIS_DRIVE_FILES_LIST_REQUEST_RUNNER_H_ | 6 #define GOOGLE_APIS_DRIVE_FILES_LIST_REQUEST_RUNNER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 class FilesListRequestRunner { | 24 class FilesListRequestRunner { |
25 public: | 25 public: |
26 FilesListRequestRunner( | 26 FilesListRequestRunner( |
27 RequestSender* request_sender, | 27 RequestSender* request_sender, |
28 const google_apis::DriveApiUrlGenerator& url_generator); | 28 const google_apis::DriveApiUrlGenerator& url_generator); |
29 | 29 |
30 // Creates a FilesListRequest instance and starts the request with a backoff | 30 // Creates a FilesListRequest instance and starts the request with a backoff |
31 // retry in case of DRIVE_RESPONSE_TOO_LARGE error code. | 31 // retry in case of DRIVE_RESPONSE_TOO_LARGE error code. |
32 CancelCallback CreateAndStartWithSizeBackoff( | 32 CancelCallback CreateAndStartWithSizeBackoff( |
33 int max_results, | 33 int max_results, |
| 34 const FilesListScope& scope, |
34 const std::string& q, | 35 const std::string& q, |
35 const std::string& fields, | 36 const std::string& fields, |
36 const FileListCallback& callback); | 37 const FileListCallback& callback); |
37 | 38 |
38 ~FilesListRequestRunner(); | 39 ~FilesListRequestRunner(); |
39 | 40 |
40 void SetRequestCompletedCallbackForTesting(const base::Closure& callback); | 41 void SetRequestCompletedCallbackForTesting(const base::Closure& callback); |
41 | 42 |
42 private: | 43 private: |
43 // Called when the cancelling callback returned by | 44 // Called when the cancelling callback returned by |
44 // CreateAndStartWithSizeBackoff is invoked. Once called cancels the current | 45 // CreateAndStartWithSizeBackoff is invoked. Once called cancels the current |
45 // request. | 46 // request. |
46 void OnCancel(CancelCallback* cancel_callback); | 47 void OnCancel(CancelCallback* cancel_callback); |
47 | 48 |
48 // Called when a single request is completed with either a success or an | 49 // Called when a single request is completed with either a success or an |
49 // error. In case of DRIVE_RESPONSE_TOO_LARGE it will retry the request with | 50 // error. In case of DRIVE_RESPONSE_TOO_LARGE it will retry the request with |
50 // half of the requests. | 51 // half of the requests. |
51 void OnCompleted(int max_results, | 52 void OnCompleted(int max_results, |
| 53 const FilesListScope& scope, |
52 const std::string& q, | 54 const std::string& q, |
53 const std::string& fields, | 55 const std::string& fields, |
54 const FileListCallback& callback, | 56 const FileListCallback& callback, |
55 CancelCallback* cancel_callback, | 57 CancelCallback* cancel_callback, |
56 DriveApiErrorCode error, | 58 DriveApiErrorCode error, |
57 std::unique_ptr<FileList> entry); | 59 std::unique_ptr<FileList> entry); |
58 | 60 |
59 RequestSender* request_sender_; // Not owned. | 61 RequestSender* request_sender_; // Not owned. |
60 const google_apis::DriveApiUrlGenerator url_generator_; // Not owned. | 62 const google_apis::DriveApiUrlGenerator url_generator_; // Not owned. |
61 base::Closure request_completed_callback_for_testing_; | 63 base::Closure request_completed_callback_for_testing_; |
62 | 64 |
63 // Note: This should remain the last member so it'll be destroyed and | 65 // Note: This should remain the last member so it'll be destroyed and |
64 // invalidate its weak pointers before any other members are destroyed. | 66 // invalidate its weak pointers before any other members are destroyed. |
65 base::WeakPtrFactory<FilesListRequestRunner> weak_ptr_factory_; | 67 base::WeakPtrFactory<FilesListRequestRunner> weak_ptr_factory_; |
66 DISALLOW_COPY_AND_ASSIGN(FilesListRequestRunner); | 68 DISALLOW_COPY_AND_ASSIGN(FilesListRequestRunner); |
67 }; | 69 }; |
68 | 70 |
69 } // namespace google_apis | 71 } // namespace google_apis |
70 | 72 |
71 #endif // GOOGLE_APIS_DRIVE_FILES_LIST_REQUEST_RUNNER_H_ | 73 #endif // GOOGLE_APIS_DRIVE_FILES_LIST_REQUEST_RUNNER_H_ |
OLD | NEW |