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 <stdint.h> |
| 9 |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/basictypes.h" | 12 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
12 #include "components/metrics/metrics_provider.h" | 14 #include "components/metrics/metrics_provider.h" |
13 | 15 |
14 class Profile; | 16 class Profile; |
15 | 17 |
16 namespace extensions { | 18 namespace extensions { |
17 class ExtensionSet; | 19 class ExtensionSet; |
18 } | 20 } |
19 | 21 |
20 namespace metrics { | 22 namespace metrics { |
(...skipping 17 matching lines...) Expand all Loading... |
38 metrics::SystemProfileProto* system_profile) override; | 40 metrics::SystemProfileProto* system_profile) override; |
39 | 41 |
40 protected: | 42 protected: |
41 // Exposed for the sake of mocking in test code. | 43 // Exposed for the sake of mocking in test code. |
42 | 44 |
43 // Retrieves the set of extensions installed in the given |profile|. | 45 // Retrieves the set of extensions installed in the given |profile|. |
44 virtual scoped_ptr<extensions::ExtensionSet> GetInstalledExtensions( | 46 virtual scoped_ptr<extensions::ExtensionSet> GetInstalledExtensions( |
45 Profile* profile); | 47 Profile* profile); |
46 | 48 |
47 // Retrieves the client ID. | 49 // Retrieves the client ID. |
48 virtual uint64 GetClientID(); | 50 virtual uint64_t GetClientID(); |
49 | 51 |
50 // Hashes the extension extension ID using the provided client key (which | 52 // Hashes the extension extension ID using the provided client key (which |
51 // must be less than kExtensionListClientKeys) and to produce an output value | 53 // must be less than kExtensionListClientKeys) and to produce an output value |
52 // between 0 and kExtensionListBuckets-1. | 54 // between 0 and kExtensionListBuckets-1. |
53 static int HashExtension(const std::string& extension_id, uint32 client_key); | 55 static int HashExtension(const std::string& extension_id, |
| 56 uint32_t client_key); |
54 | 57 |
55 private: | 58 private: |
56 // Returns the profile for which extensions will be gathered. Once a | 59 // Returns the profile for which extensions will be gathered. Once a |
57 // suitable profile has been found, future calls will continue to return the | 60 // suitable profile has been found, future calls will continue to return the |
58 // same value so that reported extensions are consistent. | 61 // same value so that reported extensions are consistent. |
59 Profile* GetMetricsProfile(); | 62 Profile* GetMetricsProfile(); |
60 | 63 |
61 // Writes whether any loaded profiles have extensions not from the webstore. | 64 // Writes whether any loaded profiles have extensions not from the webstore. |
62 void ProvideOffStoreMetric(metrics::SystemProfileProto* system_profile); | 65 void ProvideOffStoreMetric(metrics::SystemProfileProto* system_profile); |
63 | 66 |
64 // Writes the hashed list of installed extensions into the specified | 67 // Writes the hashed list of installed extensions into the specified |
65 // SystemProfileProto object. | 68 // SystemProfileProto object. |
66 void ProvideOccupiedBucketMetric(metrics::SystemProfileProto* system_profile); | 69 void ProvideOccupiedBucketMetric(metrics::SystemProfileProto* system_profile); |
67 | 70 |
68 // The MetricsStateManager from which the client ID is obtained. | 71 // The MetricsStateManager from which the client ID is obtained. |
69 metrics::MetricsStateManager* metrics_state_manager_; | 72 metrics::MetricsStateManager* metrics_state_manager_; |
70 | 73 |
71 // The profile for which extensions are gathered for the occupied bucket | 74 // The profile for which extensions are gathered for the occupied bucket |
72 // metric. Once a profile is found its value is cached here so that | 75 // metric. Once a profile is found its value is cached here so that |
73 // GetMetricsProfile() can return a consistent value. | 76 // GetMetricsProfile() can return a consistent value. |
74 Profile* cached_profile_; | 77 Profile* cached_profile_; |
75 | 78 |
76 DISALLOW_COPY_AND_ASSIGN(ExtensionsMetricsProvider); | 79 DISALLOW_COPY_AND_ASSIGN(ExtensionsMetricsProvider); |
77 }; | 80 }; |
78 | 81 |
79 #endif // CHROME_BROWSER_METRICS_EXTENSIONS_METRICS_PROVIDER_H_ | 82 #endif // CHROME_BROWSER_METRICS_EXTENSIONS_METRICS_PROVIDER_H_ |
OLD | NEW |