OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/profile_resetter/triggered_profile_resetter.h" | 5 #include "chrome/browser/profile_resetter/triggered_profile_resetter.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 reset_reg_key.ReadInt64(kTriggeredResetTimestamp, ×tamp) != | 53 reset_reg_key.ReadInt64(kTriggeredResetTimestamp, ×tamp) != |
54 ERROR_SUCCESS) { | 54 ERROR_SUCCESS) { |
55 UMA_HISTOGRAM_BOOLEAN("Profile.TriggeredReset", false); | 55 UMA_HISTOGRAM_BOOLEAN("Profile.TriggeredReset", false); |
56 return; | 56 return; |
57 } | 57 } |
58 | 58 |
59 // A reset trigger time was found. Compare it to the trigger time stored | 59 // A reset trigger time was found. Compare it to the trigger time stored |
60 // in this profile. If different, reset the profile and persist the new | 60 // in this profile. If different, reset the profile and persist the new |
61 // time. | 61 // time. |
62 PrefService* pref_service = profile_->GetPrefs(); | 62 PrefService* pref_service = profile_->GetPrefs(); |
63 const int64 preference_timestamp = | 63 const int64_t preference_timestamp = |
64 pref_service->GetInt64(prefs::kLastProfileResetTimestamp); | 64 pref_service->GetInt64(prefs::kLastProfileResetTimestamp); |
65 | 65 |
66 if (profile_->IsNewProfile()) { | 66 if (profile_->IsNewProfile()) { |
67 // New profiles should never be reset. Instead, persist the time stamp | 67 // New profiles should never be reset. Instead, persist the time stamp |
68 // directly. | 68 // directly. |
69 pref_service->SetInt64(prefs::kLastProfileResetTimestamp, timestamp); | 69 pref_service->SetInt64(prefs::kLastProfileResetTimestamp, timestamp); |
70 } else if (timestamp != preference_timestamp) { | 70 } else if (timestamp != preference_timestamp) { |
71 DVLOG(1) << "Profile reset detected."; | 71 DVLOG(1) << "Profile reset detected."; |
72 | 72 |
73 has_reset_trigger_ = true; | 73 has_reset_trigger_ = true; |
74 | 74 |
75 if (reset_reg_key.ReadValue(kTriggeredResetToolName, &tool_name_) != | 75 if (reset_reg_key.ReadValue(kTriggeredResetToolName, &tool_name_) != |
76 ERROR_SUCCESS) { | 76 ERROR_SUCCESS) { |
77 DVLOG(1) << "Failed to read triggered profile reset tool name."; | 77 DVLOG(1) << "Failed to read triggered profile reset tool name."; |
78 } else if (tool_name_.length() > kMaxToolNameLength) { | 78 } else if (tool_name_.length() > kMaxToolNameLength) { |
79 tool_name_.resize(kMaxToolNameLength); | 79 tool_name_.resize(kMaxToolNameLength); |
80 } | 80 } |
81 | 81 |
82 pref_service->SetInt64(prefs::kLastProfileResetTimestamp, timestamp); | 82 pref_service->SetInt64(prefs::kLastProfileResetTimestamp, timestamp); |
83 } | 83 } |
84 | 84 |
85 UMA_HISTOGRAM_BOOLEAN("Profile.TriggeredReset", has_reset_trigger_); | 85 UMA_HISTOGRAM_BOOLEAN("Profile.TriggeredReset", has_reset_trigger_); |
86 } | 86 } |
OLD | NEW |