OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 IPC_IPC_MESSAGE_ATTACHMENT_H_ | 5 #ifndef IPC_IPC_MESSAGE_ATTACHMENT_H_ |
6 #define IPC_IPC_MESSAGE_ATTACHMENT_H_ | 6 #define IPC_IPC_MESSAGE_ATTACHMENT_H_ |
7 | 7 |
8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "ipc/ipc_export.h" | 11 #include "ipc/ipc_export.h" |
12 | 12 |
13 namespace IPC { | 13 namespace IPC { |
14 | 14 |
15 // Auxiliary data sent with |Message|. This can be a platform file descriptor | 15 // Auxiliary data sent with |Message|. This can be a platform file descriptor |
16 // or a mojo |MessagePipe|. |GetType()| returns the type of the subclass. | 16 // or a mojo |MessagePipe|. |GetType()| returns the type of the subclass. |
| 17 // TODO(mgiuca): Avoid using UnsafeRefCounted. http://crbug.com/469952. |
17 class IPC_EXPORT MessageAttachment | 18 class IPC_EXPORT MessageAttachment |
18 : public base::RefCounted<MessageAttachment> { | 19 : public base::UnsafeRefCounted<MessageAttachment> { |
19 public: | 20 public: |
20 enum Type { | 21 enum Type { |
21 TYPE_PLATFORM_FILE, // The instance is |PlatformFileAttachment|. | 22 TYPE_PLATFORM_FILE, // The instance is |PlatformFileAttachment|. |
22 TYPE_MOJO_HANDLE, // The instance is |MojoHandleAttachment|. | 23 TYPE_MOJO_HANDLE, // The instance is |MojoHandleAttachment|. |
23 }; | 24 }; |
24 | 25 |
25 virtual Type GetType() const = 0; | 26 virtual Type GetType() const = 0; |
26 | 27 |
27 #if defined(OS_POSIX) | 28 #if defined(OS_POSIX) |
28 virtual base::PlatformFile TakePlatformFile() = 0; | 29 virtual base::PlatformFile TakePlatformFile() = 0; |
29 #endif // OS_POSIX | 30 #endif // OS_POSIX |
30 | 31 |
31 protected: | 32 protected: |
32 friend class base::RefCounted<MessageAttachment>; | 33 friend class base::UnsafeRefCounted<MessageAttachment>; |
33 MessageAttachment(); | 34 MessageAttachment(); |
34 virtual ~MessageAttachment(); | 35 virtual ~MessageAttachment(); |
35 | 36 |
36 DISALLOW_COPY_AND_ASSIGN(MessageAttachment); | 37 DISALLOW_COPY_AND_ASSIGN(MessageAttachment); |
37 }; | 38 }; |
38 | 39 |
39 } // namespace IPC | 40 } // namespace IPC |
40 | 41 |
41 #endif // IPC_IPC_MESSAGE_ATTACHMENT_H_ | 42 #endif // IPC_IPC_MESSAGE_ATTACHMENT_H_ |
OLD | NEW |