| 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 <stdint.h> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
| 11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 13 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 14 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 15 #include "chrome/browser/chromeos/policy/upload_job.h" | 17 #include "chrome/browser/chromeos/policy/upload_job.h" |
| 16 #include "chrome/browser/chromeos/settings/cros_settings.h" | 18 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 17 | 19 |
| 18 namespace base { | 20 namespace base { |
| 19 class SequencedTaskRunner; | 21 class SequencedTaskRunner; |
| 20 } | 22 } |
| 21 | 23 |
| 22 namespace policy { | 24 namespace policy { |
| 23 | 25 |
| 24 // Class responsible for periodically uploading system logs, it handles the | 26 // Class responsible for periodically uploading system logs, it handles the |
| 25 // server responses by UploadJob:Delegate callbacks. | 27 // server responses by UploadJob:Delegate callbacks. |
| 26 class SystemLogUploader : public UploadJob::Delegate { | 28 class SystemLogUploader : public UploadJob::Delegate { |
| 27 public: | 29 public: |
| 28 // Structure that stores the system log files as pairs: (file name, loaded | 30 // Structure that stores the system log files as pairs: (file name, loaded |
| 29 // from the disk binary file data). | 31 // from the disk binary file data). |
| 30 typedef std::vector<std::pair<std::string, std::string>> SystemLogs; | 32 typedef std::vector<std::pair<std::string, std::string>> SystemLogs; |
| 31 | 33 |
| 32 // Refresh constants. | 34 // Refresh constants. |
| 33 static const int64 kDefaultUploadDelayMs; | 35 static const int64_t kDefaultUploadDelayMs; |
| 34 static const int64 kErrorUploadDelayMs; | 36 static const int64_t kErrorUploadDelayMs; |
| 35 | 37 |
| 36 // Http header constants to upload. | 38 // Http header constants to upload. |
| 37 static const char* const kNameFieldTemplate; | 39 static const char* const kNameFieldTemplate; |
| 38 static const char* const kFileTypeHeaderName; | 40 static const char* const kFileTypeHeaderName; |
| 39 static const char* const kFileTypeLogFile; | 41 static const char* const kFileTypeLogFile; |
| 40 static const char* const kContentTypePlainText; | 42 static const char* const kContentTypePlainText; |
| 41 | 43 |
| 42 // A delegate interface used by SystemLogUploader to read the system logs | 44 // A delegate interface used by SystemLogUploader to read the system logs |
| 43 // from the disk and create an upload job. | 45 // from the disk and create an upload job. |
| 44 class Delegate { | 46 class Delegate { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // Note: This should remain the last member so it'll be destroyed and | 129 // Note: This should remain the last member so it'll be destroyed and |
| 128 // invalidate the weak pointers before any other members are destroyed. | 130 // invalidate the weak pointers before any other members are destroyed. |
| 129 base::WeakPtrFactory<SystemLogUploader> weak_factory_; | 131 base::WeakPtrFactory<SystemLogUploader> weak_factory_; |
| 130 | 132 |
| 131 DISALLOW_COPY_AND_ASSIGN(SystemLogUploader); | 133 DISALLOW_COPY_AND_ASSIGN(SystemLogUploader); |
| 132 }; | 134 }; |
| 133 | 135 |
| 134 } // namespace policy | 136 } // namespace policy |
| 135 | 137 |
| 136 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ | 138 #endif // CHROME_BROWSER_CHROMEOS_POLICY_SYSTEM_LOG_UPLOADER_H_ |
| OLD | NEW |