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

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

Issue 1387963004: Create a broker interface for the new Mojo EDK so that the browser can create and duplicate messa... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: presubmit whitespace error 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
OLDNEW
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698