Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / metrics / cloned_install_detector.h
blobced164db90a5b212c387ecaf366f0b5b250a8897
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.
5 #ifndef CHROME_BROWSER_METRICS_CLONED_INSTALL_DETECTOR_H_
6 #define CHROME_BROWSER_METRICS_CLONED_INSTALL_DETECTOR_H_
8 #include "base/gtest_prod_util.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
12 class PrefRegistrySimple;
13 class PrefService;
15 namespace metrics {
17 class MachineIdProvider;
19 // A class for detecting if an install is cloned. It does this by detecting
20 // when the hardware running Chrome changes.
21 class ClonedInstallDetector {
22 public:
23 explicit ClonedInstallDetector(MachineIdProvider* raw_id_provider);
24 virtual ~ClonedInstallDetector();
26 // Posts a task to generate a machine ID and store it to a local state pref.
27 // If the newly generated ID is different than the previously stored one, then
28 // the install is considered cloned. The ID is a 24-bit value based off of
29 // machine characteristics. This value should never be sent over the network.
30 // TODO(jwd): Implement change detection.
31 void CheckForClonedInstall(PrefService* local_state);
33 static void RegisterPrefs(PrefRegistrySimple* registry);
35 private:
36 FRIEND_TEST_ALL_PREFIXES(ClonedInstallDetectorTest, SaveId);
37 FRIEND_TEST_ALL_PREFIXES(ClonedInstallDetectorTest, DetectClone);
39 // Converts raw_id into a 24-bit hash and stores the hash in |local_state|.
40 // |raw_id| is not a const ref because it's passed from a cross-thread post
41 // task.
42 void SaveMachineId(PrefService* local_state, std::string raw_id);
44 scoped_refptr<MachineIdProvider> raw_id_provider_;
45 base::WeakPtrFactory<ClonedInstallDetector> weak_ptr_factory_;
47 DISALLOW_COPY_AND_ASSIGN(ClonedInstallDetector);
50 } // namespace metrics
52 #endif // CHROME_BROWSER_METRICS_CLONED_INSTALL_DETECTOR_H_