| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 IOS_CHROME_BROWSER_CRASH_LOOP_DETECTION_UTIL_H_ | 5 #ifndef IOS_CHROME_BROWSER_CRASH_LOOP_DETECTION_UTIL_H_ |
| 6 #define IOS_CHROME_BROWSER_CRASH_LOOP_DETECTION_UTIL_H_ | 6 #define IOS_CHROME_BROWSER_CRASH_LOOP_DETECTION_UTIL_H_ |
| 7 | 7 |
| 8 namespace crash_util { | 8 namespace crash_util { |
| 9 | 9 |
| 10 // Returns the number of consecutive failed startups ('instant' crashes) prior | 10 // Returns the number of consecutive failed startups ('instant' crashes) prior |
| 11 // to this one. This method always returns the number of prior failures even | 11 // to this one. This method always returns the number of prior failures even |
| 12 // after calls to increment or reset the value. | 12 // after calls to increment or reset the value. |
| 13 int GetFailedStartupAttemptCount(); | 13 int GetFailedStartupAttemptCount(); |
| 14 | 14 |
| 15 // Increases the failed startup count. This should be called immediately after | 15 // Increases the failed startup count. This should be called immediately after |
| 16 // startup, so that if there is a crash, it is recorded. | 16 // startup, so that if there is a crash, it is recorded. |
| 17 // If |flush_immediately| is true, the value will be persisted immediately. If | 17 // If |flush_immediately| is true, the value will be persisted immediately. If |
| 18 // |flush_immediately| is false, this should be followed by a call to | 18 // |flush_immediately| is false, this should be followed by a call to |
| 19 // [[NSUserDefaults standardUserDefaults] synchronize]. This is optional to | 19 // [[NSUserDefaults standardUserDefaults] synchronize]. This is optional to |
| 20 // allow coallescing of the potentially expensive call during startup. | 20 // allow coallescing of the potentially expensive call during startup. |
| 21 void IncrementFailedStartupAttemptCount(bool flush_immediately); | 21 void IncrementFailedStartupAttemptCount(bool flush_immediately); |
| 22 | 22 |
| 23 // Resets the failed startup count. This should be called once there is some | 23 // Resets the failed startup count. This should be called once there is some |
| 24 // indication the user isn't in a crash loop (e.g., some amount of time has | 24 // indication the user isn't in a crash loop (e.g., some amount of time has |
| 25 // elapsed, or some deliberate user action has been taken). | 25 // elapsed, or some deliberate user action has been taken). |
| 26 void ResetFailedStartupAttemptCount(); | 26 void ResetFailedStartupAttemptCount(); |
| 27 | 27 |
| 28 // Resets the hidden state of failed startup attempt count for testing. |
| 29 void ResetFailedStartupAttemptCountForTests(); |
| 30 |
| 28 } // namespace crash_util | 31 } // namespace crash_util |
| 29 | 32 |
| 30 #endif // IOS_CHROME_BROWSER_CRASH_LOOP_DETECTION_UTIL_H_ | 33 #endif // IOS_CHROME_BROWSER_CRASH_LOOP_DETECTION_UTIL_H_ |
| OLD | NEW |