OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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_SYSTEM_LOGS_SINGLE_LOG_SOURCE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_LOGS_SINGLE_LOG_SOURCE_H_ |
| 7 |
| 8 #include <stddef.h> |
| 9 |
| 10 #include "base/files/file.h" |
| 11 #include "base/macros.h" |
| 12 #include "chrome/browser/feedback/system_logs/system_logs_fetcher_base.h" |
| 13 #include "components/feedback/anonymizer_tool.h" |
| 14 |
| 15 namespace system_logs { |
| 16 |
| 17 // Gathers log data from a single source, possibly incrementally. |
| 18 class SingleLogSource : public SystemLogsSource { |
| 19 public: |
| 20 enum class SupportedSource { |
| 21 // For /var/log/messages. |
| 22 kMessages, |
| 23 |
| 24 // For /var/log/ui/ui.LATEST. |
| 25 kUiLatest, |
| 26 }; |
| 27 |
| 28 explicit SingleLogSource(SupportedSource source); |
| 29 ~SingleLogSource() override; |
| 30 |
| 31 // system_logs::SystemLogsSource: |
| 32 void Fetch(const SysLogsSourceCallback& callback) override; |
| 33 |
| 34 protected: |
| 35 // For unit testing. |
| 36 base::File* mutable_file() { return &file_; } |
| 37 |
| 38 private: |
| 39 // Reads all available content from |file_| that has not already been read. |
| 40 void ReadFile(SystemLogsResponse* result); |
| 41 |
| 42 // Keeps track of how much data has been read from |file_|. |
| 43 size_t num_bytes_read_; |
| 44 |
| 45 // Handle for reading the log file that is source of logging data. |
| 46 base::File file_; |
| 47 |
| 48 // For removing PII from log results. |
| 49 feedback::AnonymizerTool anonymizer_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(SingleLogSource); |
| 52 }; |
| 53 |
| 54 } // namespace system_logs |
| 55 |
| 56 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_LOGS_SINGLE_LOG_SOURCE_H_ |
OLD | NEW |