Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1311)

Unified Diff: chrome/browser/media/router/route_message.cc

Issue 2310753002: Media Remoting: Data/Control plumbing between renderer and Media Router. (Closed)
Patch Set: Just a REBASE on ToT before commit. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/router/route_message.cc
diff --git a/chrome/browser/media/router/route_message.cc b/chrome/browser/media/router/route_message.cc
index 41bc9d0d1c53d26f51ff148908a112160a367e3d..89d88f87ee5364336876ed57ca69c463d052057a 100644
--- a/chrome/browser/media/router/route_message.cc
+++ b/chrome/browser/media/router/route_message.cc
@@ -4,10 +4,30 @@
#include "chrome/browser/media/router/route_message.h"
+#include "base/base64.h"
+#include "base/json/string_escape.h"
+
namespace media_router {
RouteMessage::RouteMessage() = default;
RouteMessage::RouteMessage(const RouteMessage& other) = default;
RouteMessage::~RouteMessage() = default;
+std::string RouteMessage::ToHumanReadableString() const {
+ if (!text && !binary)
+ return "null";
+ DCHECK((type == TEXT && text) || (type == BINARY && binary));
+ std::string result;
+ if (text) {
+ result = "text=";
+ base::EscapeJSONString(*text, true, &result);
+ } else {
+ const base::StringPiece src(reinterpret_cast<const char*>(binary->data()),
+ binary->size());
+ base::Base64Encode(src, &result);
+ result = "binary=" + result;
+ }
+ return result;
+}
+
} // namespace media_router

Powered by Google App Engine
This is Rietveld 408576698