Chromium Code Reviews| Index: chrome/browser/chromeos/policy/system_log_uploader.h |
| diff --git a/chrome/browser/chromeos/policy/system_log_uploader.h b/chrome/browser/chromeos/policy/system_log_uploader.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7c1459eb76ff7ce41f09e4dc5a29aa0b05ae17c5 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/policy/system_log_uploader.h |
| @@ -0,0 +1,74 @@ |
| +// Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ |
| +#define CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/ref_counted_memory.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/time/time.h" |
| +#include "chrome/browser/chromeos/policy/system_log_upload_job.h" |
| + |
| +namespace base { |
| +class SequencedTaskRunner; |
| +} |
| + |
| +namespace policy { |
| + |
| +// Class responsible for periodically uploading system logs. |
| +class SystemLogUploader { |
| + public: |
| + explicit SystemLogUploader( |
| + const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
| + |
| + virtual ~SystemLogUploader(); |
| + |
| + // Returns the time of the last upload attempt, or the class creation time |
| + // if no upload has ever happened. |
| + base::Time last_upload_attempt() const { return last_upload_attempt_; } |
| + |
| + private: |
| + // Creates the system log upload job during every scheduled log upload. |
| + virtual SystemLogUploadJob* CreateSystemLogUploadJob(); |
| + |
| + // Handles success and failure results of upload. |
|
Andrew T Wilson (Slow)
2015/07/03 15:40:48
If these are callbacks, you should say so here.
Polina Bondarenko
2015/07/08 10:07:24
Done.
|
| + void OnSuccess(); |
| + void OnFailure(); |
| + |
| + // Starts upload system logs, creates upload job. |
| + void StartLogUpload(); |
| + |
| + // Helper method that figures out when the next system log upload should |
| + // be scheduled. |
| + void ScheduleNextSystemLogUpload(base::TimeDelta frequency); |
| + |
| + // Indicates whether the next log upload should be retried after an error or |
| + // not. |
| + bool retrying_; |
| + |
| + // How long to wait between system log uploads. |
| + base::TimeDelta upload_frequency_; |
| + |
| + // The time the last upload attempt was performed. |
| + base::Time last_upload_attempt_; |
| + |
| + // TaskRunner used for scheduling upload tasks. |
| + const scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| + |
| + // The upload job that is re-created every time when the upload starts. |
| + scoped_ptr<SystemLogUploadJob> upload_job_; |
| + |
| + // Note: This should remain the last member so it'll be destroyed and |
| + // invalidate the weak pointers before any other members are destroyed. |
| + base::WeakPtrFactory<SystemLogUploader> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SystemLogUploader); |
| +}; |
| + |
| +} // namespace policy |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ |