| 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_SYSTEM_DISPATCHER_H_ | 5 #ifndef MOJO_SYSTEM_DISPATCHER_H_ |
| 6 #define MOJO_SYSTEM_DISPATCHER_H_ | 6 #define MOJO_SYSTEM_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 friend DispatcherTransport test::DispatcherTryStartTransport(Dispatcher*); | 140 friend DispatcherTransport test::DispatcherTryStartTransport(Dispatcher*); |
| 141 | 141 |
| 142 // This must be called under the handle table lock and only if the handle | 142 // This must be called under the handle table lock and only if the handle |
| 143 // table entry is not marked busy. The caller must maintain a reference to | 143 // table entry is not marked busy. The caller must maintain a reference to |
| 144 // |dispatcher| until |DispatcherTransport::End()| is called. | 144 // |dispatcher| until |DispatcherTransport::End()| is called. |
| 145 static DispatcherTransport TryStartTransport(Dispatcher* dispatcher); | 145 static DispatcherTransport TryStartTransport(Dispatcher* dispatcher); |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 // A |MessageInTransit| may serialize dispatchers that are attached to it to a | 148 // A |MessageInTransit| may serialize dispatchers that are attached to it to a |
| 149 // given |Channel| and then (probably in a different process) deserialize. | 149 // given |Channel| and then (probably in a different process) deserialize. |
| 150 // Note that the |MessageInTransit| "owns" (i.e., has the only ref to) these |
| 151 // dispatchers, so there are no locking issues. (There's no lock ordering |
| 152 // issue, and in fact no need to take dispatcher locks at all.) |
| 150 // TODO(vtl): Consider making another wrapper similar to |DispatcherTransport| | 153 // TODO(vtl): Consider making another wrapper similar to |DispatcherTransport| |
| 151 // (but with an owning, unique reference), and having | 154 // (but with an owning, unique reference), and having |
| 152 // |CreateEquivalentDispatcherAndCloseImplNoLock()| return that wrapper (and | 155 // |CreateEquivalentDispatcherAndCloseImplNoLock()| return that wrapper (and |
| 153 // |MessageInTransit| only holding on to such wrappers). | 156 // |MessageInTransit| only holding on to such wrappers). |
| 154 class MessageInTransitAccess { | 157 class MessageInTransitAccess { |
| 155 private: | 158 private: |
| 156 friend class MessageInTransit; | 159 friend class MessageInTransit; |
| 157 | 160 |
| 158 // Serialization API. These functions may only be called on such | 161 // Serialization API. These functions may only be called on such |
| 159 // dispatchers. (|channel| is the |Channel| to which the dispatcher is to be | 162 // dispatchers. (|channel| is the |Channel| to which the dispatcher is to be |
| 160 // serialized.) See the |Dispatcher| methods of the same names for more | 163 // serialized.) See the |Dispatcher| methods of the same names for more |
| 161 // details. | 164 // details. |
| 162 // TODO(vtl): Consider replacing this API below with a proper two-phase one | 165 // TODO(vtl): Consider replacing this API below with a proper two-phase one |
| 163 // ("StartSerialize()" and "EndSerializeAndClose()", with the lock possibly | 166 // ("StartSerialize()" and "EndSerializeAndClose()", with the lock possibly |
| 164 // being held across their invocations). | 167 // being held across their invocations). |
| 165 static size_t GetMaximumSerializedSize(const Dispatcher* dispatcher, | 168 static size_t GetMaximumSerializedSize(const Dispatcher* dispatcher, |
| 166 const Channel* channel); | 169 const Channel* channel); |
| 167 static bool SerializeAndClose(Dispatcher* dispatcher, | 170 static bool SerializeAndClose(Dispatcher* dispatcher, |
| 168 Channel* channel, | 171 Channel* channel, |
| 169 void* destination, | 172 void* destination, |
| 170 size_t* actual_size); | 173 size_t* actual_size); |
| 171 | 174 |
| 172 // Deserialization API. | 175 // Deserialization API. |
| 173 // TODO(vtl): Implement this. | |
| 174 static scoped_refptr<Dispatcher> Deserialize(Channel* channel, | 176 static scoped_refptr<Dispatcher> Deserialize(Channel* channel, |
| 175 int32_t type, | 177 int32_t type, |
| 176 const void* source, | 178 const void* source, |
| 177 size_t size); | 179 size_t size); |
| 178 }; | 180 }; |
| 179 | 181 |
| 180 protected: | 182 protected: |
| 181 friend class base::RefCountedThreadSafe<Dispatcher>; | 183 friend class base::RefCountedThreadSafe<Dispatcher>; |
| 182 | 184 |
| 183 Dispatcher(); | 185 Dispatcher(); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 333 |
| 332 Dispatcher* dispatcher_; | 334 Dispatcher* dispatcher_; |
| 333 | 335 |
| 334 // Copy and assign allowed. | 336 // Copy and assign allowed. |
| 335 }; | 337 }; |
| 336 | 338 |
| 337 } // namespace system | 339 } // namespace system |
| 338 } // namespace mojo | 340 } // namespace mojo |
| 339 | 341 |
| 340 #endif // MOJO_SYSTEM_DISPATCHER_H_ | 342 #endif // MOJO_SYSTEM_DISPATCHER_H_ |
| OLD | NEW |