| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "ios/chrome/app/application_delegate/memory_warning_helper.h" | 5 #import "ios/chrome/app/application_delegate/memory_warning_helper.h" |
| 6 | 6 |
| 7 #include "base/memory/memory_pressure_listener.h" | 7 #include "base/memory/memory_pressure_listener.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "ios/chrome/browser/crash_report/breakpad_helper.h" | 9 #include "ios/chrome/browser/crash_report/breakpad_helper.h" |
| 10 #import "ios/chrome/browser/metrics/previous_session_info.h" | 10 #import "ios/chrome/browser/metrics/previous_session_info.h" |
| 11 | 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 13 #error "This file requires ARC support." | |
| 14 #endif | |
| 15 | |
| 16 namespace { | 12 namespace { |
| 17 // The number of seconds to wait after a memory warning to clear the flag used | 13 // The number of seconds to wait after a memory warning to clear the flag used |
| 18 // to detect Out Of Memory crashes. | 14 // to detect Out Of Memory crashes. |
| 19 // NOTE: From local tests on various devices, this interval ranges between 1 and | 15 // NOTE: From local tests on various devices, this interval ranges between 1 and |
| 20 // 3 seconds. It is set to 5 to ensure all out of memory crashes are identified, | 16 // 3 seconds. It is set to 5 to ensure all out of memory crashes are identified, |
| 21 // even if this may lead to overcounting them. | 17 // even if this may lead to overcounting them. |
| 22 const CFTimeInterval kOutOfMemoryResetTimeInterval = 5; | 18 const CFTimeInterval kOutOfMemoryResetTimeInterval = 5; |
| 23 } | 19 } |
| 24 | 20 |
| 25 @interface MemoryWarningHelper () { | 21 @interface MemoryWarningHelper () { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 [[PreviousSessionInfo sharedInstance] resetMemoryWarningFlag]; | 60 [[PreviousSessionInfo sharedInstance] resetMemoryWarningFlag]; |
| 65 breakpad_helper::SetMemoryWarningInProgress(false); | 61 breakpad_helper::SetMemoryWarningInProgress(false); |
| 66 } | 62 } |
| 67 | 63 |
| 68 - (void)resetForegroundMemoryWarningCount { | 64 - (void)resetForegroundMemoryWarningCount { |
| 69 _foregroundMemoryWarningCount = 0; | 65 _foregroundMemoryWarningCount = 0; |
| 70 breakpad_helper::SetMemoryWarningCount(0); | 66 breakpad_helper::SetMemoryWarningCount(0); |
| 71 } | 67 } |
| 72 | 68 |
| 73 @end | 69 @end |
| OLD | NEW |