Skip to content

Commit

Permalink
Merge branch 'main' into readdir
Browse files Browse the repository at this point in the history
  • Loading branch information
haozheng-cobalt authored Aug 15, 2024
2 parents 61245ef + a9495fe commit ba44a15
Show file tree
Hide file tree
Showing 141 changed files with 1,191 additions and 439 deletions.
15 changes: 10 additions & 5 deletions .github/config/evergreen-arm64.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"docker_service": "build-evergreen",
"docker_service": "build-android-evergreen",
"evergreen_loader": "android-arm64",
"platforms": [
"evergreen-arm64",
"evergreen-arm64-sbversion-15",
Expand All @@ -12,31 +13,35 @@
"platform":"evergreen-arm64",
"target_platform":"evergreen-arm64",
"target_cpu":"target_cpu=\\\"arm64\\\"",
"extra_gn_arguments":"use_asan=false"
"extra_gn_arguments":"use_asan=false",
"evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true"
},
{
"name":"sbversion-15",
"platform":"evergreen-arm64-sbversion-15",
"target_platform":"evergreen-arm64",
"target_cpu":"target_cpu=\\\"arm64\\\"",
"extra_gn_arguments":"use_asan=false",
"sb_api_version":"15"
"sb_api_version":"15",
"evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true"
},
{
"name":"sbversion-16",
"platform":"evergreen-arm64-sbversion-16",
"target_platform":"evergreen-arm64",
"target_cpu":"target_cpu=\\\"arm64\\\"",
"extra_gn_arguments":"use_asan=false",
"sb_api_version":"16"
"sb_api_version":"16",
"evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true"
},
{
"name":"sbversion-17",
"platform":"evergreen-arm64-sbversion-17",
"target_platform":"evergreen-arm64",
"target_cpu":"target_cpu=\\\"arm64\\\"",
"extra_gn_arguments":"use_asan=false",
"sb_api_version":"17"
"sb_api_version":"17",
"evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true"
}
]
}
2 changes: 1 addition & 1 deletion base/files/file_enumerator_starboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ std::vector<FileEnumerator::FileInfo> FileEnumerator::ReadDirectory(
FilePath full_name = source.Append(filename);
// TODO: Make sure this follows symlinks on relevant platforms.
if (stat(full_name.value().c_str(), &info.stat_) != 0) {
DPLOG(ERROR) << "Couldn't SbFileGetInfo on " << full_name.value();
DPLOG(ERROR) << "Couldn't stat on " << full_name.value();
memset(&info.stat_, 0, sizeof(info.stat_));
}
return info;
Expand Down
6 changes: 3 additions & 3 deletions base/files/file_util_starboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "starboard/configuration_constants.h"
#include "starboard/common/file.h"
#include "starboard/directory.h"
#include "starboard/file.h"
#include "base/strings/strcat.h"
#include "starboard/system.h"

Expand Down Expand Up @@ -248,12 +248,12 @@ bool PathExists(const FilePath &path) {

bool PathIsReadable(const FilePath &path) {
internal::AssertBlockingAllowed();
return SbFileCanOpen(path.value().c_str(), kSbFileOpenAlways | kSbFileRead);
return starboard::FileCanOpen(path.value().c_str(), O_CREAT | O_RDONLY);
}

bool PathIsWritable(const FilePath &path) {
internal::AssertBlockingAllowed();
return SbFileCanOpen(path.value().c_str(), kSbFileOpenAlways | kSbFileWrite);
return starboard::FileCanOpen(path.value().c_str(), O_CREAT | O_WRONLY);
}

bool DirectoryExists(const FilePath& path) {
Expand Down
2 changes: 1 addition & 1 deletion build/config/compiler/compiler.gni
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ declare_args() {
# If true, optimize for size.
# Default to favoring speed over size for platforms not listed below.
optimize_for_size =
!is_high_end_android && (is_android || is_ios || is_castos)
!(is_high_end_android || is_starboard) && (is_android || is_ios || is_castos)
}

declare_args() {
Expand Down
50 changes: 32 additions & 18 deletions cobalt/browser/browser_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ BrowserModule::BrowserModule(const GURL& url,
splash_screen_layer_ = render_tree_combiner_.CreateLayer(kSplashScreenZIndex);
// Create the debug console layer.
#if defined(ENABLE_DEBUGGER)
debug_console_layer_ = render_tree_combiner_.CreateLayer(kDebugConsoleZIndex);
if (DebugConsole::IsEnabled()) {
debug_console_layer_ =
render_tree_combiner_.CreateLayer(kDebugConsoleZIndex);
}
#endif

int qr_code_overlay_slots = 4;
Expand Down Expand Up @@ -367,15 +370,17 @@ BrowserModule::BrowserModule(const GURL& url,
resource_provider_stub_.emplace(true /*allocate_image_data*/);

#if defined(ENABLE_DEBUGGER)
debug_console_.reset(new DebugConsole(
platform_info_.get(), application_state_,
base::Bind(&BrowserModule::QueueOnDebugConsoleRenderTreeProduced,
base::Unretained(this)),
&web_settings_, network_module_, GetViewportSize(), GetResourceProvider(),
kLayoutMaxRefreshFrequencyInHz,
base::Bind(&BrowserModule::CreateDebugClient, base::Unretained(this)),
base::Bind(&BrowserModule::OnMaybeFreeze, base::Unretained(this))));
lifecycle_observers_.AddObserver(debug_console_.get());
if (debug_console_layer_) {
debug_console_.reset(new DebugConsole(
platform_info_.get(), application_state_,
base::Bind(&BrowserModule::QueueOnDebugConsoleRenderTreeProduced,
base::Unretained(this)),
&web_settings_, network_module_, GetViewportSize(),
GetResourceProvider(), kLayoutMaxRefreshFrequencyInHz,
base::Bind(&BrowserModule::CreateDebugClient, base::Unretained(this)),
base::Bind(&BrowserModule::OnMaybeFreeze, base::Unretained(this))));
lifecycle_observers_.AddObserver(debug_console_.get());
}
#endif // defined(ENABLE_DEBUGGER)

const renderer::Pipeline* pipeline =
Expand Down Expand Up @@ -1095,6 +1100,7 @@ void BrowserModule::OnDisableMediaCodecs(const std::string& codecs) {

void BrowserModule::QueueOnDebugConsoleRenderTreeProduced(
const browser::WebModule::LayoutResults& layout_results) {
#if defined(ENABLE_DEBUGGER)
TRACE_EVENT0("cobalt::browser",
"BrowserModule::QueueOnDebugConsoleRenderTreeProduced()");
render_tree_submission_queue_.AddMessage(
Expand All @@ -1103,14 +1109,17 @@ void BrowserModule::QueueOnDebugConsoleRenderTreeProduced(
task_runner_->PostTask(
FROM_HERE,
base::Bind(&BrowserModule::ProcessRenderTreeSubmissionQueue, weak_this_));
#endif
}

void BrowserModule::OnDebugConsoleRenderTreeProduced(
const browser::WebModule::LayoutResults& layout_results) {
#if defined(ENABLE_DEBUGGER)
TRACE_EVENT0("cobalt::browser",
"BrowserModule::OnDebugConsoleRenderTreeProduced()");
DCHECK(task_runner_->RunsTasksInCurrentSequence());
if (application_state_ == base::kApplicationStateConcealed) {
if (!debug_console_ ||
(application_state_ == base::kApplicationStateConcealed)) {
return;
}

Expand All @@ -1127,6 +1136,7 @@ void BrowserModule::OnDebugConsoleRenderTreeProduced(
}

SubmitCurrentRenderTreeToRenderer();
#endif
}

void BrowserModule::OnNavigateTimedTrace(const std::string& time) {
Expand All @@ -1151,7 +1161,8 @@ void BrowserModule::OnOnScreenKeyboardInputEventProduced(
}

#if defined(ENABLE_DEBUGGER)
if (!debug_console_->FilterOnScreenKeyboardInputEvent(type, event)) {
if (debug_console_ &&
!debug_console_->FilterOnScreenKeyboardInputEvent(type, event)) {
return;
}
#endif // defined(ENABLE_DEBUGGER)
Expand Down Expand Up @@ -1188,7 +1199,7 @@ void BrowserModule::OnPointerEventProduced(base_token::Token type,
}

#if defined(ENABLE_DEBUGGER)
if (!debug_console_->FilterPointerEvent(type, event)) {
if (debug_console_ && !debug_console_->FilterPointerEvent(type, event)) {
return;
}
#endif // defined(ENABLE_DEBUGGER)
Expand All @@ -1214,7 +1225,7 @@ void BrowserModule::OnWheelEventProduced(base_token::Token type,
}

#if defined(ENABLE_DEBUGGER)
if (!debug_console_->FilterWheelEvent(type, event)) {
if (debug_console_ && !debug_console_->FilterWheelEvent(type, event)) {
return;
}
#endif // defined(ENABLE_DEBUGGER)
Expand Down Expand Up @@ -1348,7 +1359,7 @@ bool BrowserModule::FilterKeyEvent(base_token::Token type,
}

#if defined(ENABLE_DEBUGGER)
if (!debug_console_->FilterKeyEvent(type, event)) {
if (debug_console_ && !debug_console_->FilterKeyEvent(type, event)) {
return false;
}
#endif // defined(ENABLE_DEBUGGER)
Expand All @@ -1359,8 +1370,9 @@ bool BrowserModule::FilterKeyEvent(base_token::Token type,
bool BrowserModule::FilterKeyEventForHotkeys(
base_token::Token type, const dom::KeyboardEventInit& event) {
#if defined(ENABLE_DEBUGGER)
if (event.key_code() == dom::keycode::kF1 ||
(event.ctrl_key() && event.key_code() == dom::keycode::kO)) {
if (debug_console_ &&
(event.key_code() == dom::keycode::kF1 ||
(event.ctrl_key() && event.key_code() == dom::keycode::kO))) {
if (type == base::Tokens::keydown()) {
// F1 or Ctrl+O cycles the debug console display.
debug_console_->CycleMode();
Expand Down Expand Up @@ -1754,7 +1766,9 @@ void BrowserModule::ResetResources() {
main_web_module_layer_->Reset();
splash_screen_layer_->Reset();
#if defined(ENABLE_DEBUGGER)
debug_console_layer_->Reset();
if (debug_console_layer_) {
debug_console_layer_->Reset();
}
#endif // defined(ENABLE_DEBUGGER)
if (qr_overlay_info_layer_) {
qr_overlay_info_layer_->Reset();
Expand Down
12 changes: 12 additions & 0 deletions cobalt/browser/debug_console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ DebugConsole::DebugConsole(

DebugConsole::~DebugConsole() {}

// static
bool DebugConsole::IsEnabled() {
#if defined(ENABLE_DEBUGGER)
// The debug console is not enabled when it's turned off from the
// command-line.
return GetDebugConsoleModeFromCommandLine() !=
debug::console::kDebugConsoleModeOff;
#else
return false;
#endif
}

bool DebugConsole::ShouldInjectInputEvents() {
switch (GetMode()) {
case debug::console::kDebugConsoleModeOff:
Expand Down
3 changes: 3 additions & 0 deletions cobalt/browser/debug_console.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class DebugConsole : public LifecycleObserver {
// Cycles through each different possible debug console visibility mode.
void CycleMode();

// Returns true if the debug console is enabled.
static bool IsEnabled();

// Returns true iff the console is in a mode that is visible.
bool IsVisible() {
return (GetMode() != debug::console::kDebugConsoleModeOff);
Expand Down
22 changes: 17 additions & 5 deletions cobalt/h5vcc/h5vcc_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ bool H5vccSettings::Set(const std::string& name, SetValueType value) const {
const char kMediaCodecBlockList[] = "MediaCodecBlockList";
const char kNavigatorUAData[] = "NavigatorUAData";
const char kQUIC[] = "QUIC";
const char kHTTP2[] = "HTTP2";
const char kHTTP3[] = "HTTP3";
const char kSkiaRasterizer[] = "SkiaRasterizer";

Expand All @@ -70,11 +71,6 @@ bool H5vccSettings::Set(const std::string& name, SetValueType value) const {
return true;
}

if (set_web_setting_func_ && value.IsType<int32>() &&
set_web_setting_func_.Run(name, value.AsType<int32>())) {
return true;
}

if (name.rfind(kMediaPrefix, 0) == 0 && value.IsType<int32>()) {
return media_module_
? media_module_->SetConfiguration(
Expand All @@ -100,6 +96,17 @@ bool H5vccSettings::Set(const std::string& name, SetValueType value) const {
}
}

if (name.compare(kHTTP2) == 0 && value.IsType<int32>()) {
if (!persistent_settings_ || !network_module_) {
return false;
} else {
persistent_settings_->Set(network::kHttp2EnabledPersistentSettingsKey,
base::Value(value.AsType<int32>() != 0));
network_module_->SetEnableHttp2FromPersistentSettings();
return true;
}
}

if (name.compare(kHTTP3) == 0 && value.IsType<int32>()) {
if (!persistent_settings_ || !network_module_) {
return false;
Expand Down Expand Up @@ -153,6 +160,11 @@ bool H5vccSettings::Set(const std::string& name, SetValueType value) const {
return true;
}
#endif
if (set_web_setting_func_ && value.IsType<int32>() &&
set_web_setting_func_.Run(name, value.AsType<int32>())) {
return true;
}

return false;
}

Expand Down
5 changes: 3 additions & 2 deletions cobalt/media/sandbox/format_guesstimator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "media/filters/chunk_demuxer.h"
#include "net/base/filename_util.h"
#include "net/base/url_util.h"
#include "starboard/common/file.h"
#include "starboard/memory.h"
#include "starboard/types.h"
#include "ui/gfx/geometry/size.h"
Expand Down Expand Up @@ -81,7 +82,7 @@ base::FilePath ResolvePath(const std::string& path) {
base::PathService::Get(base::DIR_TEST_DATA, &content_path);
result = content_path.Append(result);
}
if (SbFileCanOpen(result.value().c_str(), kSbFileOpenOnly | kSbFileRead)) {
if (starboard::FileCanOpen(result.value().c_str(), O_RDONLY)) {
return result;
}
LOG(WARNING) << "Failed to resolve path \"" << path << "\" as \""
Expand Down Expand Up @@ -141,7 +142,7 @@ FormatGuesstimator::FormatGuesstimator(const std::string& path_or_url,
return;
}
base::FilePath path = ResolvePath(path_or_url);
if (path.empty() || !SbFileCanOpen(path.value().c_str(), kSbFileRead)) {
if (path.empty() || !starboard::FileCanOpen(path.value().c_str(), O_RDONLY)) {
return;
}
InitializeAsAdaptive(path, media_module);
Expand Down
15 changes: 15 additions & 0 deletions cobalt/network/network_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ void NetworkModule::SetEnableQuicFromPersistentSettings() {
}
}

void NetworkModule::SetEnableHttp2FromPersistentSettings() {
// Called on initialization and when the persistent setting is changed.
if (options_.persistent_settings != nullptr) {
base::Value value;
options_.persistent_settings->Get(kHttp2EnabledPersistentSettingsKey,
&value);
bool enable_http2 = value.GetIfBool().value_or(true);
task_runner()->PostTask(
FROM_HERE,
base::Bind(&URLRequestContext::SetEnableHttp2,
base::Unretained(url_request_context_.get()), enable_http2));
}
}

void NetworkModule::SetEnableHttp3FromPersistentSettings() {
// Called on initialization and when the persistent setting is changed.
if (options_.persistent_settings != nullptr) {
Expand Down Expand Up @@ -233,6 +247,7 @@ void NetworkModule::Initialize(const std::string& user_agent_string,
url_request_context_.get(), thread_.get());

SetEnableQuicFromPersistentSettings();
SetEnableHttp2FromPersistentSettings();
SetEnableHttp3FromPersistentSettings();
}

Expand Down
2 changes: 2 additions & 0 deletions cobalt/network/network_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ enum ClientHintHeadersCallType : int32_t {
constexpr int32_t kEnabledClientHintHeaders = (kCallTypeLoader | kCallTypeXHR);

const char kQuicEnabledPersistentSettingsKey[] = "QUICEnabled";
const char kHttp2EnabledPersistentSettingsKey[] = "HTTP2Enabled";
const char kHttp3EnabledPersistentSettingsKey[] = "HTTP3Enabled";

class NetworkSystem;
Expand Down Expand Up @@ -130,6 +131,7 @@ class NetworkModule : public base::CurrentThread::DestructionObserver {
void SetProxy(const std::string& custom_proxy_rules);

void SetEnableQuicFromPersistentSettings();
void SetEnableHttp2FromPersistentSettings();
void SetEnableHttp3FromPersistentSettings();

// Adds the Client Hint Headers to the provided URLFetcher if enabled.
Expand Down
3 changes: 3 additions & 0 deletions cobalt/network/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const char kDisableInAppDial[] = "disable_in_app_dial";
// Switch to disable use of the Quic network protocol.
const char kDisableQuic[] = "disable_quic";

// Switch to disable use of the HTTP/2 (SPDY) network protocol.
const char kDisableHttp2[] = "disable_h2";


} // namespace switches
} // namespace network
Expand Down
1 change: 1 addition & 0 deletions cobalt/network/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern const char kMaxNetworkDelayHelp[];
extern const char kDisableInAppDial[];
#endif // ENABLE_DEBUG_COMMAND_LINE_SWITCHES
extern const char kDisableQuic[];
extern const char kDisableHttp2[];

} // namespace switches
} // namespace network
Expand Down
Loading

0 comments on commit ba44a15

Please sign in to comment.