Skip to content

Commit

Permalink
[fuchsia] Move Fuchsia-specific functions out of Cast Streaming
Browse files Browse the repository at this point in the history
This moves 2 Fuchsia-specific functions out of the
//fuchsia/cast_streaming directory. These 2 functions are now only
used by WebEngine, so they have been moved there.
Following this CL, the //fuchsia/cast_streaming directory no longer
contains any Fuchsia-specific code and can be moved to a Chromium
component.

Bug: 1157201
Change-Id: I0cec3c67b96b363c0681ada3f130baf654ee3e85
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2582944
Reviewed-by: David Dorwin <ddorwin@chromium.org>
Commit-Queue: Fabrice de Gans-Riberi <fdegans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835438}
  • Loading branch information
Steelskin authored and Chromium LUCI CQ committed Dec 9, 2020
1 parent 721926d commit 10be176
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 59 deletions.
8 changes: 1 addition & 7 deletions fuchsia/cast_streaming/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,14 @@ source_set("cast_streaming_session") {
"//media/mojo/common",
"//media/mojo/mojom",
"//mojo/public/cpp/system",
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.web",
"//third_party/openscreen/src/cast/common:public",
"//third_party/openscreen/src/cast/streaming:receiver",
"//third_party/openscreen/src/util",
]
public_deps = [ "//components/cast/message_port" ]
visibility = [ ":*" ]
public = [
"public/cast_streaming.h",
"public/cast_streaming_session.h",
]
public = [ "public/cast_streaming_session.h" ]
sources = [
"cast_streaming.cc",
"cast_streaming_session.cc",
"stream_consumer.cc",
"stream_consumer.h",
Expand Down Expand Up @@ -93,7 +88,6 @@ source_set("cast_streaming_test_sender") {
"//media/mojo/common",
"//media/mojo/mojom",
"//mojo/public/cpp/system",
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.web",
"//third_party/openscreen/src/cast/common:public",
"//third_party/openscreen/src/cast/streaming:sender",
"//third_party/openscreen/src/platform:api",
Expand Down
24 changes: 0 additions & 24 deletions fuchsia/cast_streaming/cast_streaming.cc

This file was deleted.

25 changes: 0 additions & 25 deletions fuchsia/cast_streaming/public/cast_streaming.h

This file was deleted.

5 changes: 2 additions & 3 deletions fuchsia/engine/browser/frame_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "content/public/common/was_activated_option.mojom.h"
#include "fuchsia/base/mem_buffer_util.h"
#include "fuchsia/base/message_port.h"
#include "fuchsia/cast_streaming/public/cast_streaming.h"
#include "fuchsia/engine/browser/accessibility_bridge.h"
#include "fuchsia/engine/browser/cast_streaming_session_client.h"
#include "fuchsia/engine/browser/context_impl.h"
Expand Down Expand Up @@ -518,12 +517,12 @@ bool FrameImpl::MaybeHandleCastStreamingMessage(
if (!IsCastStreamingEnabled())
return false;

if (!cast_streaming::IsCastStreamingAppOrigin(*origin))
if (!IsCastStreamingAppOrigin(*origin))
return false;

fuchsia::web::Frame_PostMessage_Result result;
if (cast_streaming_session_client_ ||
!cast_streaming::IsValidCastStreamingMessage(*message)) {
!IsValidCastStreamingMessage(*message)) {
// The Cast Streaming MessagePort should only be set once and |message|
// should be a valid Cast Streaming Message.
result.set_err(fuchsia::web::FrameError::INVALID_ORIGIN);
Expand Down
16 changes: 16 additions & 0 deletions fuchsia/engine/common/cast_streaming.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
#include "fuchsia/engine/common/cast_streaming.h"

#include "base/command_line.h"
#include "base/strings/string_piece.h"
#include "fuchsia/engine/switches.h"
#include "url/gurl.h"

namespace {

constexpr char kCastStreamingReceiverUrl[] = "data:cast_streaming_receiver";
constexpr char kCastStreamingMessagePortOrigin[] = "cast-streaming:receiver";

} // namespace

bool IsCastStreamingEnabled() {
Expand All @@ -22,3 +26,15 @@ bool IsCastStreamingEnabled() {
bool IsCastStreamingMediaSourceUrl(const GURL& url) {
return url == kCastStreamingReceiverUrl;
}

bool IsCastStreamingAppOrigin(base::StringPiece origin) {
return origin == kCastStreamingMessagePortOrigin;
}

bool IsValidCastStreamingMessage(const fuchsia::web::WebMessage& message) {
// |message| should contain exactly one OutgoingTransferrable, with a single
// MessagePort.
return message.has_outgoing_transfer() &&
message.outgoing_transfer().size() == 1u &&
message.outgoing_transfer()[0].is_message_port();
}
13 changes: 13 additions & 0 deletions fuchsia/engine/common/cast_streaming.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#ifndef FUCHSIA_ENGINE_COMMON_CAST_STREAMING_H_
#define FUCHSIA_ENGINE_COMMON_CAST_STREAMING_H_

#include <fuchsia/web/cpp/fidl.h>

#include "base/strings/string_piece_forward.h"

class GURL;

// Returns true if Cast Streaming is enabled for this process.
Expand All @@ -13,4 +17,13 @@ bool IsCastStreamingEnabled();
// Returns true if |url| is the Cast Streaming media source URL.
bool IsCastStreamingMediaSourceUrl(const GURL& url);

// TODO(crbug.com/1082821): Remove these 2 functions below once the Cast
// Streaming Receiver is implemented as a separate component from WebEngine.

// Returns true if |origin| is the Cast Streaming MessagePort origin.
bool IsCastStreamingAppOrigin(base::StringPiece origin);

// Returns true if |message| contains a valid Cast Streaming Message.
bool IsValidCastStreamingMessage(const fuchsia::web::WebMessage& message);

#endif // FUCHSIA_ENGINE_COMMON_CAST_STREAMING_H_

0 comments on commit 10be176

Please sign in to comment.