Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // The basis for all native run loops on the Mac is the CFRunLoop. It can be | 5 // The basis for all native run loops on the Mac is the CFRunLoop. It can be |
| 6 // used directly, it can be used as the driving force behind the similar | 6 // used directly, it can be used as the driving force behind the similar |
| 7 // Foundation NSRunLoop, and it can be used to implement higher-level event | 7 // Foundation NSRunLoop, and it can be used to implement higher-level event |
| 8 // loops such as the NSApplication event loop. | 8 // loops such as the NSApplication event loop. |
| 9 // | 9 // |
| 10 // This file introduces a basic CFRunLoop-based implementation of the | 10 // This file introduces a basic CFRunLoop-based implementation of the |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 // called on. | 28 // called on. |
| 29 | 29 |
| 30 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ | 30 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ |
| 31 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ | 31 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ |
| 32 | 32 |
| 33 #include "base/message_loop/message_pump.h" | 33 #include "base/message_loop/message_pump.h" |
| 34 | 34 |
| 35 | 35 |
| 36 #include <CoreFoundation/CoreFoundation.h> | 36 #include <CoreFoundation/CoreFoundation.h> |
| 37 | 37 |
| 38 #include "base/compiler_specific.h" | |
| 38 #include "base/macros.h" | 39 #include "base/macros.h" |
| 39 #include "base/memory/weak_ptr.h" | 40 #include "base/memory/weak_ptr.h" |
| 40 #include "base/message_loop/timer_slack.h" | 41 #include "base/message_loop/timer_slack.h" |
| 41 #include "build/build_config.h" | 42 #include "build/build_config.h" |
| 42 | 43 |
| 43 #if defined(__OBJC__) | 44 #if defined(__OBJC__) |
| 44 #if defined(OS_IOS) | 45 #if defined(OS_IOS) |
| 45 #import <Foundation/Foundation.h> | 46 #import <Foundation/Foundation.h> |
| 46 #else | 47 #else |
| 47 #import <AppKit/AppKit.h> | 48 #import <AppKit/AppKit.h> |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 65 // AutoreleasePoolType is a proxy type for autorelease pools. Its definition | 66 // AutoreleasePoolType is a proxy type for autorelease pools. Its definition |
| 66 // depends on the translation unit (TU) in which this header appears. In pure | 67 // depends on the translation unit (TU) in which this header appears. In pure |
| 67 // C++ TUs, it is defined as a forward C++ class declaration (that is never | 68 // C++ TUs, it is defined as a forward C++ class declaration (that is never |
| 68 // defined), because autorelease pools are an Objective-C concept. In Automatic | 69 // defined), because autorelease pools are an Objective-C concept. In Automatic |
| 69 // Reference Counting (ARC) Objective-C TUs, it is similarly defined as a | 70 // Reference Counting (ARC) Objective-C TUs, it is similarly defined as a |
| 70 // forward C++ class declaration, because clang will not allow the type | 71 // forward C++ class declaration, because clang will not allow the type |
| 71 // "NSAutoreleasePool" in such TUs. Finally, in Manual Retain Release (MRR) | 72 // "NSAutoreleasePool" in such TUs. Finally, in Manual Retain Release (MRR) |
| 72 // Objective-C TUs, it is a type alias for NSAutoreleasePool. In all cases, a | 73 // Objective-C TUs, it is a type alias for NSAutoreleasePool. In all cases, a |
| 73 // method that takes or returns an NSAutoreleasePool* can use | 74 // method that takes or returns an NSAutoreleasePool* can use |
| 74 // AutoreleasePoolType* instead. | 75 // AutoreleasePoolType* instead. |
| 75 #if !defined(__OBJC__) || __has_feature(objc_arc) | 76 #if !defined(__OBJC__) || HAS_FEATURE(objc_arc) |
|
Nico
2016/04/06 00:38:20
on mac we only support clang, so not using the mac
| |
| 76 class AutoreleasePoolType; | 77 class AutoreleasePoolType; |
| 77 #else // !defined(__OBJC__) || __has_feature(objc_arc) | 78 #else // !defined(__OBJC__) || HAS_FEATURE(objc_arc) |
| 78 typedef NSAutoreleasePool AutoreleasePoolType; | 79 typedef NSAutoreleasePool AutoreleasePoolType; |
| 79 #endif // !defined(__OBJC__) || __has_feature(objc_arc) | 80 #endif // !defined(__OBJC__) || HAS_FEATURE(objc_arc) |
| 80 | 81 |
| 81 class MessagePumpCFRunLoopBase : public MessagePump { | 82 class MessagePumpCFRunLoopBase : public MessagePump { |
| 82 // Needs access to CreateAutoreleasePool. | 83 // Needs access to CreateAutoreleasePool. |
| 83 friend class MessagePumpScopedAutoreleasePool; | 84 friend class MessagePumpScopedAutoreleasePool; |
| 84 public: | 85 public: |
| 85 MessagePumpCFRunLoopBase(); | 86 MessagePumpCFRunLoopBase(); |
| 86 ~MessagePumpCFRunLoopBase() override; | 87 ~MessagePumpCFRunLoopBase() override; |
| 87 | 88 |
| 88 // Subclasses should implement the work they need to do in MessagePump::Run | 89 // Subclasses should implement the work they need to do in MessagePump::Run |
| 89 // in the DoRun method. MessagePumpCFRunLoopBase::Run calls DoRun directly. | 90 // in the DoRun method. MessagePumpCFRunLoopBase::Run calls DoRun directly. |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac); | 346 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac); |
| 346 }; | 347 }; |
| 347 | 348 |
| 348 // Tasks posted to the message loop are posted under this mode, as well | 349 // Tasks posted to the message loop are posted under this mode, as well |
| 349 // as kCFRunLoopCommonModes. | 350 // as kCFRunLoopCommonModes. |
| 350 extern const CFStringRef BASE_EXPORT kMessageLoopExclusiveRunLoopMode; | 351 extern const CFStringRef BASE_EXPORT kMessageLoopExclusiveRunLoopMode; |
| 351 | 352 |
| 352 } // namespace base | 353 } // namespace base |
| 353 | 354 |
| 354 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ | 355 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ |
| OLD | NEW |