Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: mojo/edk/system/broker.h

Issue 1488853002: Add multiplexing of message pipes in the new EDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tsepez review comments Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/system/BUILD.gn ('k') | mojo/edk/system/broker_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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_EDK_SYSTEM_BROKER_H_ 5 #ifndef MOJO_EDK_SYSTEM_BROKER_H_
6 #define MOJO_EDK_SYSTEM_BROKER_H_ 6 #define MOJO_EDK_SYSTEM_BROKER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <vector>
10 9
11 #include "mojo/edk/embedder/scoped_platform_handle.h" 10 #include "mojo/edk/embedder/scoped_platform_handle.h"
12 11
13 namespace mojo { 12 namespace mojo {
14 namespace edk { 13 namespace edk {
14 class MessagePipeDispatcher;
15 class RawChannel;
15 16
16 // An interface for communicating to a central "broker" process from each 17 // An interface for communicating to a central "broker" process from each
17 // process using the EDK. This is needed because child processes are sandboxed. 18 // process using the EDK. It serves two purposes:
18 // It is safe to call from any thread. 19 // 1) Windows only: brokering to help child processes as they can't create
20 // named pipes or duplicate handles.
21 // 2) All platforms: support multiplexed messages pipes.
22
19 class MOJO_SYSTEM_IMPL_EXPORT Broker { 23 class MOJO_SYSTEM_IMPL_EXPORT Broker {
20 public: 24 public:
21 virtual ~Broker() {} 25 virtual ~Broker() {}
22 26
23 #if defined(OS_WIN) 27 #if defined(OS_WIN)
24 // All these methods are needed because sandboxed Windows processes can't 28 // It is safe to call these three methods from any thread.
25 // create named pipes or duplicate handles.
26 29
27 // Create a PlatformChannelPair. 30 // Create a PlatformChannelPair.
28 virtual void CreatePlatformChannelPair(ScopedPlatformHandle* server, 31 virtual void CreatePlatformChannelPair(ScopedPlatformHandle* server,
29 ScopedPlatformHandle* client) = 0; 32 ScopedPlatformHandle* client) = 0;
30 33
31 // Converts the given platform handles to tokens. 34 // Converts the given platform handles to tokens.
32 // |tokens| should point to memory that is sizeof(uint64_t) * count; 35 // |tokens| should point to memory that is sizeof(uint64_t) * count;
33 virtual void HandleToToken(const PlatformHandle* platform_handles, 36 virtual void HandleToToken(const PlatformHandle* platform_handles,
34 size_t count, 37 size_t count,
35 uint64_t* tokens) = 0; 38 uint64_t* tokens) = 0;
36 39
37 // Converts the given tokens to platformhandles. 40 // Converts the given tokens to platformhandles.
38 // |handles| should point to memory that is sizeof(HANDLE) * count; 41 // |handles| should point to memory that is sizeof(HANDLE) * count;
39 virtual void TokenToHandle(const uint64_t* tokens, 42 virtual void TokenToHandle(const uint64_t* tokens,
40 size_t count, 43 size_t count,
41 PlatformHandle* handles) = 0; 44 PlatformHandle* handles) = 0;
42 #endif 45 #endif
46
47 // Multiplexing related methods. They are called from the IO thread only.
48
49 // Called by |message_pipe| so that it receives messages for the given
50 // globally unique |pipe_id|. When the connection is established,
51 // MessagePipeDispatcher::GotNonTransferableChannel is called with the channel
52 // that it can use for sending messages.
53 virtual void ConnectMessagePipe(uint64_t pipe_id,
54 MessagePipeDispatcher* message_pipe) = 0;
55
56 // Called by |message_pipe| when it's closing so that its route can be
57 // unregistered.
58 virtual void CloseMessagePipe(uint64_t pipe_id,
59 MessagePipeDispatcher* message_pipe) = 0;
43 }; 60 };
44 61
45 } // namespace edk 62 } // namespace edk
46 } // namespace mojo 63 } // namespace mojo
47 64
48 #endif // MOJO_EDK_SYSTEM_BROKER_H_ 65 #endif // MOJO_EDK_SYSTEM_BROKER_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/BUILD.gn ('k') | mojo/edk/system/broker_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698