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