| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_BROKER_HOST_H_ | 5 #ifndef MOJO_EDK_SYSTEM_BROKER_HOST_H_ |
| 6 #define MOJO_EDK_SYSTEM_BROKER_HOST_H_ | 6 #define MOJO_EDK_SYSTEM_BROKER_HOST_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/process/process_handle.h" |
| 11 #include "mojo/edk/embedder/platform_handle_vector.h" |
| 10 #include "mojo/edk/embedder/scoped_platform_handle.h" | 12 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 11 #include "mojo/edk/system/channel.h" | 13 #include "mojo/edk/system/channel.h" |
| 12 | 14 |
| 13 namespace mojo { | 15 namespace mojo { |
| 14 namespace edk { | 16 namespace edk { |
| 15 | 17 |
| 16 // The BrokerHost is a channel to the child process, which services synchronous | 18 // The BrokerHost is a channel to the child process, which services synchronous |
| 17 // IPCs. | 19 // IPCs. |
| 18 class BrokerHost : public Channel::Delegate, | 20 class BrokerHost : public Channel::Delegate, |
| 19 public base::MessageLoop::DestructionObserver { | 21 public base::MessageLoop::DestructionObserver { |
| 20 public: | 22 public: |
| 21 explicit BrokerHost(ScopedPlatformHandle platform_handle); | 23 BrokerHost(base::ProcessHandle client_process, ScopedPlatformHandle handle); |
| 22 | 24 |
| 23 // Send |handle| to the child, to be used to establish a NodeChannel to us. | 25 // Send |handle| to the child, to be used to establish a NodeChannel to us. |
| 24 void SendChannel(ScopedPlatformHandle handle); | 26 void SendChannel(ScopedPlatformHandle handle); |
| 25 | 27 |
| 26 private: | 28 private: |
| 27 ~BrokerHost() override; | 29 ~BrokerHost() override; |
| 28 | 30 |
| 31 void PrepareHandlesForClient(PlatformHandleVector* handles); |
| 32 |
| 29 // Channel::Delegate: | 33 // Channel::Delegate: |
| 30 void OnChannelMessage(const void* payload, | 34 void OnChannelMessage(const void* payload, |
| 31 size_t payload_size, | 35 size_t payload_size, |
| 32 ScopedPlatformHandleVectorPtr handles) override; | 36 ScopedPlatformHandleVectorPtr handles) override; |
| 33 void OnChannelError() override; | 37 void OnChannelError() override; |
| 34 | 38 |
| 35 // base::MessageLoop::DestructionObserver: | 39 // base::MessageLoop::DestructionObserver: |
| 36 void WillDestroyCurrentMessageLoop() override; | 40 void WillDestroyCurrentMessageLoop() override; |
| 37 | 41 |
| 38 void OnBufferRequest(size_t num_bytes); | 42 void OnBufferRequest(size_t num_bytes); |
| 39 | 43 |
| 44 #if defined(OS_WIN) |
| 45 base::ProcessHandle client_process_; |
| 46 #endif |
| 47 |
| 40 scoped_refptr<Channel> channel_; | 48 scoped_refptr<Channel> channel_; |
| 41 | 49 |
| 42 DISALLOW_COPY_AND_ASSIGN(BrokerHost); | 50 DISALLOW_COPY_AND_ASSIGN(BrokerHost); |
| 43 }; | 51 }; |
| 44 | 52 |
| 45 } // namespace edk | 53 } // namespace edk |
| 46 } // namespace mojo | 54 } // namespace mojo |
| 47 | 55 |
| 48 #endif // MOJO_EDK_SYSTEM_BROKER_HOST_H_ | 56 #endif // MOJO_EDK_SYSTEM_BROKER_HOST_H_ |
| OLD | NEW |