Chromium Code Reviews| 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_UPLOAD_JOB_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOAD_JOB_H_ | |
| 7 | |
| 8 #include "base/cancelable_callback.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "chrome/browser/chromeos/policy/upload_job.h" | |
| 13 | |
| 14 namespace policy { | |
| 15 | |
| 16 // Class responsible for doing a single system log upload. | |
| 17 class SystemLogUploadJob : public UploadJob::Delegate { | |
| 18 public: | |
| 19 // Structure that stores the system log files as pairs: (file name, loaded | |
| 20 // from the disk binary file data). | |
| 21 typedef std::vector<std::pair<std::string, std::string>> SystemLogs; | |
| 22 | |
| 23 // A delegate interface used by SystemLogUploadJob to read the system logs | |
| 24 // from the disk and create an upload job. | |
| 25 class Delegate { | |
| 26 public: | |
| 27 typedef base::Callback<void(const SystemLogs* system_logs)> | |
| 28 LogUploadCallback; | |
| 29 | |
| 30 virtual ~Delegate() {} | |
| 31 | |
| 32 // Loads system logs and invokes |upload_callback|. | |
| 33 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
| |
| 34 | |
| 35 // Creates a new fully configured instance of an UploadJob. This method | |
| 36 // 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
| |
| 37 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.
| |
| 38 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
| |
| 39 }; | |
| 40 | |
| 41 SystemLogUploadJob(scoped_ptr<Delegate> syslog_delegate, | |
| 42 const base::Closure& succeeded_callback, | |
| 43 const base::Closure& failed_callback); | |
| 44 | |
| 45 ~SystemLogUploadJob() override; | |
| 46 | |
| 47 // 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.
| |
| 48 // upload job. | |
| 49 void Run(); | |
| 50 | |
| 51 private: | |
| 52 // UploadJob::Delegate: | |
| 53 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.
| |
| 54 void OnFailure(UploadJob::ErrorCode error_code) override; | |
| 55 | |
| 56 // Callback invoked to start loading system logs. | |
| 57 void StartLoadSystemLogs(); | |
| 58 | |
| 59 // Callback invoked when system logs are successfully loaded, | |
| 60 // starts the system log upload. | |
| 61 void StartUploadSystemLogs(const SystemLogs* system_logs); | |
| 62 | |
| 63 // The callback that will be called when the system logs were successfully | |
| 64 // 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.
| |
| 65 base::Closure succeeded_callback_; | |
| 66 | |
| 67 // 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.
| |
| 68 // this job. | |
| 69 base::Closure failed_callback_; | |
| 70 | |
| 71 // The Delegate is used to load system logs and create UploadJobs. | |
| 72 scoped_ptr<Delegate> syslog_delegate_; | |
| 73 | |
| 74 // The upload job instance that will upload the log files. | |
| 75 scoped_ptr<UploadJob> upload_job_; | |
| 76 | |
| 77 // Note: This should remain the last member so it'll be destroyed and | |
| 78 // invalidate the weak pointers before any other members are destroyed. | |
| 79 base::WeakPtrFactory<SystemLogUploadJob> weak_factory_; | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(SystemLogUploadJob); | |
| 82 }; | |
| 83 | |
| 84 } // namespace policy | |
| 85 | |
| 86 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOAD_JOB_H_ | |
| OLD | NEW |