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

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

Issue 1532813002: Replace IOSurfaceManager by directly passing IOSurface Mach ports over Chrome IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows compile Created 5 years 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
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/mac/scoped_typeref.h"
11 #include "base/scoped_generic.h" 12 #include "base/scoped_generic.h"
12 13
13 namespace base { 14 namespace base {
14 namespace mac { 15 namespace mac {
15 16
16 namespace internal { 17 namespace internal {
17 18
18 struct BASE_EXPORT SendRightTraits { 19 struct BASE_EXPORT SendRightTraits {
19 static mach_port_t InvalidValue() { 20 static mach_port_t InvalidValue() {
20 return MACH_PORT_NULL; 21 return MACH_PORT_NULL;
(...skipping 11 matching lines...) Expand all
32 }; 33 };
33 34
34 struct PortSetTraits { 35 struct PortSetTraits {
35 static mach_port_t InvalidValue() { 36 static mach_port_t InvalidValue() {
36 return MACH_PORT_NULL; 37 return MACH_PORT_NULL;
37 } 38 }
38 39
39 BASE_EXPORT static void Free(mach_port_t port); 40 BASE_EXPORT static void Free(mach_port_t port);
40 }; 41 };
41 42
43 struct RefCountedSendRighTraits {
44 BASE_EXPORT static void Retain(mach_port_t);
45 BASE_EXPORT static void Release(mach_port_t);
46 };
47
42 } // namespace internal 48 } // namespace internal
43 49
44 // A scoper for handling a Mach port that names a send right. Send rights are 50 // A scoper for handling a Mach port that names a send right. Send rights are
45 // reference counted, and this takes ownership of the right on construction 51 // reference counted, and this takes ownership of the right on construction
46 // and then removes a reference to the right on destruction. If the reference 52 // and then removes a reference to the right on destruction. If the reference
47 // is the last one on the right, the right is deallocated. 53 // is the last one on the right, the right is deallocated.
48 using ScopedMachSendRight = 54 using ScopedMachSendRight =
49 ScopedGeneric<mach_port_t, internal::SendRightTraits>; 55 ScopedGeneric<mach_port_t, internal::SendRightTraits>;
50 56
51 // A scoper for handling a Mach port's receive right. There is only one 57 // A scoper for handling a Mach port's receive right. There is only one
52 // receive right per port. This takes ownership of the receive right on 58 // receive right per port. This takes ownership of the receive right on
53 // construction and then destroys the right on destruction, turning all 59 // construction and then destroys the right on destruction, turning all
54 // outstanding send rights into dead names. 60 // outstanding send rights into dead names.
55 using ScopedMachReceiveRight = 61 using ScopedMachReceiveRight =
56 ScopedGeneric<mach_port_t, internal::ReceiveRightTraits>; 62 ScopedGeneric<mach_port_t, internal::ReceiveRightTraits>;
57 63
58 // A scoper for handling a Mach port set. A port set can have only one 64 // A scoper for handling a Mach port set. A port set can have only one
59 // reference. This takes ownership of that single reference on construction and 65 // reference. This takes ownership of that single reference on construction and
60 // destroys the port set on destruction. Destroying a port set does not destroy 66 // destroys the port set on destruction. Destroying a port set does not destroy
61 // the receive rights that are members of the port set. 67 // the receive rights that are members of the port set.
62 using ScopedMachPortSet = ScopedGeneric<mach_port_t, internal::PortSetTraits>; 68 using ScopedMachPortSet = ScopedGeneric<mach_port_t, internal::PortSetTraits>;
63 69
70 // A scoper for handling Mach port names that are send rights. Unlike
71 // ScopedMachSendRight, this scoper is both copyable and assignable, which will
72 // increase the kernel reference count of the right. Otherwise, this behaves
73 // the same as ScopedMachSendRight.
74 using ScopedRefCountedMachSendRight =
75 ScopedTypeRef<mach_port_t, internal::RefCountedSendRighTraits>;
76
64 } // namespace mac 77 } // namespace mac
65 } // namespace base 78 } // namespace base
66 79
67 #endif // BASE_MAC_SCOPED_MACH_PORT_H_ 80 #endif // BASE_MAC_SCOPED_MACH_PORT_H_
OLDNEW
« no previous file with comments | « no previous file | base/mac/scoped_mach_port.cc » ('j') | content/common/gpu/gpu_memory_buffer_factory_io_surface.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698