Index: content/public/common/presentation_connection_message.cc |
diff --git a/content/public/common/presentation_connection_message.cc b/content/public/common/presentation_connection_message.cc |
index 222e2141ac37ace61f429447d9bac1ebe52d5003..bd99a3818b203f34bf9910c194d23c86cf326229 100644 |
--- a/content/public/common/presentation_connection_message.cc |
+++ b/content/public/common/presentation_connection_message.cc |
@@ -6,6 +6,9 @@ |
#include <utility> |
+#include "base/base64.h" |
+#include "base/json/string_escape.h" |
+ |
namespace content { |
// TODO(crbug.com/524128): This restriction comes from Cast. Raise this limit |
@@ -23,7 +26,13 @@ PresentationConnectionMessage::PresentationConnectionMessage( |
: data(std::move(data)) {} |
PresentationConnectionMessage::PresentationConnectionMessage( |
- PresentationConnectionMessage&& other) = default; |
+ const PresentationConnectionMessage& other) = default; |
+ |
+// Note: "move constructor noexcept = default" currently does not compile on |
+// Windows and Android (crbug.com/706963). |
+PresentationConnectionMessage::PresentationConnectionMessage( |
+ PresentationConnectionMessage&& other) noexcept |
+ : message(std::move(other.message)), data(std::move(other.data)) {} |
PresentationConnectionMessage::~PresentationConnectionMessage() {} |
@@ -32,6 +41,9 @@ bool PresentationConnectionMessage::operator==( |
return this->data == other.data && this->message == other.message; |
} |
+PresentationConnectionMessage& PresentationConnectionMessage::operator=( |
mark a. foltz
2017/06/28 07:29:55
Can you add a note explaining why this isn't move-
imcheng
2017/06/29 08:21:09
added comment in header file.
|
+ const PresentationConnectionMessage& other) = default; |
+ |
PresentationConnectionMessage& PresentationConnectionMessage::operator=( |
PresentationConnectionMessage&& other) = default; |
@@ -39,4 +51,20 @@ bool PresentationConnectionMessage::is_binary() const { |
return data.has_value(); |
} |
+std::string PresentationConnectionMessage::ToHumanReadableString() const { |
mark a. foltz
2017/06/28 07:29:56
This only seems to be called from logging in unitt
imcheng
2017/06/29 08:21:09
Added #ifndef NDEBUG.
imcheng
2017/06/29 17:58:23
It turns out we build unit tests on release builds
|
+ if (!message && !data) |
+ return "null"; |
+ std::string result; |
+ if (message) { |
+ result = "text="; |
+ base::EscapeJSONString(*message, true, &result); |
+ } else { |
+ const base::StringPiece src(reinterpret_cast<const char*>(data->data()), |
+ data->size()); |
+ base::Base64Encode(src, &result); |
+ result = "binary=" + result; |
+ } |
+ return result; |
+} |
+ |
} // namespace content |