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

Side by Side Diff: chrome/browser/chromeos/policy/system_log_uploader.h

Issue 1193333017: Added system log uploader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comments, moved SystemLogDelegate to system_log_uploader.cc Created 5 years, 5 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 unified diff | Download patch
OLDNEW
(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 explicit SystemLogUploader(
26 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
27
28 virtual ~SystemLogUploader();
29
30 // Returns the time of the last upload attempt, or Time(0) if no upload has
31 // ever happened.
32 base::Time last_upload_attempt() const { return last_upload_attempt_; }
33
34 private:
35 // Creates the system log upload job during every scheduled log upload,
36 // that invokes |succeeded_callabck| or |failed_callback| according to the
37 // server response on the system log upload.
38 virtual SystemLogUploadJob* CreateSystemLogUploadJob(
39 const base::Closure& succeeded_callback,
40 const base::Closure& failed_callback);
41
42 // Callbacks handle success and failure results of upload, destroy the upload
43 // job.
44 void OnSuccess();
45 void OnFailure();
46
47 // Starts upload system logs, creates upload job.
48 void StartLogUpload();
49
50 // Helper method that figures out when the next system log upload should
51 // be scheduled.
52 void ScheduleNextSystemLogUpload(base::TimeDelta frequency);
53
54 // The number of consequent retries after the failed uploads.
55 int retry_count_;
56
57 // How long to wait between system log uploads.
58 base::TimeDelta upload_frequency_;
59
60 // The time the last upload attempt was performed.
61 base::Time last_upload_attempt_;
62
63 // TaskRunner used for scheduling upload tasks.
64 const scoped_refptr<base::SequencedTaskRunner> task_runner_;
65
66 // The upload job that is re-created every time when the upload starts.
67 scoped_ptr<SystemLogUploadJob> upload_job_;
68
69 // Note: This should remain the last member so it'll be destroyed and
70 // invalidate the weak pointers before any other members are destroyed.
71 base::WeakPtrFactory<SystemLogUploader> weak_factory_;
72
73 DISALLOW_COPY_AND_ASSIGN(SystemLogUploader);
74 };
75
76 } // namespace policy
77
78 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698