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

Side by Side Diff: ios/chrome/test/base/scoped_block_swizzler.mm

Issue 2882113004: [ObjC ARC] Converts ios/chrome/test/base:base 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
« no previous file with comments | « ios/chrome/test/base/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ios/chrome/test/base/scoped_block_swizzler.h" 5 #include "ios/chrome/test/base/scoped_block_swizzler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 #if !defined(__has_feature) || !__has_feature(objc_arc)
10 #error "This file requires ARC support."
11 #endif
12
9 ScopedBlockSwizzler::ScopedBlockSwizzler(Class target, SEL selector, id block) { 13 ScopedBlockSwizzler::ScopedBlockSwizzler(Class target, SEL selector, id block) {
10 method_ = class_getInstanceMethod(target, selector); 14 method_ = class_getInstanceMethod(target, selector);
11 if (!method_) { 15 if (!method_) {
12 // Try swizzling a class method instead. 16 // Try swizzling a class method instead.
13 method_ = class_getClassMethod(target, selector); 17 method_ = class_getClassMethod(target, selector);
14 } 18 }
15 DCHECK(method_); 19 DCHECK(method_);
16 20
17 IMP block_imp = imp_implementationWithBlock(block); 21 IMP block_imp = imp_implementationWithBlock(block);
18 original_imp_ = method_setImplementation(method_, block_imp); 22 original_imp_ = method_setImplementation(method_, block_imp);
19 } 23 }
20 24
21 ScopedBlockSwizzler::~ScopedBlockSwizzler() { 25 ScopedBlockSwizzler::~ScopedBlockSwizzler() {
22 IMP block_imp = method_setImplementation(method_, original_imp_); 26 IMP block_imp = method_setImplementation(method_, original_imp_);
23 DCHECK(imp_removeBlock(block_imp)); 27 DCHECK(imp_removeBlock(block_imp));
24 } 28 }
OLDNEW
« no previous file with comments | « ios/chrome/test/base/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698