Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_FEEDBACK_SYSTEM_LOGS_SYSTEM_LOGS_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_SYSTEM_LOGS_FETCHER_H_ |
| 6 #define CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_SYSTEM_LOGS_FETCHER_H_ | 6 #define CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_SYSTEM_LOGS_FETCHER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/callback.h" | 15 #include "base/callback.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "chrome/browser/feedback/system_logs/system_logs_source.h" | |
| 18 #include "components/feedback/anonymizer_tool.h" | 19 #include "components/feedback/anonymizer_tool.h" |
| 19 #include "components/feedback/feedback_common.h" | 20 #include "components/feedback/feedback_common.h" |
| 20 | 21 |
| 21 namespace system_logs { | 22 namespace system_logs { |
| 22 | 23 |
| 23 using SystemLogsResponse = FeedbackCommon::SystemLogsMap; | |
| 24 | |
| 25 // Callback that the data sources use to return data. | |
| 26 using SysLogsSourceCallback = base::Callback<void(SystemLogsResponse*)>; | |
| 27 | |
| 28 // Callback that the SystemLogsFetcher uses to return data. | 24 // Callback that the SystemLogsFetcher uses to return data. |
| 29 using SysLogsFetcherCallback = | 25 using SysLogsFetcherCallback = |
| 30 base::Callback<void(std::unique_ptr<SystemLogsResponse>)>; | 26 base::Callback<void(std::unique_ptr<SystemLogsResponse>)>; |
| 31 | 27 |
| 32 // The SystemLogsSource provides an interface for the data sources that | |
| 33 // the SystemLogsFetcher class uses to fetch logs and other information. | |
| 34 class SystemLogsSource { | |
| 35 public: | |
| 36 // |source_name| provides a descriptive identifier for debugging. | |
| 37 explicit SystemLogsSource(const std::string& source_name); | |
| 38 virtual ~SystemLogsSource(); | |
|
afakhry
2017/07/06 21:43:05
Sorry, I think I missed noticing in the review tha
| |
| 39 | |
| 40 // Fetches data and passes it by pointer to the callback | |
| 41 virtual void Fetch(const SysLogsSourceCallback& callback) = 0; | |
| 42 | |
| 43 const std::string& source_name() const { return source_name_; } | |
| 44 | |
| 45 private: | |
| 46 std::string source_name_; | |
| 47 }; | |
| 48 | |
| 49 // The SystemLogsFetcher fetches key-value data from a list of log sources. | 28 // The SystemLogsFetcher fetches key-value data from a list of log sources. |
| 50 // | 29 // |
| 51 // EXAMPLE: | 30 // EXAMPLE: |
| 52 // class Example { | 31 // class Example { |
| 53 // public: | 32 // public: |
| 54 // void ProcessLogs(SystemLogsResponse* response) { | 33 // void ProcessLogs(SystemLogsResponse* response) { |
| 55 // // do something with the logs | 34 // // do something with the logs |
| 56 // } | 35 // } |
| 57 // void GetLogs() { | 36 // void GetLogs() { |
| 58 // SystemLogsFetcher* fetcher = new SystemLogsFetcher(/*scrub_data=*/ true); | 37 // SystemLogsFetcher* fetcher = new SystemLogsFetcher(/*scrub_data=*/ true); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 std::unique_ptr<feedback::AnonymizerTool> anonymizer_; | 74 std::unique_ptr<feedback::AnonymizerTool> anonymizer_; |
| 96 | 75 |
| 97 base::WeakPtrFactory<SystemLogsFetcher> weak_ptr_factory_; | 76 base::WeakPtrFactory<SystemLogsFetcher> weak_ptr_factory_; |
| 98 | 77 |
| 99 DISALLOW_COPY_AND_ASSIGN(SystemLogsFetcher); | 78 DISALLOW_COPY_AND_ASSIGN(SystemLogsFetcher); |
| 100 }; | 79 }; |
| 101 | 80 |
| 102 } // namespace system_logs | 81 } // namespace system_logs |
| 103 | 82 |
| 104 #endif // CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_SYSTEM_LOGS_FETCHER_H_ | 83 #endif // CHROME_BROWSER_FEEDBACK_SYSTEM_LOGS_SYSTEM_LOGS_FETCHER_H_ |
| OLD | NEW |