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

Unified Diff: chrome/browser/chromeos/policy/system_log_upload_job.h

Issue 1193333017: Added system log uploader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved SystemLogUploadJob creation to DeviceCloudPolicyManager. Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
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..0e89e4272c19b8e74b9be0c0796205ea8bfe9402
--- /dev/null
+++ b/chrome/browser/chromeos/policy/system_log_upload_job.h
@@ -0,0 +1,84 @@
+// 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 periodically uploading system logs.
+class SystemLogUploadJob : public UploadJob::Delegate {
+ public:
+ typedef base::Callback<void(
+ const std::map<std::string, std::string>& system_logs)> LogUploadCallback;
Andrew T Wilson (Slow) 2015/06/29 15:06:09 Maybe make a typedef for std::map<string, string>
Polina Bondarenko 2015/07/02 15:28:04 Done, changed to std::vector of pairs
+
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ // Loads system logs.
+ virtual void LoadSystemLogs(const LogUploadCallback& upload_callback) = 0;
+
+ // Creates a new fully configured instance of an UploadJob. This method
+ // may be called any number of times.
+ virtual scoped_ptr<UploadJob> CreateUploadJob(const GURL&,
+ UploadJob::Delegate*) = 0;
+ };
+
+ // Constructor.
+ explicit SystemLogUploadJob(scoped_ptr<Delegate> syslog_delegate);
+
+ // Destructor.
+ ~SystemLogUploadJob() override;
+
+ // Start system log upload.
+ void Run(const base::Closure& succeeded_callback,
+ const base::Closure& failed_callback);
+ // Terminate system log upload.
Andrew T Wilson (Slow) 2015/06/29 15:06:09 nit: blank line above
Polina Bondarenko 2015/07/02 15:28:04 Done, removed the function.
+ void Terminate();
Andrew T Wilson (Slow) 2015/06/29 15:06:09 Why have a Terminate() function? Can the caller ju
Polina Bondarenko 2015/07/02 15:28:04 Done.
+
+ private:
+ // UploadJob::Delegate:
+ void OnSuccess() override;
+ void OnFailure(UploadJob::ErrorCode error_code) override;
+
+ // Callback invoked periodically to start loading system logs.
+ void StartLoadSystemLogs();
+
+ // Callback invoked when system logs are successfully loaded,
+ // starts system log upload.
+ void StartUploadSystemLogs(
+ const std::map<std::string, std::string>& system_logs);
+
+ // The URL to which the POST request should be directed.
+ GURL upload_url_;
+
+ // The callback that will be called when the system logs were successfully
+ // uploaded.
+ base::Closure succeeded_callback_;
+
+ // The callback that will be called when system log upload failed.
+ 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_

Powered by Google App Engine
This is Rietveld 408576698