| 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 private: | |
| 35 friend class SingleLogSourceTest; | |
| 36 | |
| 37 // Reads all available content from |file_| that has not already been read. | |
| 38 void ReadFile(SystemLogsResponse* result); | |
| 39 | |
| 40 // Keeps track of how much data has been read from |file_|. | |
| 41 size_t num_bytes_read_; | |
| 42 | |
| 43 // Handle for reading the log file that is source of logging data. | |
| 44 base::File file_; | |
| 45 | |
| 46 // For removing PII from log results. | |
| 47 feedback::AnonymizerTool anonymizer_; | |
| 48 | |
| 49 base::WeakPtrFactory<SingleLogSource> weak_ptr_factory_; | |
| 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 |