0

Remove //base dependency from libcast_graphics_1.0

This .so is loaded into other processes that already have //base; having
two copies of //base seems to be a recipe for trouble, especially with
PartitionAlloc: which module "wins" seems inconsistent.

Luckily, the switch parsing here is pretty straightforward, so just
hardcode the strings to look for in `argv`.

Bug: 404881580
Change-Id: If35d206c6a8d1c35c1c5578f5d4d00fef49388a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6504932
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Shawn Quereshi <shawnq@google.com>
Cr-Commit-Position: refs/heads/main@{#1455195}
This commit is contained in:
Daniel Cheng
2025-05-02 14:19:32 -07:00
committed by Chromium LUCI CQ
parent 6cfcb9841e
commit ad5cbdeff8
2 changed files with 16 additions and 13 deletions

@ -122,11 +122,10 @@ cast_shared_library("libcast_graphics_1.0") {
public_deps = [ "//chromecast/public" ]
deps = [
"//base",
"//chromecast/base:chromecast_switches",
"//chromecast/base:init_shlib",
]
deps = [ "//base:base_static" ]
# Note: this target must not transitively depend on //base, as having two
# copies of //base in the same address space leads to hard-to-debug crashes.
}
if (use_aura && !is_cast_audio_only && !is_fuchsia) {

@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/command_line.h"
#include "base/notreached.h"
#include "chromecast/base/chromecast_switches.h"
#include "chromecast/base/init_command_line_shlib.h"
#include <algorithm>
#include <string>
#include <vector>
#include "base/immediate_crash.h"
#include "chromecast/public/graphics_properties_shlib.h"
namespace chromecast {
@ -13,15 +14,18 @@ namespace chromecast {
bool GraphicsPropertiesShlib::IsSupported(
Resolution resolution,
const std::vector<std::string>& argv) {
InitCommandLineShlib(argv);
switch (resolution) {
case Resolution::k1080p:
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDesktopWindow1080p);
return std::ranges::any_of(argv, [](const std::string& arg) {
// This is defined by `kDesktopWindow1080p`, but it can't be used here
// since //chromecast/base depends on //base.
return arg == "-desktop-window-1080p" ||
arg == "--desktop-window-1080p";
});
case Resolution::kUHDTV:
return false;
default:
NOTREACHED();
base::ImmediateCrash();
}
}