forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipe_control_message_handler.h
55 lines (40 loc) · 1.75 KB
/
pipe_control_message_handler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// 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.
#ifndef MOJO_PUBLIC_CPP_BINDINGS_PIPE_CONTROL_MESSAGE_HANDLER_H_
#define MOJO_PUBLIC_CPP_BINDINGS_PIPE_CONTROL_MESSAGE_HANDLER_H_
#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
: public MessageReceiver {
public:
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;
private:
// |message| must have passed message header validation.
bool Validate(Message* message);
bool RunOrClosePipe(Message* message);
std::string description_;
PipeControlMessageHandlerDelegate* const delegate_;
DISALLOW_COPY_AND_ASSIGN(PipeControlMessageHandler);
};
} // namespace mojo
#endif // MOJO_PUBLIC_CPP_BINDINGS_PIPE_CONTROL_MESSAGE_HANDLER_H_