Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_METRICS_EXTENSIONS_METRICS_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_METRICS_EXTENSIONS_METRICS_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_METRICS_EXTENSIONS_METRICS_PROVIDER_H_ | 6 #define CHROME_BROWSER_METRICS_EXTENSIONS_METRICS_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 // reporting extension IDs with UMA reports (after hashing the extension IDs | 26 // reporting extension IDs with UMA reports (after hashing the extension IDs |
| 27 // for privacy). | 27 // for privacy). |
| 28 class ExtensionsMetricsProvider : public metrics::MetricsProvider { | 28 class ExtensionsMetricsProvider : public metrics::MetricsProvider { |
| 29 public: | 29 public: |
| 30 // Holds on to |metrics_state_manager|, which must outlive this object, as a | 30 // Holds on to |metrics_state_manager|, which must outlive this object, as a |
| 31 // weak pointer. | 31 // weak pointer. |
| 32 explicit ExtensionsMetricsProvider( | 32 explicit ExtensionsMetricsProvider( |
| 33 metrics::MetricsStateManager* metrics_state_manager); | 33 metrics::MetricsStateManager* metrics_state_manager); |
| 34 virtual ~ExtensionsMetricsProvider(); | 34 virtual ~ExtensionsMetricsProvider(); |
| 35 | 35 |
| 36 // metrics::MetricsProvider: | |
| 37 | |
| 38 // Writes the hashed list of installed extensions into the specified | |
| 39 // SystemProfileProto object. | |
| 40 virtual void ProvideSystemProfileMetrics( | 36 virtual void ProvideSystemProfileMetrics( |
|
Alexei Svitkine (slow)
2014/08/13 19:38:10
Nit: Keep the comment (without any blank line righ
jwd
2014/08/13 20:22:07
Done.
| |
| 41 metrics::SystemProfileProto* system_profile) OVERRIDE; | 37 metrics::SystemProfileProto* system_profile) OVERRIDE; |
| 42 | 38 |
| 43 protected: | 39 protected: |
| 44 // Exposed for the sake of mocking in test code. | 40 // Exposed for the sake of mocking in test code. |
| 45 | 41 |
| 46 // Retrieves the set of extensions installed in the current profile. | 42 // Retrieves the set of extensions installed in the current profile. |
|
Devlin
2014/08/13 19:50:07
nit: update comment to say "in the given |profile|
jwd
2014/08/13 20:22:06
Done.
| |
| 47 // TODO(mvrable): If metrics are ever converted to being per-profile, then | 43 // TODO(mvrable): If metrics are ever converted to being per-profile, then |
|
Devlin
2014/08/13 19:50:07
Can we take out the TODO? Or update it? (We *are
jwd
2014/08/13 20:22:06
Done.
| |
| 48 // this should be updated to return extensions installed in a specified | 44 // this should be updated to return extensions installed in a specified |
| 49 // profile. | 45 // profile. |
| 50 virtual scoped_ptr<extensions::ExtensionSet> GetInstalledExtensions(); | 46 virtual scoped_ptr<extensions::ExtensionSet> GetInstalledExtensions( |
| 47 Profile* profile); | |
| 51 | 48 |
| 52 // Retrieves the client ID. | 49 // Retrieves the client ID. |
| 53 virtual uint64 GetClientID(); | 50 virtual uint64 GetClientID(); |
| 54 | 51 |
| 55 // Hashes the extension extension ID using the provided client key (which | 52 // Hashes the extension extension ID using the provided client key (which |
| 56 // must be less than kExtensionListClientKeys) and to produce an output value | 53 // must be less than kExtensionListClientKeys) and to produce an output value |
| 57 // between 0 and kExtensionListBuckets-1. | 54 // between 0 and kExtensionListBuckets-1. |
| 58 static int HashExtension(const std::string& extension_id, uint32 client_key); | 55 static int HashExtension(const std::string& extension_id, uint32 client_key); |
| 59 | 56 |
| 60 private: | 57 private: |
| 61 // Returns the profile for which extensions will be gathered. Once a | 58 // Returns the profile for which extensions will be gathered. Once a |
| 62 // suitable profile has been found, future calls will continue to return the | 59 // suitable profile has been found, future calls will continue to return the |
| 63 // same value so that reported extensions are consistent. | 60 // same value so that reported extensions are consistent. |
| 64 Profile* GetMetricsProfile(); | 61 Profile* GetMetricsProfile(); |
| 65 | 62 |
| 63 // Writes whether any loaded profiles have extensions not from the webstore. | |
| 64 void ProvideOffStoreMetric(metrics::SystemProfileProto* system_profile); | |
| 65 | |
| 66 // Writes the hashed list of installed extensions into the specified | |
| 67 // SystemProfileProto object. | |
| 68 void ProvideOccupiedBucketMetric(metrics::SystemProfileProto* system_profile); | |
| 69 | |
| 66 // The MetricsStateManager from which the client ID is obtained. | 70 // The MetricsStateManager from which the client ID is obtained. |
| 67 metrics::MetricsStateManager* metrics_state_manager_; | 71 metrics::MetricsStateManager* metrics_state_manager_; |
| 68 | 72 |
| 69 // The profile for which extensions are gathered. Once a profile is found | 73 // The profile for which extensions are gathered for the occupied bucket |
| 70 // its value is cached here so that GetMetricsProfile() can return a | 74 // metric. Once a profile is found its value is cached here so that |
| 71 // consistent value. | 75 // GetMetricsProfile() can return a consistent value. |
| 72 Profile* cached_profile_; | 76 Profile* cached_profile_; |
| 73 | 77 |
| 74 DISALLOW_COPY_AND_ASSIGN(ExtensionsMetricsProvider); | 78 DISALLOW_COPY_AND_ASSIGN(ExtensionsMetricsProvider); |
| 75 }; | 79 }; |
| 76 | 80 |
| 77 #endif // CHROME_BROWSER_METRICS_EXTENSIONS_METRICS_PROVIDER_H_ | 81 #endif // CHROME_BROWSER_METRICS_EXTENSIONS_METRICS_PROVIDER_H_ |
| OLD | NEW |