ipc/chromium/src/base/scoped_nsautorelease_pool.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
     2 // Use of this source code is governed by a BSD-style license that can be
     3 // found in the LICENSE file.
     5 #ifndef BASE_SCOPED_NSAUTORELEASE_POOL_H_
     6 #define BASE_SCOPED_NSAUTORELEASE_POOL_H_
     8 #include "base/basictypes.h"
    10 #if defined(OS_MACOSX)
    11 #if defined(__OBJC__)
    12 @class NSAutoreleasePool;
    13 #else  // __OBJC__
    14 class NSAutoreleasePool;
    15 #endif  // __OBJC__
    16 #endif  // OS_MACOSX
    18 namespace base {
    20 // On the Mac, ScopedNSAutoreleasePool allocates an NSAutoreleasePool when
    21 // instantiated and sends it a -drain message when destroyed.  This allows an
    22 // autorelease pool to be maintained in ordinary C++ code without bringing in
    23 // any direct Objective-C dependency.
    24 //
    25 // On other platforms, ScopedNSAutoreleasePool is an empty object with no
    26 // effects.  This allows it to be used directly in cross-platform code without
    27 // ugly #ifdefs.
    28 class ScopedNSAutoreleasePool {
    29  public:
    30 #if !defined(OS_MACOSX)
    31   ScopedNSAutoreleasePool() {}
    32   void Recycle() { }
    33 #else  // OS_MACOSX
    34   ScopedNSAutoreleasePool();
    35   ~ScopedNSAutoreleasePool();
    37   // Clear out the pool in case its position on the stack causes it to be
    38   // alive for long periods of time (such as the entire length of the app).
    39   // Only use then when you're certain the items currently in the pool are
    40   // no longer needed.
    41   void Recycle();
    42  private:
    43   NSAutoreleasePool* autorelease_pool_;
    44 #endif  // OS_MACOSX
    46  private:
    47   DISALLOW_COPY_AND_ASSIGN(ScopedNSAutoreleasePool);
    48 };
    50 }  // namespace base
    52 #endif  // BASE_SCOPED_NSAUTORELEASE_POOL_H_

mercurial