| 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 17 matching lines...) Expand all Loading... |
| 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: | 36 // metrics::MetricsProvider: |
| 37 | 37 |
| 38 // Writes the hashed list of installed extensions into the specified | |
| 39 // SystemProfileProto object. | |
| 40 virtual void ProvideSystemProfileMetrics( | 38 virtual void ProvideSystemProfileMetrics( |
| 41 metrics::SystemProfileProto* system_profile) OVERRIDE; | 39 metrics::SystemProfileProto* system_profile) OVERRIDE; |
| 42 | 40 |
| 43 protected: | 41 protected: |
| 44 // Exposed for the sake of mocking in test code. | 42 // Exposed for the sake of mocking in test code. |
| 45 | 43 |
| 46 // Retrieves the set of extensions installed in the current profile. | 44 // Retrieves the set of extensions installed in the current profile. |
| 47 // TODO(mvrable): If metrics are ever converted to being per-profile, then | 45 // TODO(mvrable): If metrics are ever converted to being per-profile, then |
| 48 // this should be updated to return extensions installed in a specified | 46 // this should be updated to return extensions installed in a specified |
| 49 // profile. | 47 // profile. |
| 50 virtual scoped_ptr<extensions::ExtensionSet> GetInstalledExtensions(); | 48 virtual scoped_ptr<extensions::ExtensionSet> GetInstalledExtensions( |
| 49 Profile* profile); |
| 51 | 50 |
| 52 // Retrieves the client ID. | 51 // Retrieves the client ID. |
| 53 virtual uint64 GetClientID(); | 52 virtual uint64 GetClientID(); |
| 54 | 53 |
| 55 // Hashes the extension extension ID using the provided client key (which | 54 // Hashes the extension extension ID using the provided client key (which |
| 56 // must be less than kExtensionListClientKeys) and to produce an output value | 55 // must be less than kExtensionListClientKeys) and to produce an output value |
| 57 // between 0 and kExtensionListBuckets-1. | 56 // between 0 and kExtensionListBuckets-1. |
| 58 static int HashExtension(const std::string& extension_id, uint32 client_key); | 57 static int HashExtension(const std::string& extension_id, uint32 client_key); |
| 59 | 58 |
| 60 private: | 59 private: |
| 61 // Returns the profile for which extensions will be gathered. Once a | 60 // Returns the profile for which extensions will be gathered. Once a |
| 62 // suitable profile has been found, future calls will continue to return the | 61 // suitable profile has been found, future calls will continue to return the |
| 63 // same value so that reported extensions are consistent. | 62 // same value so that reported extensions are consistent. |
| 64 Profile* GetMetricsProfile(); | 63 Profile* GetMetricsProfile(); |
| 65 | 64 |
| 65 // Writes whether any loaded profiles have extensions not from the webstore. |
| 66 void ProvideOffStoreMetric(metrics::SystemProfileProto* system_profile); |
| 67 |
| 68 // Writes the hashed list of installed extensions into the specified |
| 69 // SystemProfileProto object. |
| 70 void ProvideOccupiedBucketMetric(metrics::SystemProfileProto* system_profile); |
| 71 |
| 66 // The MetricsStateManager from which the client ID is obtained. | 72 // The MetricsStateManager from which the client ID is obtained. |
| 67 metrics::MetricsStateManager* metrics_state_manager_; | 73 metrics::MetricsStateManager* metrics_state_manager_; |
| 68 | 74 |
| 69 // The profile for which extensions are gathered. Once a profile is found | 75 // The profile for which extensions are gathered for the occupied bucket |
| 70 // its value is cached here so that GetMetricsProfile() can return a | 76 // metric. Once a profile is found its value is cached here so that |
| 71 // consistent value. | 77 // GetMetricsProfile() can return a consistent value. |
| 72 Profile* cached_profile_; | 78 Profile* cached_profile_; |
| 73 | 79 |
| 74 DISALLOW_COPY_AND_ASSIGN(ExtensionsMetricsProvider); | 80 DISALLOW_COPY_AND_ASSIGN(ExtensionsMetricsProvider); |
| 75 }; | 81 }; |
| 76 | 82 |
| 77 #endif // CHROME_BROWSER_METRICS_EXTENSIONS_METRICS_PROVIDER_H_ | 83 #endif // CHROME_BROWSER_METRICS_EXTENSIONS_METRICS_PROVIDER_H_ |
| OLD | NEW |