| Index: ios/chrome/browser/memory/memory_debugger.mm
|
| diff --git a/ios/chrome/browser/memory/memory_debugger.mm b/ios/chrome/browser/memory/memory_debugger.mm
|
| index 6d41fbe54034c476dd4a852e6d4e5fe394e62f19..35b880e054517319fc98dd082a76eab0c1adcbe6 100644
|
| --- a/ios/chrome/browser/memory/memory_debugger.mm
|
| +++ b/ios/chrome/browser/memory/memory_debugger.mm
|
| @@ -8,11 +8,14 @@
|
|
|
| #include <memory>
|
|
|
| -#import "base/mac/scoped_nsobject.h"
|
| #import "ios/chrome/browser/memory/memory_metrics.h"
|
| #include "ios/chrome/browser/ui/ui_util.h"
|
| #import "ios/chrome/browser/ui/uikit_ui_util.h"
|
|
|
| +#if !defined(__has_feature) || !__has_feature(objc_arc)
|
| +#error "This file requires ARC support."
|
| +#endif
|
| +
|
| namespace {
|
| // The number of bytes in a megabyte.
|
| const CGFloat kNumBytesInMB = 1024 * 1024;
|
| @@ -22,24 +25,24 @@ const CGFloat kPadding = 10;
|
|
|
| @implementation MemoryDebugger {
|
| // A timer to trigger refreshes.
|
| - base::scoped_nsobject<NSTimer> _refreshTimer;
|
| + NSTimer* _refreshTimer;
|
|
|
| // A timer to trigger continuous memory warnings.
|
| - base::scoped_nsobject<NSTimer> _memoryWarningTimer;
|
| + NSTimer* _memoryWarningTimer;
|
|
|
| // The font to use.
|
| - base::scoped_nsobject<UIFont> _font;
|
| + UIFont* _font;
|
|
|
| // Labels for memory metrics.
|
| - base::scoped_nsobject<UILabel> _physicalFreeMemoryLabel;
|
| - base::scoped_nsobject<UILabel> _realMemoryUsedLabel;
|
| - base::scoped_nsobject<UILabel> _xcodeGaugeLabel;
|
| - base::scoped_nsobject<UILabel> _dirtyVirtualMemoryLabel;
|
| + UILabel* _physicalFreeMemoryLabel;
|
| + UILabel* _realMemoryUsedLabel;
|
| + UILabel* _xcodeGaugeLabel;
|
| + UILabel* _dirtyVirtualMemoryLabel;
|
|
|
| // Inputs for memory commands.
|
| - base::scoped_nsobject<UITextField> _bloatField;
|
| - base::scoped_nsobject<UITextField> _refreshField;
|
| - base::scoped_nsobject<UITextField> _continuousMemoryWarningField;
|
| + UITextField* _bloatField;
|
| + UITextField* _refreshField;
|
| + UITextField* _continuousMemoryWarningField;
|
|
|
| // A place to store the artifical memory bloat.
|
| std::unique_ptr<uint8_t> _bloat;
|
| @@ -54,7 +57,7 @@ const CGFloat kPadding = 10;
|
| - (instancetype)init {
|
| self = [super initWithFrame:CGRectZero];
|
| if (self) {
|
| - _font.reset([[UIFont systemFontOfSize:14] retain]);
|
| + _font = [UIFont systemFontOfSize:14];
|
| self.backgroundColor = [UIColor colorWithWhite:0.8f alpha:0.9f];
|
| self.opaque = NO;
|
|
|
| @@ -74,7 +77,6 @@ const CGFloat kPadding = 10;
|
|
|
| - (void)dealloc {
|
| [[NSNotificationCenter defaultCenter] removeObserver:self];
|
| - [super dealloc];
|
| }
|
|
|
| #pragma mark UIView methods
|
| @@ -97,19 +99,19 @@ const CGFloat kPadding = 10;
|
| NSUInteger index = 0;
|
|
|
| // Display some metrics.
|
| - _physicalFreeMemoryLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]);
|
| + _physicalFreeMemoryLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
| [self addMetricWithName:@"Physical Free"
|
| atIndex:index++
|
| usingLabel:_physicalFreeMemoryLabel];
|
| - _realMemoryUsedLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]);
|
| + _realMemoryUsedLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
| [self addMetricWithName:@"Real Memory Used"
|
| atIndex:index++
|
| usingLabel:_realMemoryUsedLabel];
|
| - _xcodeGaugeLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]);
|
| + _xcodeGaugeLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
| [self addMetricWithName:@"Xcode Gauge"
|
| atIndex:index++
|
| usingLabel:_xcodeGaugeLabel];
|
| - _dirtyVirtualMemoryLabel.reset([[UILabel alloc] initWithFrame:CGRectZero]);
|
| + _dirtyVirtualMemoryLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
| [self addMetricWithName:@"Dirty VM"
|
| atIndex:index++
|
| usingLabel:_dirtyVirtualMemoryLabel];
|
| @@ -130,7 +132,7 @@ const CGFloat kPadding = 10;
|
|
|
| // Display a text input to set the amount of artificial memory bloat and a
|
| // button to reset the bloat to zero.
|
| - _bloatField.reset([[UITextField alloc] initWithFrame:CGRectZero]);
|
| + _bloatField = [[UITextField alloc] initWithFrame:CGRectZero];
|
| [self addLabelWithText:@"Set bloat (MB)"
|
| input:_bloatField
|
| inputTarget:self
|
| @@ -148,8 +150,8 @@ const CGFloat kPadding = 10;
|
| // like them) in official builds.
|
| #if CHROMIUM_BUILD
|
| // Display a text input to control the rate of continuous memory warnings.
|
| - _continuousMemoryWarningField.reset(
|
| - [[UITextField alloc] initWithFrame:CGRectZero]);
|
| + _continuousMemoryWarningField =
|
| + [[UITextField alloc] initWithFrame:CGRectZero];
|
| [self addLabelWithText:@"Set memory warning interval (secs)"
|
| input:_continuousMemoryWarningField
|
| inputTarget:self
|
| @@ -159,7 +161,7 @@ const CGFloat kPadding = 10;
|
| #endif // CHROMIUM_BUILD
|
|
|
| // Display a text input to control the refresh rate of the memory debugger.
|
| - _refreshField.reset([[UITextField alloc] initWithFrame:CGRectZero]);
|
| + _refreshField = [[UITextField alloc] initWithFrame:CGRectZero];
|
| [self addLabelWithText:@"Set refresh interval (secs)"
|
| input:_refreshField
|
| inputTarget:self
|
| @@ -204,8 +206,7 @@ const CGFloat kPadding = 10;
|
| CGPoint nameOrigin = [self originForSubviewAtIndex:index];
|
| CGRect nameFrame =
|
| CGRectMake(nameOrigin.x, nameOrigin.y, kNameWidth, [_font lineHeight]);
|
| - base::scoped_nsobject<UILabel> nameLabel(
|
| - [[UILabel alloc] initWithFrame:nameFrame]);
|
| + UILabel* nameLabel = [[UILabel alloc] initWithFrame:nameFrame];
|
| [nameLabel setText:[NSString stringWithFormat:@"%@: ", name]];
|
| [nameLabel setFont:_font];
|
| [self addSubview:nameLabel];
|
| @@ -221,8 +222,7 @@ const CGFloat kPadding = 10;
|
| target:(id)target
|
| action:(SEL)action
|
| withOrigin:(CGPoint)origin {
|
| - base::scoped_nsobject<UIButton> button(
|
| - [[UIButton buttonWithType:UIButtonTypeSystem] retain]);
|
| + UIButton* button = [UIButton buttonWithType:UIButtonTypeSystem];
|
| [button setTitle:title forState:UIControlStateNormal];
|
| [button titleLabel].font = _font;
|
| [[button titleLabel] setTextAlignment:NSTextAlignmentCenter];
|
| @@ -274,8 +274,7 @@ const CGFloat kPadding = 10;
|
| buttonTarget:(id)buttonTarget
|
| buttonAction:(SEL)buttonAction
|
| atIndex:(NSUInteger)index {
|
| - base::scoped_nsobject<UILabel> label(
|
| - [[UILabel alloc] initWithFrame:CGRectZero]);
|
| + UILabel* label = [[UILabel alloc] initWithFrame:CGRectZero];
|
| if (labelText) {
|
| [label setText:[NSString stringWithFormat:@"%@: ", labelText]];
|
| }
|
| @@ -467,12 +466,11 @@ const CGFloat kPadding = 10;
|
| return;
|
| }
|
| [_refreshTimer invalidate];
|
| - _refreshTimer.reset(
|
| - [[NSTimer scheduledTimerWithTimeInterval:refreshTimerValue
|
| - target:self
|
| - selector:@selector(refresh:)
|
| - userInfo:nil
|
| - repeats:YES] retain]);
|
| + _refreshTimer = [NSTimer scheduledTimerWithTimeInterval:refreshTimerValue
|
| + target:self
|
| + selector:@selector(refresh:)
|
| + userInfo:nil
|
| + repeats:YES];
|
| }
|
|
|
| #pragma mark Memory warning interval methods
|
| @@ -509,12 +507,12 @@ const CGFloat kPadding = 10;
|
| // memory warnings.
|
| #pragma clang diagnostic push
|
| #pragma clang diagnostic ignored "-Wundeclared-selector"
|
| - _memoryWarningTimer.reset(
|
| - [[NSTimer scheduledTimerWithTimeInterval:timerValue
|
| - target:[UIApplication sharedApplication]
|
| - selector:@selector(_performMemoryWarning)
|
| - userInfo:nil
|
| - repeats:YES] retain]);
|
| + _memoryWarningTimer =
|
| + [NSTimer scheduledTimerWithTimeInterval:timerValue
|
| + target:[UIApplication sharedApplication]
|
| + selector:@selector(_performMemoryWarning)
|
| + userInfo:nil
|
| + repeats:YES];
|
| #pragma clang diagnostic push
|
| }
|
| #endif // CHROMIUM_BUILD
|
|
|