• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef MOJO_EDK_SYSTEM_BROKER_HOST_H_
6 #define MOJO_EDK_SYSTEM_BROKER_HOST_H_
7 
8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h"
10 #include "mojo/edk/embedder/scoped_platform_handle.h"
11 #include "mojo/edk/system/channel.h"
12 
13 namespace mojo {
14 namespace edk {
15 
16 // The BrokerHost is a channel to the child process, which services synchronous
17 // IPCs.
18 class BrokerHost : public Channel::Delegate,
19                    public base::MessageLoop::DestructionObserver {
20  public:
21   explicit BrokerHost(ScopedPlatformHandle platform_handle);
22 
23   // Send |handle| to the child, to be used to establish a NodeChannel to us.
24   void SendChannel(ScopedPlatformHandle handle);
25 
26  private:
27   ~BrokerHost() override;
28 
29   // Channel::Delegate:
30   void OnChannelMessage(const void* payload,
31                         size_t payload_size,
32                         ScopedPlatformHandleVectorPtr handles) override;
33   void OnChannelError() override;
34 
35   // base::MessageLoop::DestructionObserver:
36   void WillDestroyCurrentMessageLoop() override;
37 
38   void OnBufferRequest(size_t num_bytes);
39 
40   scoped_refptr<Channel> channel_;
41 
42   DISALLOW_COPY_AND_ASSIGN(BrokerHost);
43 };
44 
45 }  // namespace edk
46 }  // namespace mojo
47 
48 #endif  // MOJO_EDK_SYSTEM_BROKER_HOST_H_
49