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