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

Side by Side Diff: base/mac/scoped_objc_class_swizzler.h

Issue 345243007: Add ScopedObjCClassSwizzler in base/mac, absorbs objc_method_swizzle and ScopedClassSwizzler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix EventsMacTest.ButtonEvents Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_MAC_SCOPED_OBJC_CLASS_SWIZZLER_H_
6 #define BASE_MAC_SCOPED_OBJC_CLASS_SWIZZLER_H_
7
8 #import <objc/runtime.h>
9
10 #include "base/base_export.h"
11 #include "base/macros.h"
12
13 namespace base {
14 namespace mac {
15
16 // Within a given scope, replace the selector |selector| on |target| with that
17 // from |source|.
18 class BASE_EXPORT ScopedObjCClassSwizzler {
19 public:
20 ScopedObjCClassSwizzler(Class target, Class source, SEL selector);
21 ~ScopedObjCClassSwizzler();
22
23 // Return a callable function pointer for the replaced method. To call this
24 // from the replacing function, the first two arguments should be |self| and
25 // |_cmd|. These are followed by the (variadic) method arguments.
26 IMP GetOriginalImplementation();
27
28 private:
29 Method old_selector_impl_;
30 Method new_selector_impl_;
31
32 DISALLOW_COPY_AND_ASSIGN(ScopedObjCClassSwizzler);
33 };
34
35 } // namespace mac
36 } // namespace base
37
38 #endif // BASE_MAC_SCOPED_OBJC_CLASS_SWIZZLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698