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

Unified Diff: base/message_loop/message_pump_mac.h

Issue 255393002: Hide NSAutoreleasePool from ARC translation units. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename type alias to AutoreleasePoolType and add comment as to its purpose. Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/message_loop/message_pump_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_pump_mac.h
diff --git a/base/message_loop/message_pump_mac.h b/base/message_loop/message_pump_mac.h
index 424cb70938d058a90288ceb5314bf73c8ae3200c..c075b28cc941305800d6fb4d2e33ab495220dc5e 100644
--- a/base/message_loop/message_pump_mac.h
+++ b/base/message_loop/message_pump_mac.h
@@ -38,9 +38,7 @@
#include "base/memory/weak_ptr.h"
-#if !defined(__OBJC__)
-class NSAutoreleasePool;
-#else // !defined(__OBJC__)
+#if defined(__OBJC__)
#if defined(OS_IOS)
#import <Foundation/Foundation.h>
#else
@@ -55,7 +53,7 @@ class NSAutoreleasePool;
- (BOOL)isHandlingSendEvent;
@end
#endif // !defined(OS_IOS)
-#endif // !defined(__OBJC__)
+#endif // defined(__OBJC__)
namespace base {
@@ -63,6 +61,21 @@ class MessagePumpInstrumentation;
class RunLoop;
class TimeTicks;
+// AutoreleasePoolType is a proxy type for autorelease pools. Its definition
+// depends on the TU in which this header appears. In pure C++ TUs, it is
Mark Mentovai 2014/04/29 02:07:03 TU is not a commonly-understood abbreviation. Say
+// defined as a forward C++ class declaration (that is never defined), because
+// autorelease pools are an Objective-C concept. In Automatic Reference Counting
+// (ARC) Objective-C TUs, it is similarly defined as a forward C++ class
+// declaration, because clang will not allow the type "NSAutoreleasePool" in
+// such TUs. Finally, in Manual Retain Release (MRR) Objective-C TUs, it is a
+// type alias for NSAutoreleasePool. In all cases, a method that takes or
+// returns an NSAutoreleasePool* can use AutoreleasePoolType* instead.
+#if !defined(__OBJC__) || __has_feature(objc_arc)
+class AutoreleasePoolType;
+#else // !defined(__OBJC__) || __has_feature(objc_arc)
+typedef NSAutoreleasePool AutoreleasePoolType;
+#endif // !defined(__OBJC__) || __has_feature(objc_arc)
+
class MessagePumpCFRunLoopBase : public MessagePump {
// Needs access to CreateAutoreleasePool.
friend class MessagePumpScopedAutoreleasePool;
@@ -94,7 +107,7 @@ class MessagePumpCFRunLoopBase : public MessagePump {
// In some cases, CreateAutoreleasePool may return nil intentionally to
// preventing an autorelease pool from being created, allowing any
// objects autoreleased by work to fall into the current autorelease pool.
- virtual NSAutoreleasePool* CreateAutoreleasePool();
+ virtual AutoreleasePoolType* CreateAutoreleasePool();
// Enables instrumentation of the MessagePump. See MessagePumpInstrumentation
// in the implementation for details.
@@ -296,7 +309,7 @@ class MessagePumpCrApplication : public MessagePumpNSApplication {
protected:
// Returns nil if NSApp is currently in the middle of calling
// -sendEvent. Requires NSApp implementing CrAppProtocol.
- virtual NSAutoreleasePool* CreateAutoreleasePool() OVERRIDE;
+ virtual AutoreleasePoolType* CreateAutoreleasePool() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(MessagePumpCrApplication);
« no previous file with comments | « no previous file | base/message_loop/message_pump_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698