Skip to content

Commit

Permalink
Merge branch '24.lts.1+' into cherry-pick-24.lts.1+-3554
Browse files Browse the repository at this point in the history
  • Loading branch information
jellefoks authored Aug 14, 2024
2 parents 39a3d2b + f514f84 commit f9722c3
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 9 deletions.
26 changes: 21 additions & 5 deletions cobalt/h5vcc/h5vcc_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,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";

#if SB_IS(EVERGREEN)
const char kUpdaterMinFreeSpaceBytes[] = "Updater.MinFreeSpaceBytes";
Expand All @@ -62,11 +63,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 Down Expand Up @@ -95,12 +91,32 @@ bool H5vccSettings::Set(const std::string& name, SetValueType value) const {
}
}

if (name.compare(kHTTP2) == 0 && value.IsType<int32>()) {
if (!persistent_settings_) {
return false;
} else {
persistent_settings_->SetPersistentSetting(
network::kHttp2EnabledPersistentSettingsKey,
std::make_unique<base::Value>(value.AsType<int32>() != 0));
// Tell NetworkModule (if exists) to re-query persistent settings.
if (network_module_) {
network_module_->SetEnableHttp2FromPersistentSettings();
}
return true;
}
}

#if SB_IS(EVERGREEN)
if (name.compare(kUpdaterMinFreeSpaceBytes) == 0 && value.IsType<int32>()) {
updater_module_->SetMinFreeSpaceBytes(value.AsType<int32>());
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
3 changes: 3 additions & 0 deletions cobalt/loader/cors_preflight.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ bool CORSPreflight::IsPreflightNeeded() {
if (force_preflight_) {
return true;
}
if (cors_policy_ == network::kCORSOptional) {
return false;
}
// Preflight is not needed if the request method is CORS-safelisted request
// method and all headers are CORS-safelisted request-header.
std::vector<std::string> unsafe_headers;
Expand Down
14 changes: 14 additions & 0 deletions cobalt/network/network_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ void NetworkModule::SetEnableQuicFromPersistentSettings() {
}
}

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

void NetworkModule::EnsureStorageManagerStarted() {
DCHECK(storage_manager_);
storage_manager_->EnsureStarted();
Expand Down Expand Up @@ -200,6 +213,7 @@ void NetworkModule::Initialize(const std::string& user_agent_string,
url_request_context_.get(), thread_.get());

SetEnableQuicFromPersistentSettings();
SetEnableHttp2FromPersistentSettings();
}

void NetworkModule::OnCreate(base::WaitableEvent* creation_event) {
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 @@ -63,6 +63,7 @@ enum ClientHintHeadersCallType : int32_t {
constexpr int32_t kEnabledClientHintHeaders = (kCallTypeLoader | kCallTypeXHR);

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

class NetworkSystem;
// NetworkModule wraps various networking-related components such as
Expand Down Expand Up @@ -130,6 +131,7 @@ class NetworkModule : public base::MessageLoop::DestructionObserver {
void SetProxy(const std::string& custom_proxy_rules);

void SetEnableQuicFromPersistentSettings();
void SetEnableHttp2FromPersistentSettings();

// Adds the Client Hint Headers to the provided URLFetcher if enabled.
void AddClientHintHeaders(net::URLFetcher& url_fetcher,
Expand Down
2 changes: 2 additions & 0 deletions cobalt/network/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ 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
18 changes: 16 additions & 2 deletions cobalt/network/url_request_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ URLRequestContext::URLRequestContext(

net::HttpNetworkSession::Params params;

base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
params.enable_http2 = !command_line->HasSwitch(switches::kDisableHttp2);
if (configuration::Configuration::GetInstance()->CobaltEnableQuic()) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
params.enable_quic = !command_line->HasSwitch(switches::kDisableQuic);
params.use_quic_for_unknown_origins = params.enable_quic;
}
Expand Down Expand Up @@ -283,7 +284,20 @@ void URLRequestContext::SetProxy(const std::string& proxy_rules) {

void URLRequestContext::SetEnableQuic(bool enable_quic) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
storage_.http_network_session()->SetEnableQuic(enable_quic);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
bool quic_commandline_enabled =
!command_line->HasSwitch(switches::kDisableQuic);
storage_.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);
storage_.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 @@ -52,6 +52,7 @@ class URLRequestContext : public net::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
2 changes: 1 addition & 1 deletion cobalt/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
// release is cut.
//.

#define COBALT_VERSION "24.lts.41"
#define COBALT_VERSION "24.lts.50"

#endif // COBALT_VERSION_H_
15 changes: 15 additions & 0 deletions net/http/http_network_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,21 @@ void HttpNetworkSession::SetEnableQuic(bool enable_quic) {
params_.enable_quic = enable_quic;
}

void HttpNetworkSession::SetEnableHttp2(bool enable_http2) {
if (params_.enable_http2 == enable_http2) {
return;
}
params_.enable_http2 = enable_http2;

if (params_.enable_http2) {
next_protos_.push_back(kProtoHTTP2);
} else {
if (next_protos_.back() == kProtoHTTP2) {
next_protos_.pop_back();
}
}
}

bool HttpNetworkSession::UseQuicForUnknownOrigin() const {
return params_.use_quic_for_unknown_origins;
}
Expand Down
1 change: 1 addition & 0 deletions net/http/http_network_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ class NET_EXPORT HttpNetworkSession {
void ToggleQuic();

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

// Whether to try QUIC connection for origins without alt-svc on record.
bool UseQuicForUnknownOrigin() const;
Expand Down
1 change: 1 addition & 0 deletions net/http/http_stream_factory_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@ int HttpStreamFactory::Job::DoInitConnectionImpl() {
// actually need to preconnect any sockets, so we're done.
if (job_type_ == PRECONNECT)
return OK;
negotiated_protocol_ = kProtoHTTP2;
using_spdy_ = true;
next_state_ = STATE_CREATE_STREAM;
return OK;
Expand Down
4 changes: 3 additions & 1 deletion starboard/elf_loader/exported_symbols.cc
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,9 @@ const void* ExportedSymbols::Lookup(const char* name) {
const void* address = map_[name];
// Any symbol that is not registered as part of the Starboard API in the
// constructor of this class is a leak, and is an error.
SB_CHECK(address) << "Failed to retrieve the address of '" << name << "'.";
if (!address) {
SB_LOG(ERROR) << "Failed to retrieve the address of '" << name << "'.";
}
return address;
}

Expand Down
1 change: 1 addition & 0 deletions starboard/elf_loader/exported_symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace elf_loader {
class ExportedSymbols {
public:
ExportedSymbols();
// Returns the address of the symbol |name|. If it's not found, returns NULL.
const void* Lookup(const char* name);

private:
Expand Down

0 comments on commit f9722c3

Please sign in to comment.