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

Unified Diff: chrome/browser/media/cast_remoting_connector_messaging.cc

Issue 2951523002: Media Remoting: Add mojo interfaces between browser and extension. (Closed)
Patch Set: Fix unittests. Created 3 years, 5 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/cast_remoting_connector_messaging.cc
diff --git a/chrome/browser/media/cast_remoting_connector_messaging.cc b/chrome/browser/media/cast_remoting_connector_messaging.cc
deleted file mode 100644
index d55d6a5f8bcdc2180d632facc2be1d5edd1e3ae5..0000000000000000000000000000000000000000
--- a/chrome/browser/media/cast_remoting_connector_messaging.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2016 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.
-
-#include "chrome/browser/media/cast_remoting_connector_messaging.h"
-
-#include <stdio.h>
-
-#include <limits>
-
-#include "base/strings/string_number_conversions.h"
-
-const char CastRemotingConnectorMessaging::kMessageFieldSeparator = ':';
-const char CastRemotingConnectorMessaging::kStartRemotingMessageFormat[] =
- "START_CAST_REMOTING:session=%x";
-const char CastRemotingConnectorMessaging::kStartStreamsMessageFormat[] =
- "START_CAST_REMOTING_STREAMS:session=%x:audio=%c:video=%c";
-const char
-CastRemotingConnectorMessaging::kStartedStreamsMessageFormatPartial[] =
- "STARTED_CAST_REMOTING_STREAMS:session=%x";
-const char
-CastRemotingConnectorMessaging::kStartedStreamsMessageAudioIdSpecifier[] =
- ":audio_stream_id=";
-const char
-CastRemotingConnectorMessaging::kStartedStreamsMessageVideoIdSpecifier[] =
- ":video_stream_id=";
-const char CastRemotingConnectorMessaging::kStopRemotingMessageFormat[] =
- "STOP_CAST_REMOTING:session=%x";
-const char CastRemotingConnectorMessaging::kStoppedMessageFormat[] =
- "STOPPED_CAST_REMOTING:session=%x";
-const char CastRemotingConnectorMessaging::kFailedMessageFormat[] =
- "FAILED_CAST_REMOTING:session=%x";
-
-// static
-bool CastRemotingConnectorMessaging::IsMessageForSession(
- const std::string& message, const char* format,
- unsigned int expected_session_id) {
- unsigned int session_id;
- if (sscanf(message.c_str(), format, &session_id) == 1)
- return session_id == expected_session_id;
- return false;
-}
-
-// static
-int32_t CastRemotingConnectorMessaging::GetStreamIdFromStartedMessage(
- base::StringPiece message, base::StringPiece specifier) {
- auto start = message.find(specifier);
- if (start == std::string::npos)
- return -1;
- start += specifier.size();
- if (start + 1 >= message.size())
- return -1; // Must be at least one hex digit following the specifier.
- const auto length = message.find(kMessageFieldSeparator, start) - start;
- int parsed_value;
- if (!base::HexStringToInt(message.substr(start, length), &parsed_value) ||
- parsed_value < 0 ||
- parsed_value > std::numeric_limits<int32_t>::max()) {
- return -1; // Non-hex digits, or outside valid range.
- }
- return static_cast<int32_t>(parsed_value);
-}

Powered by Google App Engine
This is Rietveld 408576698