Skip to content

Commit

Permalink
Merge branch 'main' into maxz-sb16-sock-posix-reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
maxz-lab authored Aug 14, 2024
2 parents 885cbbc + 6eaa15d commit f90eae5
Show file tree
Hide file tree
Showing 138 changed files with 1,144 additions and 421 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 @@ -133,7 +133,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 @@ -250,12 +250,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
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
27 changes: 20 additions & 7 deletions cobalt/network/url_request_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,17 @@ URLRequestContext::URLRequestContext(
quic::ParsedQuicVersionVector{quic::ParsedQuicVersion::Q046()};
url_request_context_builder->set_quic_context(std::move(quic_context));

base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
bool quic_enabled =
configuration::Configuration::GetInstance()->CobaltEnableQuic();
if (quic_enabled) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
quic_enabled = !command_line->HasSwitch(switches::kDisableQuic);
}
configuration::Configuration::GetInstance()->CobaltEnableQuic() &&
!command_line->HasSwitch(switches::kDisableQuic);
bool spdy_enabled = !command_line->HasSwitch(switches::kDisableHttp2);

url_request_context_builder->SetSpdyAndQuicEnabled(/*spdy_enabled=*/true,
url_request_context_builder->SetSpdyAndQuicEnabled(spdy_enabled,
quic_enabled);

net::HttpNetworkSessionParams params;
params.enable_http2 = spdy_enabled;
params.enable_quic = quic_enabled;
params.use_quic_for_unknown_origins = quic_enabled;

Expand Down Expand Up @@ -329,7 +329,20 @@ void URLRequestContext::SetProxy(const std::string& proxy_rules) {

void URLRequestContext::SetEnableQuic(bool enable_quic) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
url_request_context_->http_network_session()->SetEnableQuic(enable_quic);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
bool quic_commandline_enabled =
!command_line->HasSwitch(switches::kDisableQuic);
url_request_context_->http_network_session()->SetEnableQuic(
enable_quic && quic_commandline_enabled);
}

void URLRequestContext::SetEnableHttp2(bool enable_http2) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
bool http2_commandline_enabled =
!command_line->HasSwitch(switches::kDisableHttp2);
url_request_context_->http_network_session()->SetEnableHttp2(
enable_http2 && http2_commandline_enabled);
}

bool URLRequestContext::using_http_cache() { return using_http_cache_; }
Expand Down
1 change: 1 addition & 0 deletions cobalt/network/url_request_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class URLRequestContext {
void SetProxy(const std::string& custom_proxy_rules);

void SetEnableQuic(bool enable_quic);
void SetEnableHttp2(bool enable_http2);

bool using_http_cache();

Expand Down
Loading

0 comments on commit f90eae5

Please sign in to comment.