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

Unified Diff: chrome/browser/chromeos/policy/upload_job_impl.h

Issue 1875443003: Retry uploading in UploadJobImpl when error occurs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Retry when token request failed, add backoff, add log messages Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/policy/upload_job_impl.h
diff --git a/chrome/browser/chromeos/policy/upload_job_impl.h b/chrome/browser/chromeos/policy/upload_job_impl.h
index 96d7df125759418c052398d7dc0c212bc6076341..0c29376ce6fbdaab12e982a7ccd133df393ae306 100644
--- a/chrome/browser/chromeos/policy/upload_job_impl.h
+++ b/chrome/browser/chromeos/policy/upload_job_impl.h
@@ -54,7 +54,8 @@ class UploadJobImpl : public UploadJob,
OAuth2TokenService* token_service,
scoped_refptr<net::URLRequestContextGetter> url_context_getter,
Delegate* delegate,
- std::unique_ptr<MimeBoundaryGenerator> boundary_generator);
+ std::unique_ptr<MimeBoundaryGenerator> boundary_generator,
+ const scoped_refptr<base::SequencedTaskRunner> task_runner);
Andrew T Wilson (Slow) 2016/05/02 09:15:49 Do you make any assumptions about this task_runner
Marton Hunyady 2016/05/04 11:26:41 Done.
~UploadJobImpl() override;
// UploadJob:
@@ -66,6 +67,14 @@ class UploadJobImpl : public UploadJob,
private:
// Indicates the current state of the UploadJobImpl.
+ // State transitions for successful upload:
+ // IDLE -> ACQUIRING_TOKEN -> PREPARING_CONTENT -> UPLOADING -> SUCCESS
+ // If error happens, state goes back to ACQUIRING_TOKEN.
+ // State transitions when error occurs once:
+ // IDLE -> ACQUIRING_TOKEN -> PREPARING_CONTENT -> UPLOADING ->
+ // -> ACQUIRING_TOKEN -> PREPARING_CONTENT -> UPLOADING -> SUCCESS
+ // State transitions when tried unsuccessfully kMaxRetries times:
+ // ... -> PREPARING_CONTENT -> UPLOADING -> ERROR
enum State {
IDLE, // Start() has not been called.
ACQUIRING_TOKEN, // Trying to acquire the access token.
@@ -85,11 +94,13 @@ class UploadJobImpl : public UploadJob,
// net::URLFetcherDelegate:
void OnURLFetchComplete(const net::URLFetcher* source) override;
+ void HandleError(ErrorCode errorCode);
+
// Requests an access token for the upload scope.
void RequestAccessToken();
// Dispatches POST request to URLFetcher.
- void StartUpload(const std::string& access_token);
+ void StartUpload();
// Constructs the body of the POST request by concatenating the
// |data_segments_|, separated by appropriate content-disposition headers and
@@ -147,6 +158,13 @@ class UploadJobImpl : public UploadJob,
// The data chunks to be uploaded.
ScopedVector<DataSegment> data_segments_;
+ // TaskRunner used for scheduling retry attempts.
+ const scoped_refptr<base::SequencedTaskRunner> task_runner_;
+
+ // Should remain the last member so it will be destroyed first and
+ // invalidate all weak pointers.
+ base::WeakPtrFactory<UploadJobImpl> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(UploadJobImpl);
};

Powered by Google App Engine
This is Rietveld 408576698