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

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

Issue 2608733002: Fix include/import in ios/testing and ios/chrome/test (Closed)
Patch Set: Created 3 years, 11 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 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 #import "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 ScopedBlockSwizzler::ScopedBlockSwizzler(Class target, SEL selector, id block) { 9 ScopedBlockSwizzler::ScopedBlockSwizzler(Class target, SEL selector, id block) {
10 method_ = class_getInstanceMethod(target, selector); 10 method_ = class_getInstanceMethod(target, selector);
11 if (!method_) { 11 if (!method_) {
12 // Try swizzling a class method instead. 12 // Try swizzling a class method instead.
13 method_ = class_getClassMethod(target, selector); 13 method_ = class_getClassMethod(target, selector);
14 } 14 }
15 DCHECK(method_); 15 DCHECK(method_);
16 16
17 IMP block_imp = imp_implementationWithBlock(block); 17 IMP block_imp = imp_implementationWithBlock(block);
18 original_imp_ = method_setImplementation(method_, block_imp); 18 original_imp_ = method_setImplementation(method_, block_imp);
19 } 19 }
20 20
21 ScopedBlockSwizzler::~ScopedBlockSwizzler() { 21 ScopedBlockSwizzler::~ScopedBlockSwizzler() {
22 IMP block_imp = method_setImplementation(method_, original_imp_); 22 IMP block_imp = method_setImplementation(method_, original_imp_);
23 DCHECK(imp_removeBlock(block_imp)); 23 DCHECK(imp_removeBlock(block_imp));
24 } 24 }
OLDNEW
« no previous file with comments | « ios/chrome/test/base/perf_test_ios.mm ('k') | ios/chrome/test/base/scoped_block_swizzler_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698