Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Unified Diff: chrome/browser/metrics/antivirus_metrics_provider_win.h

Issue 2009773007: Add AntiVirus information to the system profile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hash the product name and version Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..86011e06269533bd9e4627da21af1fcd20831d40
--- /dev/null
+++ b/chrome/browser/metrics/antivirus_metrics_provider_win.h
@@ -0,0 +1,76 @@
+// 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>
Alexei Svitkine (slow) 2016/06/01 20:42:35 Nit: No blank lines between the different system h
Will Harris 2016/06/02 20:36:27 Done.
+
+#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"
+
+namespace metrics {
+
+// AntiVirusMetricsProvider is responsible for adding antivirus information to
+// the UMA system profile proto.
+class AntiVirusMetricsProvider : public metrics::MetricsProvider {
+ public:
+ explicit AntiVirusMetricsProvider(
+ scoped_refptr<base::SequencedTaskRunner> file_thread);
+ ~AntiVirusMetricsProvider() override;
+
+ // 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 {
+ 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();
+
+ // 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);
+};
+
+} // namespace metrics
+
+#endif // CHROME_BROWSER_METRICS_ANTIVIRUS_METRICS_PROVIDER_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698