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
3 // found in the LICENSE file.
4 
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_PIPE_CONTROL_MESSAGE_HANDLER_DELEGATE_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_PIPE_CONTROL_MESSAGE_HANDLER_DELEGATE_H_
7 
8 #include "base/optional.h"
9 #include "mojo/public/cpp/bindings/disconnect_reason.h"
10 #include "mojo/public/cpp/bindings/interface_id.h"
11 
12 namespace mojo {
13 
14 class PipeControlMessageHandlerDelegate {
15  public:
16   // The implementation of the following methods should return false if the
17   // notification is unexpected. In that case, the user of this delegate is
18   // expected to close the message pipe.
19   virtual bool OnPeerAssociatedEndpointClosed(
20       InterfaceId id,
21       const base::Optional<DisconnectReason>& reason) = 0;
22 
23   // The implementation should cease dispatching messages until the
24   // |flush_pipe|'s peer is closed.
25   virtual bool WaitForFlushToComplete(ScopedMessagePipeHandle flush_pipe) = 0;
26 
27  protected:
~PipeControlMessageHandlerDelegate()28   virtual ~PipeControlMessageHandlerDelegate() {}
29 };
30 
31 }  // namespace mojo
32 
33 #endif  // MOJO_PUBLIC_CPP_BINDINGS_PIPE_CONTROL_MESSAGE_HANDLER_DELEGATE_H_
34