| 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_UPLOADER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 namespace policy { | 21 namespace policy { |
| 22 | 22 |
| 23 // Class responsible for periodically uploading system logs, it handles the | 23 // Class responsible for periodically uploading system logs, it handles the |
| 24 // server responses by UploadJob:Delegate callbacks. | 24 // server responses by UploadJob:Delegate callbacks. |
| 25 class SystemLogUploader : public UploadJob::Delegate { | 25 class SystemLogUploader : public UploadJob::Delegate { |
| 26 public: | 26 public: |
| 27 // Structure that stores the system log files as pairs: (file name, loaded | 27 // Structure that stores the system log files as pairs: (file name, loaded |
| 28 // from the disk binary file data). | 28 // from the disk binary file data). |
| 29 typedef std::vector<std::pair<std::string, std::string>> SystemLogs; | 29 typedef std::vector<std::pair<std::string, std::string>> SystemLogs; |
| 30 | 30 |
| 31 // Refresh constants. |
| 32 static const int64 kDefaultUploadDelayMs; |
| 33 static const int64 kErrorUploadDelayMs; |
| 34 |
| 35 // Http header constants to upload. |
| 36 static const char* const kNameFieldTemplate; |
| 37 static const char* const kFileTypeHeaderName; |
| 38 static const char* const kFileTypeLogFile; |
| 39 static const char* const kContentTypePlainText; |
| 40 |
| 31 // A delegate interface used by SystemLogUploader to read the system logs | 41 // A delegate interface used by SystemLogUploader to read the system logs |
| 32 // from the disk and create an upload job. | 42 // from the disk and create an upload job. |
| 33 class Delegate { | 43 class Delegate { |
| 34 public: | 44 public: |
| 35 typedef base::Callback<void(scoped_ptr<SystemLogs> system_logs)> | 45 typedef base::Callback<void(scoped_ptr<SystemLogs> system_logs)> |
| 36 LogUploadCallback; | 46 LogUploadCallback; |
| 37 | 47 |
| 38 virtual ~Delegate() {} | 48 virtual ~Delegate() {} |
| 39 | 49 |
| 40 // Loads system logs and invokes |upload_callback|. | 50 // Loads system logs and invokes |upload_callback|. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 // Note: This should remain the last member so it'll be destroyed and | 110 // Note: This should remain the last member so it'll be destroyed and |
| 101 // invalidate the weak pointers before any other members are destroyed. | 111 // invalidate the weak pointers before any other members are destroyed. |
| 102 base::WeakPtrFactory<SystemLogUploader> weak_factory_; | 112 base::WeakPtrFactory<SystemLogUploader> weak_factory_; |
| 103 | 113 |
| 104 DISALLOW_COPY_AND_ASSIGN(SystemLogUploader); | 114 DISALLOW_COPY_AND_ASSIGN(SystemLogUploader); |
| 105 }; | 115 }; |
| 106 | 116 |
| 107 } // namespace policy | 117 } // namespace policy |
| 108 | 118 |
| 109 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ | 119 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ |
| OLD | NEW |