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

Side by Side Diff: chrome/browser/metrics/antivirus_metrics_provider_win.h

Issue 2136423003: Merge M52: Add AntiVirus information to the system profile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/metrics/antivirus_metrics_provider_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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_METRICS_ANTIVIRUS_METRICS_PROVIDER_WIN_H_
6 #define CHROME_BROWSER_METRICS_ANTIVIRUS_METRICS_PROVIDER_WIN_H_
7
8 #include "components/metrics/metrics_provider.h"
9
10 #include <iwscapi.h>
11 #include <stddef.h>
12
13 #include <string>
14 #include <vector>
15
16 #include "base/callback_forward.h"
17 #include "base/feature_list.h"
18 #include "base/gtest_prod_util.h"
19 #include "base/macros.h"
20 #include "base/memory/weak_ptr.h"
21 #include "base/sequenced_task_runner.h"
22 #include "base/threading/thread_checker.h"
23 #include "components/metrics/proto/system_profile.pb.h"
24
25 // AntiVirusMetricsProvider is responsible for adding antivirus information to
26 // the UMA system profile proto.
27 class AntiVirusMetricsProvider : public metrics::MetricsProvider {
28 public:
29 static constexpr base::Feature kReportNamesFeature = {
30 "ReportFullAVProductDetails", base::FEATURE_DISABLED_BY_DEFAULT};
31
32 explicit AntiVirusMetricsProvider(
33 scoped_refptr<base::TaskRunner> task_runner);
34
35 ~AntiVirusMetricsProvider() override;
36
37 // metrics::MetricsDataProvider:
38 void ProvideSystemProfileMetrics(
39 metrics::SystemProfileProto* system_profile_proto) override;
40
41 // Fetches AntiVirus data asynchronously and calls |done_callback| when
42 // done. Should be called before ProvideSystemProfileMetrics to ensure that
43 // data is ready to be collected.
44 void GetAntiVirusMetrics(const base::Closure& done_callback);
45
46 private:
47 // This enum is reported via a histogram so new values should always be added
48 // at the end.
49 enum ResultCode {
50 RESULT_SUCCESS = 0,
51 RESULT_GENERIC_FAILURE = 1,
52 RESULT_FAILED_TO_INITIALIZE_COM = 2,
53 RESULT_FAILED_TO_CREATE_INSTANCE = 3,
54 RESULT_FAILED_TO_INITIALIZE_PRODUCT_LIST = 4,
55 RESULT_FAILED_TO_GET_PRODUCT_COUNT = 5,
56 RESULT_FAILED_TO_GET_ITEM = 6,
57 RESULT_FAILED_TO_GET_PRODUCT_STATE = 7,
58 RESULT_PRODUCT_STATE_INVALID = 8,
59 RESULT_FAILED_TO_GET_PRODUCT_NAME = 9,
60 RESULT_FAILED_TO_GET_REMEDIATION_PATH = 10,
61 RESULT_FAILED_TO_CONNECT_TO_WMI = 11,
62 RESULT_FAILED_TO_SET_SECURITY_BLANKET = 12,
63 RESULT_FAILED_TO_EXEC_WMI_QUERY = 13,
64 RESULT_FAILED_TO_ITERATE_RESULTS = 14,
65 RESULT_WSC_NOT_AVAILABLE = 15,
66 RESULT_COUNT = 16
67 };
68
69 typedef metrics::SystemProfileProto::AntiVirusProduct AvProduct;
70
71 // Query COM interface IWSCProductList for installed AV products. This
72 // interface is only available on Windows 8 and above.
73 static ResultCode FillAntiVirusProductsFromWSC(
74 std::vector<AvProduct>* products);
75 // Query WMI ROOT\SecurityCenter2 for installed AV products. This interface is
76 // only available on Windows Vista and above.
77 static ResultCode FillAntiVirusProductsFromWMI(
78 std::vector<AvProduct>* products);
79 static std::vector<AvProduct> GetAntiVirusProductsOnFileThread();
80
81 // Called when metrics are done being gathered from the FILE thread.
82 // |done_callback| is the callback that should be called once all metrics are
83 // gathered.
84 void GotAntiVirusProducts(const base::Closure& done_callback,
85 const std::vector<AvProduct>& av_products);
86
87 // The TaskRunner on which file operations are performed (supplied by the
88 // embedder).
89 scoped_refptr<base::TaskRunner> task_runner_;
90
91 // Information on installed AntiVirus gathered.
92 std::vector<AvProduct> av_products_;
93
94 base::ThreadChecker thread_checker_;
95 base::WeakPtrFactory<AntiVirusMetricsProvider> weak_ptr_factory_;
96
97 FRIEND_TEST_ALL_PREFIXES(AntiVirusMetricsProviderTest, GetMetricsFullName);
98
99 DISALLOW_COPY_AND_ASSIGN(AntiVirusMetricsProvider);
100 };
101
102 #endif // CHROME_BROWSER_METRICS_ANTIVIRUS_METRICS_PROVIDER_WIN_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/antivirus_metrics_provider_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698