Chromium Code Reviews| Index: chrome/browser/metrics/antivirus_metrics_provider_win.h |
| diff --git a/chrome/browser/metrics/antivirus_metrics_provider_win.h b/chrome/browser/metrics/antivirus_metrics_provider_win.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..232e7fea00bbf279a41c87cabbb03d22f898d013 |
| --- /dev/null |
| +++ b/chrome/browser/metrics/antivirus_metrics_provider_win.h |
| @@ -0,0 +1,74 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_METRICS_ANTIVIRUS_METRICS_PROVIDER_WIN_H_ |
| +#define CHROME_BROWSER_METRICS_ANTIVIRUS_METRICS_PROVIDER_WIN_H_ |
| + |
| +#include "components/metrics/metrics_provider.h" |
| + |
| +#include <iwscapi.h> |
| +#include <stddef.h> |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/callback_forward.h" |
| +#include "base/gtest_prod_util.h" |
| +#include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/sequenced_task_runner.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "components/metrics/proto/system_profile.pb.h" |
| + |
| +// AntiVirusMetricsProvider is responsible for adding antivirus information to |
| +// the UMA system profile proto. |
| +class AntiVirusMetricsProvider : public metrics::MetricsProvider { |
| + public: |
| + static constexpr const char kReportFullAvProductDetailsName[] = |
| + "ReportFullAVProductDetails"; |
|
Alexei Svitkine (slow)
2016/06/02 21:46:57
Nit: Just declare the Feature here if you're expor
Will Harris
2016/06/02 23:57:17
Done.
|
| + |
| + explicit AntiVirusMetricsProvider( |
| + scoped_refptr<base::SequencedTaskRunner> file_thread); |
| + |
| + ~AntiVirusMetricsProvider() override; |
|
Alexei Svitkine (slow)
2016/06/02 21:46:57
Nit: Add an empty line below.
Will Harris
2016/06/02 23:57:17
Done.
|
| + // metrics::MetricsDataProvider: |
| + void ProvideSystemProfileMetrics( |
| + metrics::SystemProfileProto* system_profile_proto) override; |
| + |
| + // Called to gather metrics, before calling ProvideSystemProfileMetrics. |
| + void GetAntiVirusMetrics(const base::Closure& done_callback); |
| + |
| + private: |
| + struct AvProduct { |
| + metrics::SystemProfileProto::AntiVirusState product_state; |
| + std::wstring product_name; |
| + std::wstring product_version; |
| + }; |
| + typedef std::vector<AvProduct> AvProductList; |
| + |
| + static bool FillAntiVirusProducts(AvProductList* products); |
| + static AvProductList GetAntiVirusProductsOnFileThread(); |
|
Alexei Svitkine (slow)
2016/06/02 21:46:57
Nit: Can this be in the anon namespace instead?
Will Harris
2016/06/02 23:57:17
moving it to anonymous would mean I'd have to decl
|
| + |
| + // Called when metrics are done being gathered from the FILE thread. |
| + // |done_callback| is the callback that should be called once all metrics are |
| + // gathered. |
| + void GotAntiVirusProducts(const base::Closure& done_callback, |
| + const AvProductList& av_products); |
| + |
| + // The thread on which file operations are performed (supplied by the |
| + // embedder). |
| + scoped_refptr<base::SequencedTaskRunner> file_thread_; |
| + |
| + // Information on installed AntiVirus gathered. |
| + AvProductList av_products_; |
| + |
| + base::ThreadChecker thread_checker_; |
| + base::WeakPtrFactory<AntiVirusMetricsProvider> weak_ptr_factory_; |
| + |
| + FRIEND_TEST_ALL_PREFIXES(AntiVirusMetricsProviderTest, GetAvProducts); |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AntiVirusMetricsProvider); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_METRICS_ANTIVIRUS_METRICS_PROVIDER_WIN_H_ |