Skip to content

Commit

Permalink
Add GetPersistentSetting() to h5vcc_settings.
Browse files Browse the repository at this point in the history
Add a persistent settings getter to validate set persistent h5vcc
settings. The getter is a string getter that maps to the various types
that allows for empty string returns when the getter fails.

b/305057554

Change-Id: Iefde82ef3110c0b9c90a45807edd5652ba59ed0b
  • Loading branch information
briantting committed Nov 13, 2023
1 parent 4cbc246 commit e5ecb72
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cobalt/h5vcc/h5vcc_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,24 @@ bool H5vccSettings::Set(const std::string& name, SetValueType value) const {
return false;
}

std::string H5vccSettings::GetPersistentSetting(
const std::string& name, const std::string& default_setting) const {
const char kQUIC[] = "QUIC";

if (persistent_settings_) {
// Accepts the string "true" or "false" as the default setting.
// Returns the string "true" or "false".
if (name.compare(kQUIC) == 0) {
bool value = persistent_settings_->GetPersistentSettingAsBool(
network::kQuicEnabledPersistentSettingsKey, default_setting);
if (value) {
return "true";
}
return "false";
}
}
return "";
}

} // namespace h5vcc
} // namespace cobalt
3 changes: 3 additions & 0 deletions cobalt/h5vcc/h5vcc_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class H5vccSettings : public script::Wrappable {
// invalid or not set to the expected value.
bool Set(const std::string& name, SetValueType value) const;

std::string GetPersistentSetting(const std::string& name,
const std::string& default_setting) const;

DEFINE_WRAPPABLE_TYPE(H5vccSettings);

private:
Expand Down
1 change: 1 addition & 0 deletions cobalt/h5vcc/h5vcc_settings.idl
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@

interface H5vccSettings {
boolean set(DOMString name, (long or DOMString) value);
DOMString getPersistentSetting(DOMString name, DOMString default_setting);
};

0 comments on commit e5ecb72

Please sign in to comment.