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

Side by Side Diff: chrome/browser/cocoa/objc_zombie.mm

Issue 2822013: Revert 49989 - x (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 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
« no previous file with comments | « no previous file | ipc/file_descriptor_set_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/cocoa/objc_zombie.h" 5 #import "chrome/browser/cocoa/objc_zombie.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <mach-o/dyld.h> 8 #include <mach-o/dyld.h>
9 #include <mach-o/nlist.h> 9 #include <mach-o/nlist.h>
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 nl[0].n_type == N_UNDF || nl[1].n_type == N_UNDF) 93 nl[0].n_type == N_UNDF || nl[1].n_type == N_UNDF)
94 return NULL; 94 return NULL;
95 95
96 return (DestructFn*)((char*)&class_addIvar - nl[1].n_value + nl[0].n_value); 96 return (DestructFn*)((char*)&class_addIvar - nl[1].n_value + nl[0].n_value);
97 } 97 }
98 98
99 // Replacement |-dealloc| which turns objects into zombies and places 99 // Replacement |-dealloc| which turns objects into zombies and places
100 // them into |g_zombies| to be freed later. 100 // them into |g_zombies| to be freed later.
101 void ZombieDealloc(id self, SEL _cmd) { 101 void ZombieDealloc(id self, SEL _cmd) {
102 // This code should only be called when it is implementing |-dealloc|. 102 // This code should only be called when it is implementing |-dealloc|.
103 //DCHECK_EQ(_cmd, @selector(dealloc)); // clang 103 DCHECK_EQ(_cmd, @selector(dealloc));
104 104
105 // Use the original |-dealloc| if the object doesn't wish to be 105 // Use the original |-dealloc| if the object doesn't wish to be
106 // zombied. 106 // zombied.
107 if (!g_zombieAllObjects && ![self shouldBecomeCrZombie]) { 107 if (!g_zombieAllObjects && ![self shouldBecomeCrZombie]) {
108 g_originalDeallocIMP(self, _cmd); 108 g_originalDeallocIMP(self, _cmd);
109 return; 109 return;
110 } 110 }
111 111
112 // Use the original |-dealloc| if |object_cxxDestruct| was never 112 // Use the original |-dealloc| if |object_cxxDestruct| was never
113 // initialized, because otherwise C++ destructors won't be called. 113 // initialized, because otherwise C++ destructors won't be called.
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 if (oldZombies) { 372 if (oldZombies) {
373 for (size_t i = 0; i < oldCount; ++i) { 373 for (size_t i = 0; i < oldCount; ++i) {
374 if (oldZombies[i].object) 374 if (oldZombies[i].object)
375 free(oldZombies[i].object); 375 free(oldZombies[i].object);
376 } 376 }
377 free(oldZombies); 377 free(oldZombies);
378 } 378 }
379 } 379 }
380 380
381 } // namespace ObjcEvilDoers 381 } // namespace ObjcEvilDoers
OLDNEW
« no previous file with comments | « no previous file | ipc/file_descriptor_set_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698