| 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..7abc6821e071fcdcc05c7ee1cd19cb9b94bdf779
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/policy/system_log_uploader.h
|
| @@ -0,0 +1,78 @@
|
| +// 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 Time(0) 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,
|
| + // that invokes |succeeded_callabck| or |failed_callback| according to the
|
| + // server response on the system log upload.
|
| + virtual SystemLogUploadJob* CreateSystemLogUploadJob(
|
| + const base::Closure& succeeded_callback,
|
| + const base::Closure& failed_callback);
|
| +
|
| + // Callbacks handle success and failure results of upload, destroy the upload
|
| + // job.
|
| + 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);
|
| +
|
| + // The number of consequent retries after the failed uploads.
|
| + int retry_count_;
|
| +
|
| + // 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_
|
|
|