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_CHILD_TOKEN_SERIALIZER_WIN_H_ |
| 6 #define MOJO_EDK_SYSTEM_CHILD_TOKEN_SERIALIZER_WIN_H_ |
| 7 |
| 8 #include "base/memory/singleton.h" |
| 9 #include "base/synchronization/lock_impl.h" |
| 10 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 11 #include "mojo/edk/system/system_impl_export.h" |
| 12 #include "mojo/edk/system/token_serializer_win.h" |
| 13 |
| 14 namespace mojo { |
| 15 namespace edk { |
| 16 struct TokenSerializerMessage; |
| 17 |
| 18 // An implementation of TokenSerializer used in (sandboxed) child processes. It |
| 19 // talks over sync IPCs to the (unsandboxed) parent process (specifically, |
| 20 // ParentTokenSerializer) to convert handles to tokens and vice versa. |
| 21 class MOJO_SYSTEM_IMPL_EXPORT ChildTokenSerializer : public TokenSerializer { |
| 22 public: |
| 23 static ChildTokenSerializer* GetInstance(); |
| 24 |
| 25 // Passes the platform handle that is used to talk to ParentTokenSerializer. |
| 26 void SetParentTokenSerializerHandle(ScopedPlatformHandle handle); |
| 27 |
| 28 // TokenSerializer implementation: |
| 29 void CreatePlatformChannelPair(ScopedPlatformHandle* server, |
| 30 ScopedPlatformHandle* client) override; |
| 31 void HandleToToken(const PlatformHandle* platform_handles, |
| 32 size_t count, |
| 33 uint64_t* tokens) override; |
| 34 void TokenToHandle(const uint64_t* tokens, |
| 35 size_t count, |
| 36 PlatformHandle* handles) override; |
| 37 |
| 38 private: |
| 39 friend struct base::DefaultSingletonTraits<ChildTokenSerializer>; |
| 40 |
| 41 ChildTokenSerializer(); |
| 42 ~ChildTokenSerializer() override; |
| 43 |
| 44 // Helper method to write the given message and read back the result. |
| 45 bool WriteAndReadResponse(TokenSerializerMessage* message, |
| 46 void* response, |
| 47 uint32_t response_size); |
| 48 |
| 49 // Guards access to below. |
| 50 // We use LockImpl instead of Lock because the latter adds thread checking |
| 51 // that we don't want (since we lock in the constructor and unlock on another |
| 52 // thread. |
| 53 base::internal::LockImpl lock_; |
| 54 ScopedPlatformHandle handle_; |
| 55 }; |
| 56 |
| 57 } // namespace edk |
| 58 } // namespace mojo |
| 59 |
| 60 #endif // MOJO_EDK_SYSTEM_CHILD_TOKEN_SERIALIZER_WIN_H_ |
OLD | NEW |