Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(654)

Side by Side Diff: chrome/browser/metrics/extension_metrics.h

Issue 297483008: Refactor HashedExtensionMetrics into ExtensionsMetricsProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_METRICS_EXTENSION_METRICS_H_
6 #define CHROME_BROWSER_METRICS_EXTENSION_METRICS_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12
13 class Profile;
14
15 namespace extensions {
16 class ExtensionSet;
17 }
18
19 namespace metrics {
20 class SystemProfileProto;
21 }
22
23 // HashedExtensionMetrics groups various constants and functions used for
24 // reporting extension IDs with UMA reports (after hashing the extension IDs
25 // for privacy).
26 class HashedExtensionMetrics {
27 public:
28 explicit HashedExtensionMetrics(uint64 client_id);
29 virtual ~HashedExtensionMetrics();
30
31 // Writes the hashed list of installed extensions into the specified
32 // SystemProfileProto object.
33 void WriteExtensionList(metrics::SystemProfileProto* system_profile);
34
35 protected:
36 // Retrieves the set of extensions installed in the current profile. The
37 // default implementation should be fine, but this can be overridden for
38 // testing.
39 //
40 // TODO(mvrable): If metrics are ever converted to being per-profile, then
41 // this should be updated to return extensions installed in a specified
42 // profile.
43 virtual scoped_ptr<extensions::ExtensionSet> GetInstalledExtensions();
44
45 // Hashes the extension extension ID using the provided client key (which
46 // must be less than kExtensionListClientKeys) and to produce an output value
47 // between 0 and kExtensionListBuckets-1.
48 static int HashExtension(const std::string& extension_id, uint32 client_key);
49
50 private:
51 // Returns the profile for which extensions will be gathered. Once a
52 // suitable profile has been found, future calls will continue to return the
53 // same value so that reported extensions are consistent.
54 Profile* GetMetricsProfile();
55
56 // The key used when hashing extension identifiers, derived from client_id.
57 const int client_key_;
58
59 // The profile for which extensions are gathered. Once a profile is found
60 // its value is cached here so that GetMetricsProfile() can return a
61 // consistent value.
62 Profile* cached_profile_;
63
64 DISALLOW_COPY_AND_ASSIGN(HashedExtensionMetrics);
65 };
66
67 #endif // CHROME_BROWSER_METRICS_EXTENSION_METRICS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/extension_metrics.cc » ('j') | chrome/browser/metrics/extensions_metrics_provider.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698