Index: chrome/browser/chromeos/policy/system_log_upload_job.h |
diff --git a/chrome/browser/chromeos/policy/system_log_upload_job.h b/chrome/browser/chromeos/policy/system_log_upload_job.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..789a0960f02b6d3c1a00a16113fdd3e36d925725 |
--- /dev/null |
+++ b/chrome/browser/chromeos/policy/system_log_upload_job.h |
@@ -0,0 +1,86 @@ |
+// 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_UPLOAD_JOB_H_ |
+#define CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOAD_JOB_H_ |
+ |
+#include "base/cancelable_callback.h" |
+#include "base/macros.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/memory/weak_ptr.h" |
+#include "chrome/browser/chromeos/policy/upload_job.h" |
+ |
+namespace policy { |
+ |
+// Class responsible for doing a single system log upload. |
+class SystemLogUploadJob : public UploadJob::Delegate { |
+ public: |
+ // Structure that stores the system log files as pairs: (file name, loaded |
+ // from the disk binary file data). |
+ typedef std::vector<std::pair<std::string, std::string>> SystemLogs; |
+ |
+ // A delegate interface used by SystemLogUploadJob to read the system logs |
+ // from the disk and create an upload job. |
+ class Delegate { |
+ public: |
+ typedef base::Callback<void(const SystemLogs* system_logs)> |
+ LogUploadCallback; |
+ |
+ virtual ~Delegate() {} |
+ |
+ // Loads system logs and invokes |upload_callback|. |
+ virtual void LoadSystemLogs(const LogUploadCallback& upload_callback) = 0; |
Andrew T Wilson (Slow)
2015/07/17 15:43:57
One question - why do we have a Delegate class? Wh
Polina Bondarenko
2015/07/23 14:27:31
Removed SystemLogUploadJob at all. This Delegate i
|
+ |
+ // Creates a new fully configured instance of an UploadJob. This method |
+ // may be called any number of times. |
Andrew T Wilson (Slow)
2015/07/17 15:43:57
Either document under what situation it may be cal
Polina Bondarenko
2015/07/23 14:27:31
After changing structure this delegate (SystemLogD
|
+ virtual scoped_ptr<UploadJob> CreateUploadJob(const GURL&, |
Andrew T Wilson (Slow)
2015/07/17 15:43:57
nit: this is fine, but I still usually put names w
Polina Bondarenko
2015/07/23 14:27:31
Done.
|
+ UploadJob::Delegate*) = 0; |
Andrew T Wilson (Slow)
2015/07/17 15:43:57
It's vaguely confusing that you pass an UploadJob:
Polina Bondarenko
2015/07/23 14:27:31
Now it is moved to SystemLogUploader and SystemLog
|
+ }; |
+ |
+ SystemLogUploadJob(scoped_ptr<Delegate> syslog_delegate, |
+ const base::Closure& succeeded_callback, |
+ const base::Closure& failed_callback); |
+ |
+ ~SystemLogUploadJob() override; |
+ |
+ // Starts the system log upload, could be called only once for every created |
Andrew T Wilson (Slow)
2015/07/17 15:43:57
Nit: should only be called once on any SystemLogUp
Polina Bondarenko
2015/07/23 14:27:31
Fixed comment.
|
+ // upload job. |
+ void Run(); |
+ |
+ private: |
+ // UploadJob::Delegate: |
+ void OnSuccess() override; |
Andrew T Wilson (Slow)
2015/07/17 15:43:57
Think these should be public to match their defini
Polina Bondarenko
2015/07/23 14:27:31
Moved to the public section.
|
+ void OnFailure(UploadJob::ErrorCode error_code) override; |
+ |
+ // Callback invoked to start loading system logs. |
+ void StartLoadSystemLogs(); |
+ |
+ // Callback invoked when system logs are successfully loaded, |
+ // starts the system log upload. |
+ void StartUploadSystemLogs(const SystemLogs* system_logs); |
+ |
+ // The callback that will be called when the system logs were successfully |
+ // uploaded. It destroys the job. |
Andrew T Wilson (Slow)
2015/07/17 15:43:57
note instead that the callback *may* destroy this
Polina Bondarenko
2015/07/23 14:27:31
Removed this class and callbacks at all.
|
+ base::Closure succeeded_callback_; |
+ |
+ // The callback that will be called when system log upload failed. It destroys |
Andrew T Wilson (Slow)
2015/07/17 15:43:57
Ditto - note that invoking this callback can free
Polina Bondarenko
2015/07/23 14:27:31
Removed this class and callbacks at all.
|
+ // this job. |
+ base::Closure failed_callback_; |
+ |
+ // The Delegate is used to load system logs and create UploadJobs. |
+ scoped_ptr<Delegate> syslog_delegate_; |
+ |
+ // The upload job instance that will upload the log files. |
+ scoped_ptr<UploadJob> 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<SystemLogUploadJob> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SystemLogUploadJob); |
+}; |
+ |
+} // namespace policy |
+ |
+#endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOAD_JOB_H_ |