| 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/data_pipe_consumer_dispatcher.h" | 9 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" |
| 10 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" | 10 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 platform_handles); | 64 platform_handles); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // static | 67 // static |
| 68 scoped_refptr<Dispatcher> Dispatcher::TransportDataAccess::Deserialize( | 68 scoped_refptr<Dispatcher> Dispatcher::TransportDataAccess::Deserialize( |
| 69 Channel* channel, | 69 Channel* channel, |
| 70 int32_t type, | 70 int32_t type, |
| 71 const void* source, | 71 const void* source, |
| 72 size_t size, | 72 size_t size, |
| 73 embedder::PlatformHandleVector* platform_handles) { | 73 embedder::PlatformHandleVector* platform_handles) { |
| 74 switch (static_cast<int32_t>(type)) { | 74 switch (static_cast<Dispatcher::Type>(type)) { |
| 75 case kTypeUnknown: | 75 case Type::UNKNOWN: |
| 76 DVLOG(2) << "Deserializing invalid handle"; | 76 DVLOG(2) << "Deserializing invalid handle"; |
| 77 return nullptr; | 77 return nullptr; |
| 78 case kTypeMessagePipe: | 78 case Type::MESSAGE_PIPE: |
| 79 return scoped_refptr<Dispatcher>( | 79 return scoped_refptr<Dispatcher>( |
| 80 MessagePipeDispatcher::Deserialize(channel, source, size)); | 80 MessagePipeDispatcher::Deserialize(channel, source, size)); |
| 81 case kTypeDataPipeProducer: | 81 case Type::DATA_PIPE_PRODUCER: |
| 82 return scoped_refptr<Dispatcher>( | 82 return scoped_refptr<Dispatcher>( |
| 83 DataPipeProducerDispatcher::Deserialize(channel, source, size)); | 83 DataPipeProducerDispatcher::Deserialize(channel, source, size)); |
| 84 case kTypeDataPipeConsumer: | 84 case Type::DATA_PIPE_CONSUMER: |
| 85 return scoped_refptr<Dispatcher>( | 85 return scoped_refptr<Dispatcher>( |
| 86 DataPipeConsumerDispatcher::Deserialize(channel, source, size)); | 86 DataPipeConsumerDispatcher::Deserialize(channel, source, size)); |
| 87 case kTypeSharedBuffer: | 87 case Type::SHARED_BUFFER: |
| 88 return scoped_refptr<Dispatcher>(SharedBufferDispatcher::Deserialize( | 88 return scoped_refptr<Dispatcher>(SharedBufferDispatcher::Deserialize( |
| 89 channel, source, size, platform_handles)); | 89 channel, source, size, platform_handles)); |
| 90 case kTypePlatformHandle: | 90 case Type::PLATFORM_HANDLE: |
| 91 return scoped_refptr<Dispatcher>(PlatformHandleDispatcher::Deserialize( | 91 return scoped_refptr<Dispatcher>(PlatformHandleDispatcher::Deserialize( |
| 92 channel, source, size, platform_handles)); | 92 channel, source, size, platform_handles)); |
| 93 } | 93 } |
| 94 LOG(WARNING) << "Unknown dispatcher type " << type; | 94 LOG(WARNING) << "Unknown dispatcher type " << type; |
| 95 return nullptr; | 95 return nullptr; |
| 96 } | 96 } |
| 97 | 97 |
| 98 MojoResult Dispatcher::Close() { | 98 MojoResult Dispatcher::Close() { |
| 99 base::AutoLock locker(lock_); | 99 base::AutoLock locker(lock_); |
| 100 if (is_closed_) | 100 if (is_closed_) |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 // DispatcherTransport --------------------------------------------------------- | 485 // DispatcherTransport --------------------------------------------------------- |
| 486 | 486 |
| 487 void DispatcherTransport::End() { | 487 void DispatcherTransport::End() { |
| 488 DCHECK(dispatcher_); | 488 DCHECK(dispatcher_); |
| 489 dispatcher_->lock_.Release(); | 489 dispatcher_->lock_.Release(); |
| 490 dispatcher_ = nullptr; | 490 dispatcher_ = nullptr; |
| 491 } | 491 } |
| 492 | 492 |
| 493 } // namespace system | 493 } // namespace system |
| 494 } // namespace mojo | 494 } // namespace mojo |
| OLD | NEW |