| 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 #include "components/metrics/cloned_install_detector.h" | 5 #include "components/metrics/cloned_install_detector.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 base::PostTaskAndReplyWithResult( | 58 base::PostTaskAndReplyWithResult( |
| 59 task_runner.get(), | 59 task_runner.get(), |
| 60 FROM_HERE, | 60 FROM_HERE, |
| 61 base::Bind(&MachineIdProvider::GetMachineId, raw_id_provider_), | 61 base::Bind(&MachineIdProvider::GetMachineId, raw_id_provider_), |
| 62 base::Bind(&ClonedInstallDetector::SaveMachineId, | 62 base::Bind(&ClonedInstallDetector::SaveMachineId, |
| 63 weak_ptr_factory_.GetWeakPtr(), | 63 weak_ptr_factory_.GetWeakPtr(), |
| 64 local_state)); | 64 local_state)); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void ClonedInstallDetector::SaveMachineId(PrefService* local_state, | 67 void ClonedInstallDetector::SaveMachineId(PrefService* local_state, |
| 68 std::string raw_id) { | 68 const std::string& raw_id) { |
| 69 if (raw_id.empty()) { | 69 if (raw_id.empty()) { |
| 70 LogMachineIdState(ID_GENERATION_FAILED); | 70 LogMachineIdState(ID_GENERATION_FAILED); |
| 71 local_state->ClearPref(prefs::kMetricsMachineId); | 71 local_state->ClearPref(prefs::kMetricsMachineId); |
| 72 return; | 72 return; |
| 73 } | 73 } |
| 74 | 74 |
| 75 int hashed_id = HashRawId(raw_id); | 75 int hashed_id = HashRawId(raw_id); |
| 76 | 76 |
| 77 MachineIdState id_state = ID_NO_STORED_VALUE; | 77 MachineIdState id_state = ID_NO_STORED_VALUE; |
| 78 if (local_state->HasPrefPath(prefs::kMetricsMachineId)) { | 78 if (local_state->HasPrefPath(prefs::kMetricsMachineId)) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 90 | 90 |
| 91 local_state->SetInteger(prefs::kMetricsMachineId, hashed_id); | 91 local_state->SetInteger(prefs::kMetricsMachineId, hashed_id); |
| 92 } | 92 } |
| 93 | 93 |
| 94 // static | 94 // static |
| 95 void ClonedInstallDetector::RegisterPrefs(PrefRegistrySimple* registry) { | 95 void ClonedInstallDetector::RegisterPrefs(PrefRegistrySimple* registry) { |
| 96 registry->RegisterIntegerPref(prefs::kMetricsMachineId, 0); | 96 registry->RegisterIntegerPref(prefs::kMetricsMachineId, 0); |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace metrics | 99 } // namespace metrics |
| OLD | NEW |