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 #include "mojo/edk/system/dispatcher.h" | 5 #include "mojo/edk/system/dispatcher.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/edk/system/configuration.h" | 8 #include "mojo/edk/system/configuration.h" |
9 #include "mojo/edk/system/message_pipe_dispatcher.h" | 9 #include "mojo/edk/system/message_pipe_dispatcher.h" |
10 #include "mojo/edk/system/platform_handle_dispatcher.h" | 10 #include "mojo/edk/system/platform_handle_dispatcher.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 } | 51 } |
52 | 52 |
53 // static | 53 // static |
54 bool Dispatcher::TransportDataAccess::EndSerializeAndClose( | 54 bool Dispatcher::TransportDataAccess::EndSerializeAndClose( |
55 Dispatcher* dispatcher, | 55 Dispatcher* dispatcher, |
56 Channel* channel, | 56 Channel* channel, |
57 void* destination, | 57 void* destination, |
58 size_t* actual_size, | 58 size_t* actual_size, |
59 embedder::PlatformHandleVector* platform_handles) { | 59 embedder::PlatformHandleVector* platform_handles) { |
60 DCHECK(dispatcher); | 60 DCHECK(dispatcher); |
61 return dispatcher->EndSerializeAndClose( | 61 return dispatcher->EndSerializeAndClose(channel, destination, actual_size, |
62 channel, destination, actual_size, platform_handles); | 62 platform_handles); |
63 } | 63 } |
64 | 64 |
65 // static | 65 // static |
66 scoped_refptr<Dispatcher> Dispatcher::TransportDataAccess::Deserialize( | 66 scoped_refptr<Dispatcher> Dispatcher::TransportDataAccess::Deserialize( |
67 Channel* channel, | 67 Channel* channel, |
68 int32_t type, | 68 int32_t type, |
69 const void* source, | 69 const void* source, |
70 size_t size, | 70 size_t size, |
71 embedder::PlatformHandleVector* platform_handles) { | 71 embedder::PlatformHandleVector* platform_handles) { |
72 switch (static_cast<int32_t>(type)) { | 72 switch (static_cast<int32_t>(type)) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 DispatcherVector* dispatchers, | 123 DispatcherVector* dispatchers, |
124 uint32_t* num_dispatchers, | 124 uint32_t* num_dispatchers, |
125 MojoReadMessageFlags flags) { | 125 MojoReadMessageFlags flags) { |
126 DCHECK(!num_dispatchers || *num_dispatchers == 0 || | 126 DCHECK(!num_dispatchers || *num_dispatchers == 0 || |
127 (dispatchers && dispatchers->empty())); | 127 (dispatchers && dispatchers->empty())); |
128 | 128 |
129 base::AutoLock locker(lock_); | 129 base::AutoLock locker(lock_); |
130 if (is_closed_) | 130 if (is_closed_) |
131 return MOJO_RESULT_INVALID_ARGUMENT; | 131 return MOJO_RESULT_INVALID_ARGUMENT; |
132 | 132 |
133 return ReadMessageImplNoLock( | 133 return ReadMessageImplNoLock(bytes, num_bytes, dispatchers, num_dispatchers, |
134 bytes, num_bytes, dispatchers, num_dispatchers, flags); | 134 flags); |
135 } | 135 } |
136 | 136 |
137 MojoResult Dispatcher::WriteData(UserPointer<const void> elements, | 137 MojoResult Dispatcher::WriteData(UserPointer<const void> elements, |
138 UserPointer<uint32_t> num_bytes, | 138 UserPointer<uint32_t> num_bytes, |
139 MojoWriteDataFlags flags) { | 139 MojoWriteDataFlags flags) { |
140 base::AutoLock locker(lock_); | 140 base::AutoLock locker(lock_); |
141 if (is_closed_) | 141 if (is_closed_) |
142 return MOJO_RESULT_INVALID_ARGUMENT; | 142 return MOJO_RESULT_INVALID_ARGUMENT; |
143 | 143 |
144 return WriteDataImplNoLock(elements, num_bytes, flags); | 144 return WriteDataImplNoLock(elements, num_bytes, flags); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 // shouldn't be in |Core|'s handle table. | 467 // shouldn't be in |Core|'s handle table. |
468 is_closed_ = true; | 468 is_closed_ = true; |
469 | 469 |
470 #if !defined(NDEBUG) | 470 #if !defined(NDEBUG) |
471 // See the comment above |EndSerializeAndCloseImplNoLock()|. In brief: Locking | 471 // See the comment above |EndSerializeAndCloseImplNoLock()|. In brief: Locking |
472 // isn't actually needed, but we need to satisfy assertions (which we don't | 472 // isn't actually needed, but we need to satisfy assertions (which we don't |
473 // want to remove or weaken). | 473 // want to remove or weaken). |
474 base::AutoLock locker(lock_); | 474 base::AutoLock locker(lock_); |
475 #endif | 475 #endif |
476 | 476 |
477 return EndSerializeAndCloseImplNoLock( | 477 return EndSerializeAndCloseImplNoLock(channel, destination, actual_size, |
478 channel, destination, actual_size, platform_handles); | 478 platform_handles); |
479 } | 479 } |
480 | 480 |
481 // DispatcherTransport --------------------------------------------------------- | 481 // DispatcherTransport --------------------------------------------------------- |
482 | 482 |
483 void DispatcherTransport::End() { | 483 void DispatcherTransport::End() { |
484 DCHECK(dispatcher_); | 484 DCHECK(dispatcher_); |
485 dispatcher_->lock_.Release(); | 485 dispatcher_->lock_.Release(); |
486 dispatcher_ = nullptr; | 486 dispatcher_ = nullptr; |
487 } | 487 } |
488 | 488 |
489 } // namespace system | 489 } // namespace system |
490 } // namespace mojo | 490 } // namespace mojo |
OLD | NEW |