| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_EDK_SYSTEM_BROKER_H_ | |
| 6 #define MOJO_EDK_SYSTEM_BROKER_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 #include <stdint.h> | |
| 10 | |
| 11 #include "mojo/edk/embedder/scoped_platform_handle.h" | |
| 12 | |
| 13 namespace mojo { | |
| 14 namespace edk { | |
| 15 class MessagePipeDispatcher; | |
| 16 class RawChannel; | |
| 17 | |
| 18 // An interface for communicating to a central "broker" process from each | |
| 19 // process using the EDK. It serves two purposes: | |
| 20 // 1) Windows only: brokering to help child processes as they can't create | |
| 21 // named pipes or duplicate handles. | |
| 22 // 2) All platforms: support multiplexed messages pipes. | |
| 23 | |
| 24 class MOJO_SYSTEM_IMPL_EXPORT Broker { | |
| 25 public: | |
| 26 virtual ~Broker() {} | |
| 27 | |
| 28 #if defined(OS_WIN) | |
| 29 // It is safe to call these three methods from any thread. | |
| 30 | |
| 31 // Create a PlatformChannelPair. | |
| 32 virtual void CreatePlatformChannelPair(ScopedPlatformHandle* server, | |
| 33 ScopedPlatformHandle* client) = 0; | |
| 34 | |
| 35 // Converts the given platform handles to tokens. | |
| 36 // |tokens| should point to memory that is sizeof(uint64_t) * count; | |
| 37 virtual void HandleToToken(const PlatformHandle* platform_handles, | |
| 38 size_t count, | |
| 39 uint64_t* tokens) = 0; | |
| 40 | |
| 41 // Converts the given tokens to platformhandles. | |
| 42 // |handles| should point to memory that is sizeof(HANDLE) * count; | |
| 43 virtual void TokenToHandle(const uint64_t* tokens, | |
| 44 size_t count, | |
| 45 PlatformHandle* handles) = 0; | |
| 46 #endif | |
| 47 | |
| 48 // Multiplexing related methods. They are called from the IO thread only. | |
| 49 | |
| 50 // Called by |message_pipe| so that it receives messages for the given | |
| 51 // globally unique |pipe_id|. When the connection is established, | |
| 52 // MessagePipeDispatcher::GotNonTransferableChannel is called with the channel | |
| 53 // that it can use for sending messages. | |
| 54 virtual void ConnectMessagePipe(uint64_t pipe_id, | |
| 55 MessagePipeDispatcher* message_pipe) = 0; | |
| 56 | |
| 57 // Called by |message_pipe| when it's closing so that its route can be | |
| 58 // unregistered. | |
| 59 // It's ok to call this from a callback (i.e. from OnError or | |
| 60 // GotNonTransferableChannel). | |
| 61 virtual void CloseMessagePipe(uint64_t pipe_id, | |
| 62 MessagePipeDispatcher* message_pipe) = 0; | |
| 63 }; | |
| 64 | |
| 65 } // namespace edk | |
| 66 } // namespace mojo | |
| 67 | |
| 68 #endif // MOJO_EDK_SYSTEM_BROKER_H_ | |
| OLD | NEW |