diff options
Diffstat (limited to 'chrome/browser/feedback/system_logs')
5 files changed, 42 insertions, 11 deletions
diff --git a/chrome/browser/feedback/system_logs/about_system_logs_fetcher.h b/chrome/browser/feedback/system_logs/about_system_logs_fetcher.h index 708eec0..5938071 100644 --- a/chrome/browser/feedback/system_logs/about_system_logs_fetcher.h +++ b/chrome/browser/feedback/system_logs/about_system_logs_fetcher.h @@ -15,7 +15,7 @@ namespace system_logs { class AboutSystemLogsFetcher : public SystemLogsFetcherBase { public: AboutSystemLogsFetcher(); - ~AboutSystemLogsFetcher(); + ~AboutSystemLogsFetcher() override; private: diff --git a/chrome/browser/feedback/system_logs/scrubbed_system_logs_fetcher.cc b/chrome/browser/feedback/system_logs/scrubbed_system_logs_fetcher.cc index 24aa8de..eed5ce5 100644 --- a/chrome/browser/feedback/system_logs/scrubbed_system_logs_fetcher.cc +++ b/chrome/browser/feedback/system_logs/scrubbed_system_logs_fetcher.cc @@ -36,7 +36,8 @@ ScrubbedSystemLogsFetcher::ScrubbedSystemLogsFetcher() { data_sources_.push_back(new TouchLogSource()); // Debug Daemon data source - currently only this data source supports - // the scrub_data parameter. + // the scrub_data parameter but all others get processed by Rewrite() + // as well. const bool scrub_data = true; data_sources_.push_back(new DebugDaemonLogSource(scrub_data)); #endif @@ -47,4 +48,10 @@ ScrubbedSystemLogsFetcher::ScrubbedSystemLogsFetcher() { ScrubbedSystemLogsFetcher::~ScrubbedSystemLogsFetcher() { } +void ScrubbedSystemLogsFetcher::Rewrite(const std::string& source_name, + SystemLogsResponse* response) { + for (auto& element : *response) + element.second = anonymizer_.Anonymize(element.second); +} + } // namespace system_logs diff --git a/chrome/browser/feedback/system_logs/scrubbed_system_logs_fetcher.h b/chrome/browser/feedback/system_logs/scrubbed_system_logs_fetcher.h index 40229f2..fdf23be 100644 --- a/chrome/browser/feedback/system_logs/scrubbed_system_logs_fetcher.h +++ b/chrome/browser/feedback/system_logs/scrubbed_system_logs_fetcher.h @@ -7,6 +7,7 @@ #include "base/macros.h" #include "chrome/browser/feedback/system_logs/system_logs_fetcher_base.h" +#include "components/feedback/anonymizer_tool.h" namespace system_logs { @@ -17,9 +18,14 @@ namespace system_logs { class ScrubbedSystemLogsFetcher : public SystemLogsFetcherBase { public: ScrubbedSystemLogsFetcher(); - ~ScrubbedSystemLogsFetcher(); + ~ScrubbedSystemLogsFetcher() override; + + protected: + void Rewrite(const std::string& source_name, + SystemLogsResponse* response) override; private: + feedback::AnonymizerTool anonymizer_; DISALLOW_COPY_AND_ASSIGN(ScrubbedSystemLogsFetcher); }; diff --git a/chrome/browser/feedback/system_logs/system_logs_fetcher_base.cc b/chrome/browser/feedback/system_logs/system_logs_fetcher_base.cc index 9c7ff09..7f90985 100644 --- a/chrome/browser/feedback/system_logs/system_logs_fetcher_base.cc +++ b/chrome/browser/feedback/system_logs/system_logs_fetcher_base.cc @@ -36,18 +36,29 @@ void SystemLogsFetcherBase::Fetch(const SysLogsFetcherCallback& callback) { callback_ = callback; for (size_t i = 0; i < data_sources_.size(); ++i) { VLOG(1) << "Fetching SystemLogSource: " << data_sources_[i]->source_name(); - data_sources_[i]->Fetch(base::Bind(&SystemLogsFetcherBase::AddResponse, + data_sources_[i]->Fetch(base::Bind(&SystemLogsFetcherBase::OnFetched, AsWeakPtr(), data_sources_[i]->source_name())); } } -void SystemLogsFetcherBase::AddResponse(const std::string& source_name, - SystemLogsResponse* response) { +void SystemLogsFetcherBase::OnFetched(const std::string& source_name, + SystemLogsResponse* response) { DCHECK_CURRENTLY_ON(BrowserThread::UI); VLOG(1) << "Received SystemLogSource: " << source_name; + Rewrite(source_name, response); + AddResponse(source_name, response); +} + +void SystemLogsFetcherBase::Rewrite(const std::string& /* source_name */, + SystemLogsResponse* /* response */) { + // This implementation in the base class is intentionally empty. +} + +void SystemLogsFetcherBase::AddResponse(const std::string& source_name, + SystemLogsResponse* response) { for (SystemLogsResponse::const_iterator it = response->begin(); it != response->end(); ++it) { diff --git a/chrome/browser/feedback/system_logs/system_logs_fetcher_base.h b/chrome/browser/feedback/system_logs/system_logs_fetcher_base.h index 5f881e6..29a20ab 100644 --- a/chrome/browser/feedback/system_logs/system_logs_fetcher_base.h +++ b/chrome/browser/feedback/system_logs/system_logs_fetcher_base.h @@ -63,15 +63,22 @@ class SystemLogsFetcherBase : public base::SupportsWeakPtr<SystemLogsFetcherBase> { public: SystemLogsFetcherBase(); - ~SystemLogsFetcherBase(); + virtual ~SystemLogsFetcherBase(); void Fetch(const SysLogsFetcherCallback& callback); protected: - // Callback passed to all the data sources. It merges the |data| it receives - // into response_. When all the data sources have responded, it deletes their - // objects and returns the response to the callback_. After this it - // deletes this instance of the object. + // Callback passed to all the data sources. Calls Rewrite() and AddResponse(). + void OnFetched(const std::string& source_name, SystemLogsResponse* response); + + // Virtual function that allows derived classes to modify the response before + // it gets added to the output. + virtual void Rewrite(const std::string& source_name, + SystemLogsResponse* response); + + // Merges the |data| it receives into response_. When all the data sources + // have responded, it deletes their objects and returns the response to the + // callback_. After this it deletes this instance of the object. void AddResponse(const std::string& source_name, SystemLogsResponse* response); |