Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 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 CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/memory/ref_counted_memory.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "base/time/time.h" | |
| 14 #include "chrome/browser/chromeos/policy/system_log_upload_job.h" | |
| 15 | |
| 16 namespace base { | |
| 17 class SequencedTaskRunner; | |
| 18 } | |
| 19 | |
| 20 namespace policy { | |
| 21 | |
| 22 // Class responsible for periodically uploading system logs. | |
| 23 class SystemLogUploader { | |
| 24 public: | |
| 25 // Constructor. | |
| 26 SystemLogUploader(const scoped_refptr<base::SequencedTaskRunner>& task_runner, | |
| 27 scoped_ptr<SystemLogUploadJob> upload_job); | |
|
Andrew T Wilson (Slow)
2015/06/29 15:06:09
I don't like having a persistent upload_job that y
Polina Bondarenko
2015/07/02 15:28:04
Done.
| |
| 28 | |
| 29 // Destructor. | |
|
Andrew T Wilson (Slow)
2015/06/29 15:06:09
Remove this comment (and the one above) - no need
Polina Bondarenko
2015/07/02 15:28:04
Done.
| |
| 30 ~SystemLogUploader(); | |
| 31 | |
| 32 // Returns the time of the last successful upload, or Time(0) if no upload | |
| 33 // has ever happened. | |
| 34 base::Time last_upload() const { return last_upload_; } | |
| 35 | |
| 36 private: | |
| 37 // Handles success and failure results of upload. | |
| 38 void OnSuccess(); | |
| 39 void OnFailure(); | |
| 40 | |
| 41 // Start upload system logs, run upload job. | |
| 42 void StartLogUpload(); | |
| 43 | |
| 44 // Helper method that figures out when the next system log upload should | |
| 45 // be scheduled. | |
| 46 void ScheduleNextSystemLogUpload(base::TimeDelta frequency); | |
| 47 | |
| 48 // Indicates whether the last log upload was successful or not the first | |
| 49 // failed. Because if log upload is failed, only one retry log upload should | |
|
Andrew T Wilson (Slow)
2015/06/29 15:06:09
This comment is a bit unclear. Maybe this flag sho
Polina Bondarenko
2015/07/02 15:28:04
Done.
| |
| 50 // be done. | |
| 51 bool last_success_; | |
| 52 | |
| 53 // How long to wait between system log uploads. | |
| 54 base::TimeDelta upload_frequency_; | |
| 55 | |
| 56 // The time the last upload was performed. | |
|
Andrew T Wilson (Slow)
2015/06/29 15:06:09
nit: "last successful upload"? Or just last upload
Polina Bondarenko
2015/07/02 15:28:04
Done. Renamed to last_upload_attempt_.
| |
| 57 base::Time last_upload_; | |
| 58 | |
| 59 // TaskRunner used for scheduling upload tasks. | |
| 60 const scoped_refptr<base::SequencedTaskRunner> task_runner_; | |
| 61 | |
| 62 // System log upload job. | |
|
Andrew T Wilson (Slow)
2015/06/29 15:06:09
Delete this comment or make it useful. Maybe talk
Polina Bondarenko
2015/07/02 15:28:04
Done.
| |
| 63 scoped_ptr<SystemLogUploadJob> upload_job_; | |
| 64 | |
| 65 // Note: This should remain the last member so it'll be destroyed and | |
| 66 // invalidate the weak pointers before any other members are destroyed. | |
| 67 base::WeakPtrFactory<SystemLogUploader> weak_factory_; | |
| 68 | |
| 69 DISALLOW_COPY_AND_ASSIGN(SystemLogUploader); | |
| 70 }; | |
| 71 | |
| 72 } // namespace policy | |
| 73 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ | |
| OLD | NEW |