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

Side by Side 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: Change the return type in the method definitions to match the declarations. Created 6 years, 7 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
« no previous file with comments | « no previous file | base/message_loop/message_pump_mac.mm » ('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) 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 20 matching lines...) Expand all
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 #include "base/basictypes.h" 35 #include "base/basictypes.h"
36 36
37 #include <CoreFoundation/CoreFoundation.h> 37 #include <CoreFoundation/CoreFoundation.h>
38 38
39 #include "base/memory/weak_ptr.h" 39 #include "base/memory/weak_ptr.h"
40 40
41 #if !defined(__OBJC__) 41 #if defined(__OBJC__)
42 class NSAutoreleasePool;
43 #else // !defined(__OBJC__)
44 #if defined(OS_IOS) 42 #if defined(OS_IOS)
45 #import <Foundation/Foundation.h> 43 #import <Foundation/Foundation.h>
46 #else 44 #else
47 #import <AppKit/AppKit.h> 45 #import <AppKit/AppKit.h>
48 46
49 // Clients must subclass NSApplication and implement this protocol if they use 47 // Clients must subclass NSApplication and implement this protocol if they use
50 // MessagePumpMac. 48 // MessagePumpMac.
51 @protocol CrAppProtocol 49 @protocol CrAppProtocol
52 // Must return true if -[NSApplication sendEvent:] is currently on the stack. 50 // Must return true if -[NSApplication sendEvent:] is currently on the stack.
53 // See the comment for |CreateAutoreleasePool()| in the cc file for why this is 51 // See the comment for |CreateAutoreleasePool()| in the cc file for why this is
54 // necessary. 52 // necessary.
55 - (BOOL)isHandlingSendEvent; 53 - (BOOL)isHandlingSendEvent;
56 @end 54 @end
57 #endif // !defined(OS_IOS) 55 #endif // !defined(OS_IOS)
58 #endif // !defined(__OBJC__) 56 #endif // defined(__OBJC__)
59 57
60 namespace base { 58 namespace base {
61 59
62 class MessagePumpInstrumentation; 60 class MessagePumpInstrumentation;
63 class RunLoop; 61 class RunLoop;
64 class TimeTicks; 62 class TimeTicks;
65 63
64 #if !defined(__OBJC__) || __has_feature(objc_arc)
65 class AutoreleasePool;
Mark Mentovai 2014/04/28 21:12:12 Call this AutoreleasePoolType so that it doesn’t l
66 #else // !defined(__OBJC__) || __has_feature(objc_arc)
67 typedef NSAutoreleasePool AutoreleasePool;
68 #endif // !defined(__OBJC__) || __has_feature(objc_arc)
69
66 class MessagePumpCFRunLoopBase : public MessagePump { 70 class MessagePumpCFRunLoopBase : public MessagePump {
67 // Needs access to CreateAutoreleasePool. 71 // Needs access to CreateAutoreleasePool.
68 friend class MessagePumpScopedAutoreleasePool; 72 friend class MessagePumpScopedAutoreleasePool;
69 public: 73 public:
70 MessagePumpCFRunLoopBase(); 74 MessagePumpCFRunLoopBase();
71 virtual ~MessagePumpCFRunLoopBase(); 75 virtual ~MessagePumpCFRunLoopBase();
72 76
73 // Subclasses should implement the work they need to do in MessagePump::Run 77 // Subclasses should implement the work they need to do in MessagePump::Run
74 // in the DoRun method. MessagePumpCFRunLoopBase::Run calls DoRun directly. 78 // in the DoRun method. MessagePumpCFRunLoopBase::Run calls DoRun directly.
75 // This arrangement is used because MessagePumpCFRunLoopBase needs to set 79 // This arrangement is used because MessagePumpCFRunLoopBase needs to set
(...skipping 11 matching lines...) Expand all
87 int run_nesting_level() const { return run_nesting_level_; } 91 int run_nesting_level() const { return run_nesting_level_; }
88 92
89 // Sets this pump's delegate. Signals the appropriate sources if 93 // Sets this pump's delegate. Signals the appropriate sources if
90 // |delegateless_work_| is true. |delegate| can be NULL. 94 // |delegateless_work_| is true. |delegate| can be NULL.
91 void SetDelegate(Delegate* delegate); 95 void SetDelegate(Delegate* delegate);
92 96
93 // Return an autorelease pool to wrap around any work being performed. 97 // Return an autorelease pool to wrap around any work being performed.
94 // In some cases, CreateAutoreleasePool may return nil intentionally to 98 // In some cases, CreateAutoreleasePool may return nil intentionally to
95 // preventing an autorelease pool from being created, allowing any 99 // preventing an autorelease pool from being created, allowing any
96 // objects autoreleased by work to fall into the current autorelease pool. 100 // objects autoreleased by work to fall into the current autorelease pool.
97 virtual NSAutoreleasePool* CreateAutoreleasePool(); 101 virtual AutoreleasePool* CreateAutoreleasePool();
98 102
99 // Enables instrumentation of the MessagePump. See MessagePumpInstrumentation 103 // Enables instrumentation of the MessagePump. See MessagePumpInstrumentation
100 // in the implementation for details. 104 // in the implementation for details.
101 void EnableInstrumentation(); 105 void EnableInstrumentation();
102 WeakPtr<MessagePumpInstrumentation> instrumentation_; 106 WeakPtr<MessagePumpInstrumentation> instrumentation_;
103 107
104 private: 108 private:
105 // Timer callback scheduled by ScheduleDelayedWork. This does not do any 109 // Timer callback scheduled by ScheduleDelayedWork. This does not do any
106 // work, but it signals work_source_ so that delayed work can be performed 110 // work, but it signals work_source_ so that delayed work can be performed
107 // within the appropriate priority constraints. 111 // within the appropriate priority constraints.
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 }; 293 };
290 294
291 class MessagePumpCrApplication : public MessagePumpNSApplication { 295 class MessagePumpCrApplication : public MessagePumpNSApplication {
292 public: 296 public:
293 MessagePumpCrApplication(); 297 MessagePumpCrApplication();
294 virtual ~MessagePumpCrApplication(); 298 virtual ~MessagePumpCrApplication();
295 299
296 protected: 300 protected:
297 // Returns nil if NSApp is currently in the middle of calling 301 // Returns nil if NSApp is currently in the middle of calling
298 // -sendEvent. Requires NSApp implementing CrAppProtocol. 302 // -sendEvent. Requires NSApp implementing CrAppProtocol.
299 virtual NSAutoreleasePool* CreateAutoreleasePool() OVERRIDE; 303 virtual AutoreleasePool* CreateAutoreleasePool() OVERRIDE;
300 304
301 private: 305 private:
302 DISALLOW_COPY_AND_ASSIGN(MessagePumpCrApplication); 306 DISALLOW_COPY_AND_ASSIGN(MessagePumpCrApplication);
303 }; 307 };
304 #endif // !defined(OS_IOS) 308 #endif // !defined(OS_IOS)
305 309
306 class MessagePumpMac { 310 class MessagePumpMac {
307 public: 311 public:
308 // If not on the main thread, returns a new instance of 312 // If not on the main thread, returns a new instance of
309 // MessagePumpNSRunLoop. 313 // MessagePumpNSRunLoop.
(...skipping 18 matching lines...) Expand all
328 BASE_EXPORT static bool IsHandlingSendEvent(); 332 BASE_EXPORT static bool IsHandlingSendEvent();
329 #endif // !defined(OS_IOS) 333 #endif // !defined(OS_IOS)
330 334
331 private: 335 private:
332 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac); 336 DISALLOW_IMPLICIT_CONSTRUCTORS(MessagePumpMac);
333 }; 337 };
334 338
335 } // namespace base 339 } // namespace base
336 340
337 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_ 341 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_MAC_H_
OLDNEW
« 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