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

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

Issue 1465183005: Rename mojo::TokenSerializer to mojo::Broker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix win component 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
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_PARENT_TOKEN_SERIALIZER_STATE_WIN_H_ 5 #ifndef MOJO_EDK_SYSTEM_BROKER_STATE_H_
6 #define MOJO_EDK_SYSTEM_PARENT_TOKEN_SERIALIZER_STATE_WIN_H_ 6 #define MOJO_EDK_SYSTEM_BROKER_STATE_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "mojo/edk/embedder/scoped_platform_handle.h" 13 #include "mojo/edk/embedder/scoped_platform_handle.h"
14 #include "mojo/edk/system/broker.h"
14 #include "mojo/edk/system/system_impl_export.h" 15 #include "mojo/edk/system/system_impl_export.h"
15 #include "mojo/edk/system/token_serializer_win.h"
16 16
17 namespace mojo { 17 namespace mojo {
18 namespace edk { 18 namespace edk {
19 19
20 // Common state that has to live in a parent process on Windows. There is one 20 // Common broker state that has to live in a parent process. There is one
21 // instance of this class in the parent process. This class also implements the 21 // instance of this class in the parent process. This class implements the
22 // TokenSerializer interface for use by code in the parent process. 22 // Broker interface for use by code in the parent process as well.
23 class MOJO_SYSTEM_IMPL_EXPORT ParentTokenSerializerState 23 class MOJO_SYSTEM_IMPL_EXPORT BrokerState : NON_EXPORTED_BASE(public Broker) {
24 : NON_EXPORTED_BASE(public TokenSerializer) {
25 public: 24 public:
26 static ParentTokenSerializerState* GetInstance(); 25 static BrokerState* GetInstance();
27 26
28 // TokenSerializer implementation. 27 // Broker implementation.
28 #if defined(OS_WIN)
29 void CreatePlatformChannelPair(ScopedPlatformHandle* server, 29 void CreatePlatformChannelPair(ScopedPlatformHandle* server,
30 ScopedPlatformHandle* client) override; 30 ScopedPlatformHandle* client) override;
31 void HandleToToken(const PlatformHandle* platform_handles, 31 void HandleToToken(const PlatformHandle* platform_handles,
32 size_t count, 32 size_t count,
33 uint64_t* tokens) override; 33 uint64_t* tokens) override;
34 void TokenToHandle(const uint64_t* tokens, 34 void TokenToHandle(const uint64_t* tokens,
35 size_t count, 35 size_t count,
36 PlatformHandle* handles) override; 36 PlatformHandle* handles) override;
37 #endif
37 38
38 scoped_refptr<base::TaskRunner> token_serialize_thread() { 39 scoped_refptr<base::TaskRunner> broker_thread() {
39 return token_serialize_thread_.task_runner(); 40 return broker_thread_.task_runner();
40 } 41 }
41 42
42 private: 43 private:
43 friend struct base::DefaultSingletonTraits<ParentTokenSerializerState>; 44 friend struct base::DefaultSingletonTraits<BrokerState>;
44 45
45 ParentTokenSerializerState(); 46 BrokerState();
46 ~ParentTokenSerializerState() override; 47 ~BrokerState() override;
47 48
48 // A separate thread to handle sync IPCs from child processes for exchanging 49 // A separate thread to handle sync IPCs from child processes for exchanging
49 // platform handles with tokens. We use a separate thread because latency is 50 // platform handles with tokens. We use a separate thread because latency is
50 // very sensitive (since any time a pipe is created or sent, a child process 51 // very sensitive (since any time a pipe is created or sent, a child process
51 // makes a sync call to this class). 52 // makes a sync call to this class).
52 base::Thread token_serialize_thread_; 53 base::Thread broker_thread_;
53 54
55 #if defined(OS_WIN)
54 // Used in the parent (unsandboxed) process to hold a mapping between HANDLES 56 // Used in the parent (unsandboxed) process to hold a mapping between HANDLES
55 // and tokens. When a child process wants to send a HANDLE to another process, 57 // and tokens. When a child process wants to send a HANDLE to another process,
56 // it exchanges it to a token and then the other process exchanges that token 58 // it exchanges it to a token and then the other process exchanges that token
57 // back to a HANDLE. 59 // back to a HANDLE.
58 base::Lock lock_; // Guards access to below. 60 base::Lock lock_; // Guards access to below.
59 base::hash_map<uint64_t, HANDLE> token_map_; 61 base::hash_map<uint64_t, HANDLE> token_map_;
62 #endif
60 }; 63 };
61 64
62 } // namespace edk 65 } // namespace edk
63 } // namespace mojo 66 } // namespace mojo
64 67
65 #endif // MOJO_EDK_SYSTEM_PARENT_TOKEN_SERIALIZER_STATE_WIN_H_ 68 #endif // MOJO_EDK_SYSTEM_BROKER_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698