Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 const base::Feature kFeature = { | |
|
Alexei Svitkine (slow)
2016/06/03 15:48:33
kFeature is not very informative.
How about kRepo
Will Harris
2016/06/03 20:51:30
Done.
| |
| 30 "ReportFullAVProductDetails", base::FEATURE_DISABLED_BY_DEFAULT}; | |
| 31 | |
| 32 explicit AntiVirusMetricsProvider( | |
| 33 scoped_refptr<base::SequencedTaskRunner> file_thread); | |
| 34 | |
| 35 ~AntiVirusMetricsProvider() override; | |
| 36 | |
| 37 // metrics::MetricsDataProvider: | |
| 38 void ProvideSystemProfileMetrics( | |
| 39 metrics::SystemProfileProto* system_profile_proto) override; | |
| 40 | |
| 41 // Called to gather metrics, before calling ProvideSystemProfileMetrics. | |
|
Alexei Svitkine (slow)
2016/06/03 15:48:33
Nit: This comment explains how its used, but how i
Will Harris
2016/06/03 20:51:30
I chose bad files to copy comments from :)
Done.
| |
| 42 void GetAntiVirusMetrics(const base::Closure& done_callback); | |
| 43 | |
| 44 private: | |
| 45 // This enum is reported via a histogram so new values should always be added | |
| 46 // at the end. | |
| 47 enum ResultCode { | |
| 48 RESULT_SUCCESS = 0, | |
| 49 RESULT_GENERIC_FAILURE = 1, | |
| 50 RESULT_FAILED_TO_INITIALIZE_COM = 2, | |
| 51 RESULT_FAILED_TO_CREATE_INSTANCE = 3, | |
| 52 RESULT_FAILED_TO_INITIALIZE_PRODUCT_LIST = 4, | |
| 53 RESULT_FAILED_TO_GET_PRODUCT_COUNT = 5, | |
| 54 RESULT_FAILED_TO_GET_ITEM = 6, | |
| 55 RESULT_FAILED_TO_GET_PRODUCT_STATE = 7, | |
| 56 RESULT_PRODUCT_STATE_INVALID = 8, | |
| 57 RESULT_FAILED_TO_GET_PRODUCT_NAME = 9, | |
| 58 RESULT_FAILED_TO_GET_REMEDIATION_PATH = 10, | |
| 59 RESULT_COUNT = 11 | |
| 60 }; | |
| 61 | |
| 62 typedef metrics::SystemProfileProto::AntiVirusProduct AvProduct; | |
| 63 typedef std::vector<AvProduct> AvProductList; | |
|
Alexei Svitkine (slow)
2016/06/03 15:48:33
Nit: I don't think having this typedef is very use
Will Harris
2016/06/03 20:51:30
Done.
| |
| 64 | |
| 65 static ResultCode FillAntiVirusProducts(AvProductList* products); | |
| 66 static AvProductList GetAntiVirusProductsOnFileThread(); | |
| 67 | |
| 68 // Called when metrics are done being gathered from the FILE thread. | |
| 69 // |done_callback| is the callback that should be called once all metrics are | |
| 70 // gathered. | |
| 71 void GotAntiVirusProducts(const base::Closure& done_callback, | |
| 72 const AvProductList& av_products); | |
| 73 | |
| 74 // The thread on which file operations are performed (supplied by the | |
| 75 // embedder). | |
| 76 scoped_refptr<base::SequencedTaskRunner> file_thread_; | |
| 77 | |
| 78 // Information on installed AntiVirus gathered. | |
| 79 AvProductList av_products_; | |
| 80 | |
| 81 base::ThreadChecker thread_checker_; | |
| 82 base::WeakPtrFactory<AntiVirusMetricsProvider> weak_ptr_factory_; | |
| 83 | |
| 84 DISALLOW_COPY_AND_ASSIGN(AntiVirusMetricsProvider); | |
| 85 }; | |
| 86 | |
| 87 #endif // CHROME_BROWSER_METRICS_ANTIVIRUS_METRICS_PROVIDER_WIN_H_ | |
| OLD | NEW |