blob: a5c04da62720c8248109f4199983bc72a0ae4ac6 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/bindings_export.h"
#include "mojo/public/cpp/bindings/message.h"
namespace mojo {
class PipeControlMessageHandlerDelegate;
// Handler for messages defined in pipe_control_messages.mojom.
class MOJO_CPP_BINDINGS_EXPORT PipeControlMessageHandler
: NON_EXPORTED_BASE(public MessageReceiver) {
explicit PipeControlMessageHandler(
PipeControlMessageHandlerDelegate* delegate);
~PipeControlMessageHandler() override;
// Sets the description for this handler. Used only when reporting validation
// errors.
void SetDescription(const std::string& description);
// NOTE: |message| must have passed message header validation.
static bool IsPipeControlMessage(const Message* message);
// MessageReceiver implementation:
// NOTE: |message| must:
// - have passed message header validation; and
// - be a pipe control message (i.e., IsPipeControlMessage() returns true).
// If the method returns false, the message pipe should be closed.
bool Accept(Message* message) override;
// |message| must have passed message header validation.
bool Validate(Message* message);
bool RunOrClosePipe(Message* message);
std::string description_;
PipeControlMessageHandlerDelegate* const delegate_;
} // namespace mojo