OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_PUBLIC_COMMON_PRESENTATION_CONNECTION_MESSAGE_H_ | 5 #ifndef CONTENT_PUBLIC_COMMON_PRESENTATION_CONNECTION_MESSAGE_H_ |
6 #define CONTENT_PUBLIC_COMMON_PRESENTATION_CONNECTION_MESSAGE_H_ | 6 #define CONTENT_PUBLIC_COMMON_PRESENTATION_CONNECTION_MESSAGE_H_ |
7 | 7 |
8 #include <stddef.h> // For size_t | 8 #include <stddef.h> // For size_t |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/optional.h" | 14 #include "base/optional.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 // The maximum number of bytes allowed in a presentation connection message. | 19 // The maximum number of bytes allowed in a presentation connection message. |
20 CONTENT_EXPORT extern const size_t kMaxPresentationConnectionMessageSize; | 20 CONTENT_EXPORT extern const size_t kMaxPresentationConnectionMessageSize; |
21 | 21 |
22 // Represents a presentation connection message. If this is a text message, | 22 // Represents a presentation connection message. If this is a text message, |
23 // |data| is null; otherwise, |message| is null. Empty messages are allowed. | 23 // |data| is null; otherwise, |message| is null. Empty messages are allowed. |
24 struct CONTENT_EXPORT PresentationConnectionMessage { | 24 struct CONTENT_EXPORT PresentationConnectionMessage { |
25 public: | 25 public: |
26 // Constructs a new, untyped message (for Mojo). These messages are not valid | 26 // Constructs a new, untyped message (for Mojo). These messages are not valid |
27 // and exactly one of |message| or |data| must be set. | 27 // and exactly one of |message| or |data| must be set. |
28 PresentationConnectionMessage(); | 28 PresentationConnectionMessage(); |
29 // PCM is a move-only type. | 29 // Copy constructor / assignment are necessary due to MediaRouter allowing |
30 PresentationConnectionMessage(PresentationConnectionMessage&& other); | 30 // multiple RouteMessageObserver instances per MediaRoute. |
| 31 PresentationConnectionMessage(const PresentationConnectionMessage& other); |
| 32 PresentationConnectionMessage(PresentationConnectionMessage&& other) noexcept; |
31 // Constructs a text message from |message|. | 33 // Constructs a text message from |message|. |
32 explicit PresentationConnectionMessage(std::string message); | 34 explicit PresentationConnectionMessage(std::string message); |
33 // Constructs a binary message from |data|. | 35 // Constructs a binary message from |data|. |
34 explicit PresentationConnectionMessage(std::vector<uint8_t> data); | 36 explicit PresentationConnectionMessage(std::vector<uint8_t> data); |
| 37 |
35 ~PresentationConnectionMessage(); | 38 ~PresentationConnectionMessage(); |
36 | 39 |
37 bool is_binary() const; | 40 bool is_binary() const; |
38 | 41 |
39 bool operator==(const PresentationConnectionMessage& other) const; | 42 bool operator==(const PresentationConnectionMessage& other) const; |
40 PresentationConnectionMessage& operator=( | 43 PresentationConnectionMessage& operator=( |
| 44 const PresentationConnectionMessage& other); |
| 45 PresentationConnectionMessage& operator=( |
41 PresentationConnectionMessage&& other); | 46 PresentationConnectionMessage&& other); |
42 | 47 |
43 base::Optional<std::string> message; | 48 base::Optional<std::string> message; |
44 base::Optional<std::vector<uint8_t>> data; | 49 base::Optional<std::vector<uint8_t>> data; |
45 }; | 50 }; |
46 | 51 |
47 } // namespace content | 52 } // namespace content |
48 | 53 |
49 #endif // CONTENT_PUBLIC_COMMON_PRESENTATION_CONNECTION_MESSAGE_H_ | 54 #endif // CONTENT_PUBLIC_COMMON_PRESENTATION_CONNECTION_MESSAGE_H_ |
OLD | NEW |