 Chromium Code Reviews
 Chromium Code Reviews Issue 345243007:
  Add ScopedObjCClassSwizzler in base/mac, absorbs objc_method_swizzle and ScopedClassSwizzler  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 345243007:
  Add ScopedObjCClassSwizzler in base/mac, absorbs objc_method_swizzle and ScopedClassSwizzler  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: base/test/scoped_class_swizzler_mac.h | 
| diff --git a/base/test/scoped_class_swizzler_mac.h b/base/test/scoped_class_swizzler_mac.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..3346086823b2d3fe36b0e2cfb2c2086b600cc1d1 | 
| --- /dev/null | 
| +++ b/base/test/scoped_class_swizzler_mac.h | 
| @@ -0,0 +1,30 @@ | 
| +// Copyright 2014 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +#ifndef BASE_TEST_SCOPED_CLASS_SWIZZLER_MAC_H_ | 
| +#define BASE_TEST_SCOPED_CLASS_SWIZZLER_MAC_H_ | 
| + | 
| +#import <objc/runtime.h> | 
| + | 
| +#include "base/macros.h" | 
| + | 
| +namespace base { | 
| + | 
| +// Within a given scope, replace the selector |selector| on |target| with that | 
| 
Robert Sesek
2014/07/21 15:59:01
We have this code also in //chrome/common/mac/objc
 
Mark Mentovai
2014/07/21 16:09:58
rsesek wrote:
 
tapted
2014/07/22 12:53:49
Done. I've merged the implementations. Or, more ac
 
Robert Sesek
2014/07/22 13:59:21
Yes, I like the Donor pattern.
 
tapted
2014/07/22 23:41:44
Done.
 | 
| +// from |source|. | 
| +class ScopedClassSwizzler { | 
| 
Mark Mentovai
2014/07/21 16:09:58
This should say ObjC in its name, and the filename
 
tapted
2014/07/22 12:53:49
Done (but dropped the _mac - seems more consistent
 | 
| + public: | 
| + ScopedClassSwizzler(Class target, Class source, SEL selector); | 
| + ~ScopedClassSwizzler(); | 
| + | 
| + private: | 
| + Method old_selector_impl_; | 
| + Method new_selector_impl_; | 
| + | 
| + DISALLOW_COPY_AND_ASSIGN(ScopedClassSwizzler); | 
| +}; | 
| + | 
| +} // namespace base | 
| + | 
| +#endif // BASE_TEST_SCOPED_CLASS_SWIZZLER_MAC_H_ |