Chromium Code Reviews| Index: content/public/common/presentation_connection_message.h |
| diff --git a/content/public/common/presentation_connection_message.h b/content/public/common/presentation_connection_message.h |
| index 646958e4dd41bfd8bc8aac6c6ead24fa6d15e397..46aad6095ec08477f7281c5086348619696e60c9 100644 |
| --- a/content/public/common/presentation_connection_message.h |
| +++ b/content/public/common/presentation_connection_message.h |
| @@ -5,33 +5,44 @@ |
| #ifndef CONTENT_PUBLIC_COMMON_PRESENTATION_CONNECTION_MESSAGE_H_ |
| #define CONTENT_PUBLIC_COMMON_PRESENTATION_CONNECTION_MESSAGE_H_ |
| +#include <stddef.h> // For size_t |
| #include <stdint.h> |
| -#include <memory> |
| #include <string> |
| #include <vector> |
| +#include "base/optional.h" |
| #include "content/common/content_export.h" |
| namespace content { |
| -enum PresentationMessageType { |
| - TEXT, |
| - BINARY, |
| -}; |
| +// The maximum number of bytes allowed in a presentation connection message. |
| +CONTENT_EXPORT extern const size_t kMaxPresentationConnectionMessageSize; |
| + |
| +// Represents a presentation connection message. If this is a text message, |
| +// |data| is null; otherwise, |message| is null. Empty messages are allowed. |
| -// Represents a presentation connection message. |
| -// If this is a text message, |data| is null; otherwise, |message| is null. |
| -// Empty messages are allowed. |
| struct CONTENT_EXPORT PresentationConnectionMessage { |
| public: |
| - explicit PresentationConnectionMessage(PresentationMessageType type); |
| + // Constructs a new, untyped message (for Mojo). These messages are not valid |
| + // and exactly one of |message| or |data| must be set. |
| + PresentationConnectionMessage(); |
| + // PCM is a move-only type. |
| + PresentationConnectionMessage(PresentationConnectionMessage&& other); |
| + // Constructs a text message from |message|. |
| + explicit PresentationConnectionMessage(std::string message); |
| + // Constructs a binary message from |data|. |
| + explicit PresentationConnectionMessage(std::vector<uint8_t> data); |
| ~PresentationConnectionMessage(); |
| bool is_binary() const; |
| - const PresentationMessageType type; |
| - std::string message; |
| - std::unique_ptr<std::vector<uint8_t>> data; |
| + |
| + bool operator==(const PresentationConnectionMessage& other) const; |
| + PresentationConnectionMessage& operator=( |
| + PresentationConnectionMessage&& other); |
| + |
| + base::Optional<std::string> message; |
| + base::Optional<std::vector<uint8_t>> data; |
| }; |
|
dcheng
2017/02/28 06:45:27
Nit: DISALLOW_COPY_AND_ASSIGN, since it seems like
mark a. foltz
2017/02/28 18:35:21
The compiler automatically deletes the default cop
dcheng
2017/03/01 00:55:49
I think I would still prefer to be explicit about
mark a. foltz
2017/03/03 21:03:21
The compiler actually won't allow use of DISALLOW_
dcheng
2017/03/06 22:14:55
This shouldn't block the commit but:
$ cat test.c
|
| } // namespace content |