OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOAD_JOB_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOAD_JOB_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOAD_JOB_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOAD_JOB_H_ |
7 | 7 |
8 #include "base/cancelable_callback.h" | 8 #include "base/cancelable_callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 // Loads system logs and invokes |upload_callback|. | 29 // Loads system logs and invokes |upload_callback|. |
30 virtual void LoadSystemLogs(const LogUploadCallback& upload_callback) = 0; | 30 virtual void LoadSystemLogs(const LogUploadCallback& upload_callback) = 0; |
31 | 31 |
32 // Creates a new fully configured instance of an UploadJob. This method | 32 // Creates a new fully configured instance of an UploadJob. This method |
33 // may be called any number of times. | 33 // may be called any number of times. |
34 virtual scoped_ptr<UploadJob> CreateUploadJob(const GURL&, | 34 virtual scoped_ptr<UploadJob> CreateUploadJob(const GURL&, |
35 UploadJob::Delegate*) = 0; | 35 UploadJob::Delegate*) = 0; |
36 }; | 36 }; |
37 | 37 |
| 38 // Status of the job. |
| 39 enum Status { |
| 40 NOT_STARTED = 0, // The job is ready to be started. |
| 41 RUNNING, // The job was started and is running now. |
| 42 SUCCEEDED, // The job finished running successfully. |
| 43 FAILED, // The job finished running with failure. |
| 44 }; |
| 45 |
38 explicit SystemLogUploadJob(scoped_ptr<Delegate> syslog_delegate); | 46 explicit SystemLogUploadJob(scoped_ptr<Delegate> syslog_delegate); |
39 | 47 |
40 ~SystemLogUploadJob() override; | 48 ~SystemLogUploadJob() override; |
41 | 49 |
42 // Starts system log upload. | 50 // Get the current job status. |
| 51 Status status() const { return status_; } |
| 52 |
| 53 // Starts the system log upload. |
43 virtual void Run(const base::Closure& succeeded_callback, | 54 virtual void Run(const base::Closure& succeeded_callback, |
44 const base::Closure& failed_callback); | 55 const base::Closure& failed_callback); |
45 | 56 |
46 private: | 57 private: |
47 // UploadJob::Delegate: | 58 // UploadJob::Delegate: |
48 void OnSuccess() override; | 59 void OnSuccess() override; |
49 void OnFailure(UploadJob::ErrorCode error_code) override; | 60 void OnFailure(UploadJob::ErrorCode error_code) override; |
50 | 61 |
51 // Callback invoked periodically to start loading system logs. | 62 // Callback invoked periodically to start loading system logs. |
52 void StartLoadSystemLogs(); | 63 void StartLoadSystemLogs(); |
53 | 64 |
54 // Callback invoked when system logs are successfully loaded, | 65 // Callback invoked when system logs are successfully loaded, |
55 // starts system log upload. | 66 |
| 67 // The current status of this job. |
| 68 Status status_; |
| 69 |
| 70 // starts the system log upload. |
56 void StartUploadSystemLogs(const SystemLogs* system_logs); | 71 void StartUploadSystemLogs(const SystemLogs* system_logs); |
57 | 72 |
58 // The URL to which the POST request should be directed. | 73 // The URL to which the POST request should be directed. |
59 GURL upload_url_; | 74 GURL upload_url_; |
60 | 75 |
61 // The callback that will be called when the system logs were successfully | 76 // The callback that will be called when the system logs were successfully |
62 // uploaded. | 77 // uploaded. |
63 base::Closure succeeded_callback_; | 78 base::Closure succeeded_callback_; |
64 | 79 |
65 // The callback that will be called when system log upload failed. | 80 // The callback that will be called when system log upload failed. |
66 base::Closure failed_callback_; | 81 base::Closure failed_callback_; |
67 | 82 |
68 // The Delegate is used to load system logs and create UploadJobs. | 83 // The Delegate is used to load system logs and create UploadJobs. |
69 scoped_ptr<Delegate> syslog_delegate_; | 84 scoped_ptr<Delegate> syslog_delegate_; |
70 | 85 |
71 // The upload job instance that will upload the log files. | 86 // The upload job instance that will upload the log files. |
72 scoped_ptr<UploadJob> upload_job_; | 87 scoped_ptr<UploadJob> upload_job_; |
73 | 88 |
74 // Note: This should remain the last member so it'll be destroyed and | 89 // Note: This should remain the last member so it'll be destroyed and |
75 // invalidate the weak pointers before any other members are destroyed. | 90 // invalidate the weak pointers before any other members are destroyed. |
76 base::WeakPtrFactory<SystemLogUploadJob> weak_factory_; | 91 base::WeakPtrFactory<SystemLogUploadJob> weak_factory_; |
77 | 92 |
78 DISALLOW_COPY_AND_ASSIGN(SystemLogUploadJob); | 93 DISALLOW_COPY_AND_ASSIGN(SystemLogUploadJob); |
79 }; | 94 }; |
80 | 95 |
81 } // namespace policy | 96 } // namespace policy |
82 | 97 |
83 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOAD_JOB_H_ | 98 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOAD_JOB_H_ |
OLD | NEW |