| 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/system/dispatcher.h" | 5 #include "mojo/system/dispatcher.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "mojo/system/constants.h" | 8 #include "mojo/system/constants.h" |
| 9 #include "mojo/system/message_pipe_dispatcher.h" | 9 #include "mojo/system/message_pipe_dispatcher.h" |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 // We shouldn't race with things that close dispatchers, since closing can | 34 // We shouldn't race with things that close dispatchers, since closing can |
| 35 // only take place either under |handle_table_lock_| or when the handle is | 35 // only take place either under |handle_table_lock_| or when the handle is |
| 36 // marked as busy. | 36 // marked as busy. |
| 37 DCHECK(!dispatcher->is_closed_); | 37 DCHECK(!dispatcher->is_closed_); |
| 38 | 38 |
| 39 return DispatcherTransport(dispatcher); | 39 return DispatcherTransport(dispatcher); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // static | 42 // static |
| 43 void Dispatcher::MessageInTransitAccess::StartSerialize( | 43 void Dispatcher::TransportDataAccess::StartSerialize( |
| 44 Dispatcher* dispatcher, | 44 Dispatcher* dispatcher, |
| 45 Channel* channel, | 45 Channel* channel, |
| 46 size_t* max_size, | 46 size_t* max_size, |
| 47 size_t* max_platform_handles) { | 47 size_t* max_platform_handles) { |
| 48 DCHECK(dispatcher); | 48 DCHECK(dispatcher); |
| 49 dispatcher->StartSerialize(channel, max_size, max_platform_handles); | 49 dispatcher->StartSerialize(channel, max_size, max_platform_handles); |
| 50 } | 50 } |
| 51 | 51 |
| 52 // static | 52 // static |
| 53 bool Dispatcher::MessageInTransitAccess::EndSerializeAndClose( | 53 bool Dispatcher::TransportDataAccess::EndSerializeAndClose( |
| 54 Dispatcher* dispatcher, | 54 Dispatcher* dispatcher, |
| 55 Channel* channel, | 55 Channel* channel, |
| 56 void* destination, | 56 void* destination, |
| 57 size_t* actual_size, | 57 size_t* actual_size, |
| 58 std::vector<embedder::PlatformHandle>* platform_handles) { | 58 std::vector<embedder::PlatformHandle>* platform_handles) { |
| 59 DCHECK(dispatcher); | 59 DCHECK(dispatcher); |
| 60 return dispatcher->EndSerializeAndClose(channel, destination, actual_size, | 60 return dispatcher->EndSerializeAndClose(channel, destination, actual_size, |
| 61 platform_handles); | 61 platform_handles); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // static | 64 // static |
| 65 scoped_refptr<Dispatcher> Dispatcher::MessageInTransitAccess::Deserialize( | 65 scoped_refptr<Dispatcher> Dispatcher::TransportDataAccess::Deserialize( |
| 66 Channel* channel, | 66 Channel* channel, |
| 67 int32_t type, | 67 int32_t type, |
| 68 const void* source, | 68 const void* source, |
| 69 size_t size) { | 69 size_t size) { |
| 70 switch (static_cast<int32_t>(type)) { | 70 switch (static_cast<int32_t>(type)) { |
| 71 case kTypeUnknown: | 71 case kTypeUnknown: |
| 72 DVLOG(2) << "Deserializing invalid handle"; | 72 DVLOG(2) << "Deserializing invalid handle"; |
| 73 return scoped_refptr<Dispatcher>(); | 73 return scoped_refptr<Dispatcher>(); |
| 74 case kTypeMessagePipe: | 74 case kTypeMessagePipe: |
| 75 return scoped_refptr<Dispatcher>( | 75 return scoped_refptr<Dispatcher>( |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 // DispatcherTransport --------------------------------------------------------- | 444 // DispatcherTransport --------------------------------------------------------- |
| 445 | 445 |
| 446 void DispatcherTransport::End() { | 446 void DispatcherTransport::End() { |
| 447 DCHECK(dispatcher_); | 447 DCHECK(dispatcher_); |
| 448 dispatcher_->lock_.Release(); | 448 dispatcher_->lock_.Release(); |
| 449 dispatcher_ = NULL; | 449 dispatcher_ = NULL; |
| 450 } | 450 } |
| 451 | 451 |
| 452 } // namespace system | 452 } // namespace system |
| 453 } // namespace mojo | 453 } // namespace mojo |
| OLD | NEW |