Chromium Code Reviews| 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_PARENT_TOKEN_SERIALIZER_WIN_H_ | 5 #ifndef MOJO_EDK_SYSTEM_CHILD_BROKER_HOST_H_ |
| 6 #define MOJO_EDK_SYSTEM_PARENT_TOKEN_SERIALIZER_WIN_H_ | 6 #define MOJO_EDK_SYSTEM_CHILD_BROKER_HOST_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/process/process_handle.h" | |
| 12 #include "mojo/edk/embedder/scoped_platform_handle.h" | 13 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 13 #include "mojo/edk/system/system_impl_export.h" | 14 #include "mojo/edk/system/system_impl_export.h" |
| 14 | 15 |
| 15 namespace mojo { | 16 namespace mojo { |
| 16 namespace edk { | 17 namespace edk { |
| 17 | 18 |
| 18 // Responds to requests from a child process to exchange handles to tokens and | 19 // Responds to requests from a child process to exchange handles to tokens and |
| 19 // vice versa. There is one object of this class per child process host object. | 20 // vice versa. There is one object of this class per child process host object. |
| 20 // This object will delete itself when it notices that the pipe is broken. | 21 // This object will delete itself when it notices that the pipe is broken. |
| 21 class MOJO_SYSTEM_IMPL_EXPORT ParentTokenSerializer | 22 class MOJO_SYSTEM_IMPL_EXPORT ChildBrokerHost |
| 23 #if defined(OS_WIN) | |
|
yzshen1
2015/11/25 16:47:09
I think it will be cleaner if we have ChildBrokerH
jam
2015/11/25 16:56:09
I was waiting for the change after this, to implem
| |
| 22 : NON_EXPORTED_BASE(public base::MessageLoopForIO::IOHandler) { | 24 : NON_EXPORTED_BASE(public base::MessageLoopForIO::IOHandler) { |
| 25 #else | |
| 26 { | |
| 27 #endif | |
| 23 public: | 28 public: |
| 24 // |child_process| is a handle to the child process. It's not owned by this | 29 // |child_process| is a handle to the child process. It's not owned by this |
| 25 // class but is guaranteed to be alive as long as the child process is | 30 // class but is guaranteed to be alive as long as the child process is |
| 26 // running. |pipe| is a handle to the communication pipe to the child process, | 31 // running. |pipe| is a handle to the communication pipe to the child process, |
| 27 // which is generated inside mojo::edk::ChildProcessLaunched. It is owned by | 32 // which is generated inside mojo::edk::ChildProcessLaunched. It is owned by |
| 28 // this class. | 33 // this class. |
| 29 ParentTokenSerializer(HANDLE child_process, ScopedPlatformHandle pipe); | 34 ChildBrokerHost(base::ProcessHandle child_process, ScopedPlatformHandle pipe); |
| 30 | 35 |
| 31 private: | 36 private: |
| 32 ~ParentTokenSerializer() override; | 37 virtual ~ChildBrokerHost(); |
|
hans
2015/11/25 20:35:41
The Win-Clang style plugin complains about this on
jam
2015/11/25 21:28:57
I'll fix it. Is there a trybot I can use to verify
Nico
2015/11/25 22:03:33
win_clang_dbg, but it's opt-in and backed by a mea
| |
| 33 | 38 |
| 34 void RegisterIOHandler(); | 39 void RegisterIOHandler(); |
| 35 void BeginRead(); | 40 void BeginRead(); |
| 36 | 41 |
| 42 #if defined(OS_WIN) | |
| 37 void OnIOCompleted(base::MessageLoopForIO::IOContext* context, | 43 void OnIOCompleted(base::MessageLoopForIO::IOContext* context, |
| 38 DWORD bytes_transferred, | 44 DWORD bytes_transferred, |
| 39 DWORD error) override; | 45 DWORD error) override; |
| 40 | 46 |
| 41 // Helper wrappers around DuplicateHandle. | 47 // Helper wrappers around DuplicateHandle. |
| 42 HANDLE DuplicateToChild(HANDLE handle); | 48 HANDLE DuplicateToChild(HANDLE handle); |
| 43 HANDLE DuplicateFromChild(HANDLE handle); | 49 HANDLE DuplicateFromChild(HANDLE handle); |
| 50 #endif | |
| 44 | 51 |
| 45 HANDLE child_process_; | 52 base::ProcessHandle child_process_; |
| 46 ScopedPlatformHandle pipe_; | 53 ScopedPlatformHandle pipe_; |
| 54 | |
| 55 #if defined(OS_WIN) | |
| 47 base::MessageLoopForIO::IOContext read_context_; | 56 base::MessageLoopForIO::IOContext read_context_; |
| 48 base::MessageLoopForIO::IOContext write_context_; | 57 base::MessageLoopForIO::IOContext write_context_; |
| 58 #endif | |
| 49 | 59 |
| 50 std::vector<char> read_data_; | 60 std::vector<char> read_data_; |
| 51 // How many bytes in read_data_ we already read. | 61 // How many bytes in read_data_ we already read. |
| 52 uint32_t num_bytes_read_; | 62 uint32_t num_bytes_read_; |
| 53 std::vector<char> write_data_; | 63 std::vector<char> write_data_; |
| 54 }; | 64 }; |
| 55 | 65 |
| 56 } // namespace edk | 66 } // namespace edk |
| 57 } // namespace mojo | 67 } // namespace mojo |
| 58 | 68 |
| 59 #endif // MOJO_EDK_SYSTEM_PARENT_TOKEN_SERIALIZER_WIN_H_ | 69 #endif // MOJO_EDK_SYSTEM_CHILD_BROKER_HOST_H_ |
| OLD | NEW |