 Chromium Code Reviews
 Chromium Code Reviews Issue 1218773003:
  Implement a DRIVE_REQUEST_TOO_LARGE backoff.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1218773003:
  Implement a DRIVE_REQUEST_TOO_LARGE backoff.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef GOOGLE_APIS_DRIVE_FILES_LIST_REQUEST_RUNNER_H_ | |
| 6 #define GOOGLE_APIS_DRIVE_FILES_LIST_REQUEST_RUNNER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/callback_forward.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "google_apis/drive/drive_api_requests.h" | |
| 15 #include "google_apis/drive/drive_api_url_generator.h" | |
| 16 #include "google_apis/drive/drive_common_callbacks.h" | |
| 17 | |
| 18 namespace google_apis { | |
| 19 | |
| 20 class RequestSender; | |
| 21 | |
| 22 // Runs file list requests (the FileListRequest class) with a backoff retry | |
| 23 // logic in case of the DRIVE_RESPONSE_TOO_LARGE error code. | |
| 24 class FilesListRequestRunner { | |
| 
Primiano Tucci (use gerrit)
2015/06/30 09:25:04
I think these should be SOMETHING_EXPORT, this bro
 | |
| 25 public: | |
| 26 FilesListRequestRunner( | |
| 27 RequestSender* request_sender, | |
| 28 const google_apis::DriveApiUrlGenerator& url_generator); | |
| 29 | |
| 30 // Creates a FilesListRequest instance and starts the request with a backoff | |
| 31 // retry in case of DRIVE_RESPONSE_TOO_LARGE error code. | |
| 32 CancelCallback CreateAndStartWithSizeBackoff( | |
| 33 int max_results, | |
| 34 const std::string& q, | |
| 35 const std::string& fields, | |
| 36 const FileListCallback& callback); | |
| 37 | |
| 38 ~FilesListRequestRunner(); | |
| 39 | |
| 40 void SetRequestCompletedCallbackForTesting(const base::Closure& callback); | |
| 41 | |
| 42 private: | |
| 43 // Called when the cancelling callback returned by | |
| 44 // CreateAndStartWithSizeBackoff is invoked. Once called cancels the current | |
| 45 // request. | |
| 46 void OnCancel(CancelCallback* cancel_callback); | |
| 47 | |
| 48 // 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 // half of the requests. | |
| 51 void OnCompleted(int max_results, | |
| 52 const std::string& q, | |
| 53 const std::string& fields, | |
| 54 const FileListCallback& callback, | |
| 55 CancelCallback* cancel_callback, | |
| 56 DriveApiErrorCode error, | |
| 57 scoped_ptr<FileList> entry); | |
| 58 | |
| 59 RequestSender* request_sender_; // Not owned. | |
| 60 const google_apis::DriveApiUrlGenerator url_generator_; // Not owned. | |
| 61 base::Closure request_completed_callback_for_testing_; | |
| 62 | |
| 63 // Note: This should remain the last member so it'll be destroyed and | |
| 64 // invalidate its weak pointers before any other members are destroyed. | |
| 65 base::WeakPtrFactory<FilesListRequestRunner> weak_ptr_factory_; | |
| 66 DISALLOW_COPY_AND_ASSIGN(FilesListRequestRunner); | |
| 67 }; | |
| 68 | |
| 69 } // namespace google_apis | |
| 70 | |
| 71 #endif // GOOGLE_APIS_DRIVE_FILES_LIST_REQUEST_RUNNER_H_ | |
| OLD | NEW |