summaryrefslogtreecommitdiffstats
path: root/chromium/base/message_loop/message_pump_mac.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/base/message_loop/message_pump_mac.h')
-rw-r--r--chromium/base/message_loop/message_pump_mac.h46
1 files changed, 34 insertions, 12 deletions
diff --git a/chromium/base/message_loop/message_pump_mac.h b/chromium/base/message_loop/message_pump_mac.h
index 424cb70938d..6e63d2b5516 100644
--- a/chromium/base/message_loop/message_pump_mac.h
+++ b/chromium/base/message_loop/message_pump_mac.h
@@ -37,10 +37,9 @@
#include <CoreFoundation/CoreFoundation.h>
#include "base/memory/weak_ptr.h"
+#include "base/message_loop/timer_slack.h"
-#if !defined(__OBJC__)
-class NSAutoreleasePool;
-#else // !defined(__OBJC__)
+#if defined(__OBJC__)
#if defined(OS_IOS)
#import <Foundation/Foundation.h>
#else
@@ -55,7 +54,7 @@ class NSAutoreleasePool;
- (BOOL)isHandlingSendEvent;
@end
#endif // !defined(OS_IOS)
-#endif // !defined(__OBJC__)
+#endif // defined(__OBJC__)
namespace base {
@@ -63,6 +62,22 @@ class MessagePumpInstrumentation;
class RunLoop;
class TimeTicks;
+// AutoreleasePoolType is a proxy type for autorelease pools. Its definition
+// depends on the translation unit (TU) in which this header appears. In pure
+// C++ TUs, it is 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;
@@ -79,6 +94,7 @@ class MessagePumpCFRunLoopBase : public MessagePump {
virtual void ScheduleWork() OVERRIDE;
virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) OVERRIDE;
+ virtual void SetTimerSlack(TimerSlack timer_slack) OVERRIDE;
protected:
// Accessors for private data members to be used by subclasses.
@@ -94,7 +110,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.
@@ -181,6 +197,8 @@ class MessagePumpCFRunLoopBase : public MessagePump {
// See PowerStateNotification.
CFAbsoluteTime delayed_work_fire_time_;
+ base::TimerSlack timer_slack_;
+
// The recursion depth of the currently-executing CFRunLoopRun loop on the
// run loop's thread. 0 if no run loops are running inside of whatever scope
// the object was created in.
@@ -205,7 +223,7 @@ class MessagePumpCFRunLoopBase : public MessagePump {
DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoopBase);
};
-class MessagePumpCFRunLoop : public MessagePumpCFRunLoopBase {
+class BASE_EXPORT MessagePumpCFRunLoop : public MessagePumpCFRunLoopBase {
public:
MessagePumpCFRunLoop();
virtual ~MessagePumpCFRunLoop();
@@ -224,9 +242,9 @@ class MessagePumpCFRunLoop : public MessagePumpCFRunLoopBase {
DISALLOW_COPY_AND_ASSIGN(MessagePumpCFRunLoop);
};
-class MessagePumpNSRunLoop : public MessagePumpCFRunLoopBase {
+class BASE_EXPORT MessagePumpNSRunLoop : public MessagePumpCFRunLoopBase {
public:
- BASE_EXPORT MessagePumpNSRunLoop();
+ MessagePumpNSRunLoop();
virtual ~MessagePumpNSRunLoop();
virtual void DoRun(Delegate* delegate) OVERRIDE;
@@ -296,14 +314,14 @@ 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);
};
#endif // !defined(OS_IOS)
-class MessagePumpMac {
+class BASE_EXPORT MessagePumpMac {
public:
// If not on the main thread, returns a new instance of
// MessagePumpNSRunLoop.
@@ -321,17 +339,21 @@ class MessagePumpMac {
// UsingCrApp() returns false if the message pump was created before
// NSApp was initialized, or if NSApp does not implement
// CrAppProtocol. NSApp must be initialized before calling.
- BASE_EXPORT static bool UsingCrApp();
+ static bool UsingCrApp();
// Wrapper to query -[NSApp isHandlingSendEvent] from C++ code.
// Requires NSApp to implement CrAppProtocol.
- BASE_EXPORT static bool IsHandlingSendEvent();
+ static bool IsHandlingSendEvent();
#endif // !defined(OS_IOS)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac);
};
+// Tasks posted to the message loop are posted under this mode, as well
+// as kCFRunLoopCommonModes.
+extern const CFStringRef BASE_EXPORT kMessageLoopExclusiveRunLoopMode;
+
} // namespace base
#endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_