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

Side by Side Diff: base/mac/scoped_mach_port.h

Issue 295933017: Add base::mac::ScopedMachPort::release() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 #ifndef BASE_MAC_SCOPED_MACH_PORT_H_ 5 #ifndef BASE_MAC_SCOPED_MACH_PORT_H_
6 #define BASE_MAC_SCOPED_MACH_PORT_H_ 6 #define BASE_MAC_SCOPED_MACH_PORT_H_
7 7
8 #include <mach/mach.h> 8 #include <mach/mach.h>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
12 13
13 namespace base { 14 namespace base {
14 namespace mac { 15 namespace mac {
15 16
16 // A class for managing the life of a Mach port, releasing via 17 // A class for managing the life of a Mach port, releasing via
17 // mach_port_deallocate either its send and/or receive rights. 18 // mach_port_deallocate either its send and/or receive rights.
18 class BASE_EXPORT ScopedMachPort { 19 class BASE_EXPORT ScopedMachPort {
19 public: 20 public:
20 // Creates a scoper by taking ownership of the port. 21 // Creates a scoper by taking ownership of the port.
21 explicit ScopedMachPort(mach_port_t port); 22 explicit ScopedMachPort(mach_port_t port);
22 23
23 ~ScopedMachPort(); 24 ~ScopedMachPort();
24 25
25 void reset(mach_port_t port = MACH_PORT_NULL); 26 void reset(mach_port_t port = MACH_PORT_NULL);
26 27
27 operator mach_port_t() const { 28 operator mach_port_t() const {
28 return port_; 29 return port_;
29 } 30 }
30 31
31 mach_port_t get() const { 32 mach_port_t get() const {
32 return port_; 33 return port_;
33 } 34 }
34 35
36 mach_port_t release() WARN_UNUSED_RESULT {
37 mach_port_t temp = port_;
38 port_ = MACH_PORT_NULL;
39 return temp;
40 }
41
35 private: 42 private:
36 mach_port_t port_; 43 mach_port_t port_;
37 44
38 DISALLOW_COPY_AND_ASSIGN(ScopedMachPort); 45 DISALLOW_COPY_AND_ASSIGN(ScopedMachPort);
39 }; 46 };
40 47
41 } // namespace mac 48 } // namespace mac
42 } // namespace base 49 } // namespace base
43 50
44 #endif // BASE_MAC_SCOPED_MACH_PORT_H_ 51 #endif // BASE_MAC_SCOPED_MACH_PORT_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698