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 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 the class creation time | |
31 // if no upload has 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 virtual SystemLogUploadJob* CreateSystemLogUploadJob(); | |
37 | |
38 // 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.
| |
39 void OnSuccess(); | |
40 void OnFailure(); | |
41 | |
42 // Starts upload system logs, creates upload job. | |
43 void StartLogUpload(); | |
44 | |
45 // Helper method that figures out when the next system log upload should | |
46 // be scheduled. | |
47 void ScheduleNextSystemLogUpload(base::TimeDelta frequency); | |
48 | |
49 // Indicates whether the next log upload should be retried after an error or | |
50 // not. | |
51 bool retrying_; | |
52 | |
53 // How long to wait between system log uploads. | |
54 base::TimeDelta upload_frequency_; | |
55 | |
56 // The time the last upload attempt was performed. | |
57 base::Time last_upload_attempt_; | |
58 | |
59 // TaskRunner used for scheduling upload tasks. | |
60 const scoped_refptr<base::SequencedTaskRunner> task_runner_; | |
61 | |
62 // The upload job that is re-created every time when the upload starts. | |
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 | |
74 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ | |
OLD | NEW |