Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: ios/chrome/app/safe_mode/safe_mode_coordinator.mm

Issue 2894003002: [ObjC ARC] Converts ios/chrome/app/safe_mode:safe_mode to ARC. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/safe_mode/safe_mode_coordinator.h" 5 #import "ios/chrome/app/safe_mode/safe_mode_coordinator.h"
stkhapugin 2017/05/30 13:36:37 In this header, update: @property(nonatomic, null
rohitrao (ping after 24h) 2017/05/30 15:05:07 Should the migration tools be updating header file
lindsayw 2017/06/01 15:35:44 Done.
6 6
7 #include "base/mac/scoped_nsobject.h"
8 #import "ios/chrome/app/safe_mode/safe_mode_view_controller.h" 7 #import "ios/chrome/app/safe_mode/safe_mode_view_controller.h"
9 #include "ios/chrome/browser/crash_loop_detection_util.h" 8 #include "ios/chrome/browser/crash_loop_detection_util.h"
10 9
10 #if !defined(__has_feature) || !__has_feature(objc_arc)
11 #error "This file requires ARC support."
12 #endif
13
11 namespace { 14 namespace {
12 const int kStartupCrashLoopThreshold = 2; 15 const int kStartupCrashLoopThreshold = 2;
13 } 16 }
14 17
15 @interface SafeModeCoordinator ()<SafeModeViewControllerDelegate> { 18 @interface SafeModeCoordinator ()<SafeModeViewControllerDelegate> {
16 // Weak pointer to window passed on init. 19 // Weak pointer to window passed on init.
lindsayw 2017/05/19 12:03:07 stk@ Please let me know how you would like these c
stkhapugin 2017/05/30 13:36:37 I'm okay with keeping them as is.
rohitrao (ping after 24h) 2017/05/30 15:05:07 I would just get rid of the comments on lines 19 a
lindsayw 2017/06/01 15:35:44 Done.
17 base::WeakNSObject<UIWindow> _window; 20 __weak UIWindow* _window;
18 // Weak pointer backing property of the same name. 21 // Weak pointer backing property of the same name.
19 base::WeakNSProtocol<id<SafeModeCoordinatorDelegate>> _delegate; 22 __weak id<SafeModeCoordinatorDelegate> _delegate;
stkhapugin 2017/05/30 13:36:37 Remove this ivar and put: @implementation SafeMod
lindsayw 2017/06/01 15:35:44 Done.
20 } 23 }
21 24
22 @end 25 @end
23 26
24 @implementation SafeModeCoordinator 27 @implementation SafeModeCoordinator
25 28
26 #pragma mark - property implementation. 29 #pragma mark - property implementation.
27 30
28 - (id<SafeModeCoordinatorDelegate>)delegate { 31 - (id<SafeModeCoordinatorDelegate>)delegate {
stkhapugin 2017/05/30 13:36:37 Remove this getter
lindsayw 2017/06/01 15:35:44 Done.
29 return _delegate; 32 return _delegate;
30 } 33 }
31 34
32 - (void)setDelegate:(id<SafeModeCoordinatorDelegate>)delegate { 35 - (void)setDelegate:(id<SafeModeCoordinatorDelegate>)delegate {
33 _delegate.reset(delegate); 36 _delegate = delegate;
stkhapugin 2017/05/30 13:36:37 Remove this setter.
lindsayw 2017/06/01 15:35:44 Done.
34 } 37 }
35 38
36 #pragma mark - Public class methods 39 #pragma mark - Public class methods
37 40
38 + (BOOL)shouldStart { 41 + (BOOL)shouldStart {
39 // Check whether there appears to be a startup crash loop. If not, don't look 42 // Check whether there appears to be a startup crash loop. If not, don't look
40 // at anything else. 43 // at anything else.
41 if (crash_util::GetFailedStartupAttemptCount() < kStartupCrashLoopThreshold) 44 if (crash_util::GetFailedStartupAttemptCount() < kStartupCrashLoopThreshold)
42 return NO; 45 return NO;
43 46
44 return [SafeModeViewController hasSuggestions]; 47 return [SafeModeViewController hasSuggestions];
45 } 48 }
46 49
47 #pragma mark - ChromeCoordinator implementation 50 #pragma mark - ChromeCoordinator implementation
48 51
49 - (void)start { 52 - (void)start {
50 // Create the SafeModeViewController and make it the root view controller for 53 // Create the SafeModeViewController and make it the root view controller for
51 // the window. The window has ownership of it and will dispose of it when 54 // the window. The window has ownership of it and will dispose of it when
52 // another view controller is made root. 55 // another view controller is made root.
53 // 56 //
54 // General note: Safe mode should be safe; it should not depend on other 57 // General note: Safe mode should be safe; it should not depend on other
55 // objects being created. Be extremely conservative when adding code to this 58 // objects being created. Be extremely conservative when adding code to this
56 // method. 59 // method.
57 base::scoped_nsobject<SafeModeViewController> viewController( 60 SafeModeViewController* viewController =
58 [[SafeModeViewController alloc] initWithDelegate:self]); 61 [[SafeModeViewController alloc] initWithDelegate:self];
59 [self.window setRootViewController:viewController]; 62 [self.window setRootViewController:viewController];
60 63
61 // Reset the crash count; the user may change something based on the recovery 64 // Reset the crash count; the user may change something based on the recovery
62 // UI that will fix the crash, and having the next launch start in recovery 65 // UI that will fix the crash, and having the next launch start in recovery
63 // mode would be strange. 66 // mode would be strange.
64 crash_util::ResetFailedStartupAttemptCount(); 67 crash_util::ResetFailedStartupAttemptCount();
65 } 68 }
66 69
67 // Override of ChildCoordinators method, which is not supported in this class. 70 // Override of ChildCoordinators method, which is not supported in this class.
68 - (MutableCoordinatorArray*)childCoordinators { 71 - (MutableCoordinatorArray*)childCoordinators {
69 NOTREACHED() << "Do not add child coordinators to SafeModeCoordinator."; 72 NOTREACHED() << "Do not add child coordinators to SafeModeCoordinator.";
70 return nil; 73 return nil;
71 } 74 }
72 75
73 #pragma mark - SafeModeViewControllerDelegate implementation 76 #pragma mark - SafeModeViewControllerDelegate implementation
74 77
75 - (void)startBrowserFromSafeMode { 78 - (void)startBrowserFromSafeMode {
76 [self.delegate coordinatorDidExitSafeMode:self]; 79 [self.delegate coordinatorDidExitSafeMode:self];
77 } 80 }
78 81
79 @end 82 @end
OLDNEW
« no previous file with comments | « ios/chrome/app/safe_mode/BUILD.gn ('k') | ios/chrome/app/safe_mode/safe_mode_view_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698