Chromium Code Reviews| 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..cbcbf5cd8b9a904bbd441436a99b2bb7220e25e2 100644 |
| --- a/chrome/browser/chromeos/policy/upload_job_impl.h |
| +++ b/chrome/browser/chromeos/policy/upload_job_impl.h |
| @@ -49,12 +49,15 @@ class UploadJobImpl : public UploadJob, |
| std::string GenerateBoundary() const override; // MimeBoundaryGenerator |
| }; |
| + // |task_runner| must belong to the same thread from which the consturctor and |
|
Andrew T Wilson (Slow)
2016/05/10 22:00:42
nit: constructor
Marton Hunyady
2016/05/11 12:55:30
Done.
|
| + // all the public methods are called. |
| UploadJobImpl(const GURL& upload_url, |
| const std::string& account_id, |
| 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); |
| ~UploadJobImpl() override; |
| // UploadJob: |
| @@ -66,6 +69,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 +96,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 +160,15 @@ 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_; |
| + |
| + base::ThreadChecker thread_checker_; |
| + |
| + // 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); |
| }; |