Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/browser/ui/overscroll_actions/overscroll_actions_gesture_rec ognizer.h" | 5 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_gesture_rec ognizer.h" |
| 6 | 6 |
| 7 #import <UIKit/UIGestureRecognizerSubclass.h> | 7 #import <UIKit/UIGestureRecognizerSubclass.h> |
| 8 | 8 |
| 9 #import "base/ios/weak_nsobject.h" | 9 #import "base/logging.h" |
| 10 | |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 12 #error "This file requires ARC support." | |
| 13 #endif | |
| 10 | 14 |
| 11 @interface OverscrollActionsGestureRecognizer () { | 15 @interface OverscrollActionsGestureRecognizer () { |
| 12 base::WeakNSProtocol<id> target_; | 16 __weak id target_; |
| 13 SEL action_; | 17 SEL action_; |
| 14 } | 18 } |
| 15 @end | 19 @end |
| 16 | 20 |
| 17 @implementation OverscrollActionsGestureRecognizer | 21 @implementation OverscrollActionsGestureRecognizer |
| 18 | 22 |
| 19 - (instancetype)initWithTarget:(id)target action:(SEL)action { | 23 - (instancetype)initWithTarget:(id)target action:(SEL)action { |
| 20 self = [super initWithTarget:target action:action]; | 24 self = [super initWithTarget:target action:action]; |
| 21 if (self) { | 25 if (self) { |
| 22 target_.reset([target retain]); | 26 target_ = target; |
| 23 action_ = action; | 27 action_ = action; |
| 24 } | 28 } |
| 25 return self; | 29 return self; |
| 26 } | 30 } |
| 27 | 31 |
| 28 - (void)reset { | 32 - (void)reset { |
| 29 [super reset]; | 33 [super reset]; |
| 34 #pragma clang diagnostic push | |
| 35 #pragma clang diagnostic ignored "-Warc-performSelector-leaks" | |
|
jif
2017/06/12 18:18:24
Are we OK to live with this?
marq (ping after 24h)
2017/06/12 18:21:47
We don't really have an option, since the compiler
| |
| 30 [target_ performSelector:action_ withObject:self]; | 36 [target_ performSelector:action_ withObject:self]; |
| 37 #pragma clang diagnostic pop | |
| 31 } | 38 } |
| 32 | 39 |
| 33 - (void)removeTarget:(id)target action:(SEL)action { | 40 - (void)removeTarget:(id)target action:(SEL)action { |
| 34 DCHECK(target != target_); | 41 DCHECK(target != target_); |
| 35 [super removeTarget:target action:action]; | 42 [super removeTarget:target action:action]; |
| 36 } | 43 } |
| 37 | 44 |
| 38 @end | 45 @end |
| OLD | NEW |