OLD | NEW |
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_TOKEN_SERIALIZER_WIN_H_ | 5 #ifndef MOJO_EDK_SYSTEM_BROKER_H_ |
6 #define MOJO_EDK_SYSTEM_TOKEN_SERIALIZER_WIN_H_ | 6 #define MOJO_EDK_SYSTEM_BROKER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "mojo/edk/embedder/scoped_platform_handle.h" | 11 #include "mojo/edk/embedder/scoped_platform_handle.h" |
12 | 12 |
13 namespace mojo { | 13 namespace mojo { |
14 namespace edk { | 14 namespace edk { |
15 | 15 |
16 // An interface for serializing a Mojo handle to memory. A child process will | 16 // An interface for communicating to a central "broker" process from each |
17 // have to make sync calls to the parent process. It is safe to call from any | 17 // process using the EDK. This is needed because child processes are sandboxed. |
18 // thread. | 18 // It is safe to call from any thread. |
19 class MOJO_SYSTEM_IMPL_EXPORT TokenSerializer { | 19 class MOJO_SYSTEM_IMPL_EXPORT Broker { |
20 public: | 20 public: |
21 virtual ~TokenSerializer() {} | 21 virtual ~Broker() {} |
| 22 |
| 23 #if defined(OS_WIN) |
| 24 // All these methods are needed because sandboxed Windows processes can't |
| 25 // create named pipes or duplicate handles. |
22 | 26 |
23 // Create a PlatformChannelPair. | 27 // Create a PlatformChannelPair. |
24 virtual void CreatePlatformChannelPair(ScopedPlatformHandle* server, | 28 virtual void CreatePlatformChannelPair(ScopedPlatformHandle* server, |
25 ScopedPlatformHandle* client) = 0; | 29 ScopedPlatformHandle* client) = 0; |
26 | 30 |
27 // Converts the given platform handles to tokens. | 31 // Converts the given platform handles to tokens. |
28 // |tokens| should point to memory that is sizeof(uint64_t) * count; | 32 // |tokens| should point to memory that is sizeof(uint64_t) * count; |
29 virtual void HandleToToken(const PlatformHandle* platform_handles, | 33 virtual void HandleToToken(const PlatformHandle* platform_handles, |
30 size_t count, | 34 size_t count, |
31 uint64_t* tokens) = 0; | 35 uint64_t* tokens) = 0; |
32 | 36 |
33 // Converts the given tokens to platformhandles. | 37 // Converts the given tokens to platformhandles. |
34 // |handles| should point to memory that is sizeof(HANDLE) * count; | 38 // |handles| should point to memory that is sizeof(HANDLE) * count; |
35 virtual void TokenToHandle(const uint64_t* tokens, | 39 virtual void TokenToHandle(const uint64_t* tokens, |
36 size_t count, | 40 size_t count, |
37 PlatformHandle* handles) = 0; | 41 PlatformHandle* handles) = 0; |
| 42 #endif |
38 }; | 43 }; |
39 | 44 |
40 } // namespace edk | 45 } // namespace edk |
41 } // namespace mojo | 46 } // namespace mojo |
42 | 47 |
43 #endif // MOJO_EDK_SYSTEM_TOKEN_SERIALIZER_WIN_H_ | 48 #endif // MOJO_EDK_SYSTEM_BROKER_H_ |
OLD | NEW |