OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 MOJO_EDK_SYSTEM_MESSAGE_PIPE_H_ | 5 #ifndef MOJO_EDK_SYSTEM_MESSAGE_PIPE_H_ |
6 #define MOJO_EDK_SYSTEM_MESSAGE_PIPE_H_ | 6 #define MOJO_EDK_SYSTEM_MESSAGE_PIPE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
| 11 #include <memory> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "mojo/edk/embedder/platform_handle_vector.h" | 15 #include "mojo/edk/embedder/platform_handle_vector.h" |
16 #include "mojo/edk/system/channel_endpoint_client.h" | 16 #include "mojo/edk/system/channel_endpoint_client.h" |
17 #include "mojo/edk/system/dispatcher.h" | 17 #include "mojo/edk/system/dispatcher.h" |
18 #include "mojo/edk/system/handle_signals_state.h" | 18 #include "mojo/edk/system/handle_signals_state.h" |
19 #include "mojo/edk/system/memory.h" | 19 #include "mojo/edk/system/memory.h" |
20 #include "mojo/edk/system/message_in_transit.h" | 20 #include "mojo/edk/system/message_in_transit.h" |
21 #include "mojo/edk/system/message_pipe_endpoint.h" | 21 #include "mojo/edk/system/message_pipe_endpoint.h" |
22 #include "mojo/edk/system/mutex.h" | 22 #include "mojo/edk/system/mutex.h" |
23 #include "mojo/edk/system/system_impl_export.h" | 23 #include "mojo/edk/system/system_impl_export.h" |
24 #include "mojo/public/c/system/message_pipe.h" | 24 #include "mojo/public/c/system/message_pipe.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 void OnDetachFromChannel(unsigned port) override; | 120 void OnDetachFromChannel(unsigned port) override; |
121 | 121 |
122 private: | 122 private: |
123 MessagePipe(); | 123 MessagePipe(); |
124 ~MessagePipe() override; | 124 ~MessagePipe() override; |
125 | 125 |
126 // This is used internally by |WriteMessage()| and by |OnReadMessage()|. | 126 // This is used internally by |WriteMessage()| and by |OnReadMessage()|. |
127 // |transports| may be non-null only if it's nonempty and |message| has no | 127 // |transports| may be non-null only if it's nonempty and |message| has no |
128 // dispatchers attached. Must be called with |lock_| held. | 128 // dispatchers attached. Must be called with |lock_| held. |
129 MojoResult EnqueueMessageNoLock(unsigned port, | 129 MojoResult EnqueueMessageNoLock(unsigned port, |
130 scoped_ptr<MessageInTransit> message, | 130 std::unique_ptr<MessageInTransit> message, |
131 std::vector<DispatcherTransport>* transports) | 131 std::vector<DispatcherTransport>* transports) |
132 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); | 132 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); |
133 | 133 |
134 // Helper for |EnqueueMessageNoLock()|. | 134 // Helper for |EnqueueMessageNoLock()|. |
135 MojoResult AttachTransportsNoLock( | 135 MojoResult AttachTransportsNoLock( |
136 unsigned port, | 136 unsigned port, |
137 MessageInTransit* message, | 137 MessageInTransit* message, |
138 std::vector<DispatcherTransport>* transports) | 138 std::vector<DispatcherTransport>* transports) |
139 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); | 139 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); |
140 | 140 |
141 mutable Mutex mutex_; | 141 mutable Mutex mutex_; |
142 scoped_ptr<MessagePipeEndpoint> endpoints_[2] MOJO_GUARDED_BY(mutex_); | 142 std::unique_ptr<MessagePipeEndpoint> endpoints_[2] MOJO_GUARDED_BY(mutex_); |
143 | 143 |
144 MOJO_DISALLOW_COPY_AND_ASSIGN(MessagePipe); | 144 MOJO_DISALLOW_COPY_AND_ASSIGN(MessagePipe); |
145 }; | 145 }; |
146 | 146 |
147 } // namespace system | 147 } // namespace system |
148 } // namespace mojo | 148 } // namespace mojo |
149 | 149 |
150 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_H_ | 150 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_H_ |
OLD | NEW |