From de3a92c801302771461b5d116829908b41341084 Mon Sep 17 00:00:00 2001 From: Madhura Jayaraman Date: Wed, 11 Sep 2024 11:47:19 -0700 Subject: [PATCH] Remove SB_API_VERSION < 17 checks from cobalt/ b/362374622 Change-Id: I4384ba5a2bc5cf6a6f1b37e1b0933901aaf80073 --- base/strings/string_util_starboard.h | 2 - base/threading/platform_thread_starboard.cc | 26 --------- cobalt/audio/audio_helpers.h | 11 ---- cobalt/base/wrap_main_starboard.h | 4 -- cobalt/browser/application.cc | 15 ----- cobalt/browser/user_agent_platform_info.cc | 56 ------------------- cobalt/browser/user_agent_platform_info.h | 3 - .../dom/captions/system_caption_settings.cc | 8 --- cobalt/dom/html_media_element.cc | 4 -- cobalt/dom/keyboard_event.cc | 2 - cobalt/dom/keyboard_event_test.cc | 2 - cobalt/dom/keycode.h | 2 - cobalt/h5vcc/h5vcc_accessibility.cc | 12 ---- cobalt/ui_navigation/interface.cc | 4 +- .../testing/mock_user_agent_platform_info.h | 5 -- cobalt/web/user_agent_platform_info.h | 3 - 16 files changed, 1 insertion(+), 158 deletions(-) diff --git a/base/strings/string_util_starboard.h b/base/strings/string_util_starboard.h index 90da5a8ce1ec..857cd6576207 100644 --- a/base/strings/string_util_starboard.h +++ b/base/strings/string_util_starboard.h @@ -16,9 +16,7 @@ #define BASE_STRING_UTIL_STARBOARD_H_ #include -#if SB_API_VERSION >= 16 #include -#endif #include "base/basictypes.h" #include "base/logging.h" diff --git a/base/threading/platform_thread_starboard.cc b/base/threading/platform_thread_starboard.cc index 3a7513fdf8a0..0b540daf4b57 100644 --- a/base/threading/platform_thread_starboard.cc +++ b/base/threading/platform_thread_starboard.cc @@ -39,11 +39,9 @@ void* ThreadFunc(void* params) { ThreadParams* thread_params = static_cast(params); PlatformThread::Delegate* delegate = thread_params->delegate; -#if SB_API_VERSION >= 16 if (kSbHasThreadPrioritySupport) { SbThreadSetPriority(thread_params->thread_priority); } -#endif // SB_API_VERSION >= 16 pthread_setname_np(pthread_self(), thread_params->thread_name.c_str()); absl::optional disallow_singleton; @@ -66,7 +64,6 @@ void* ThreadFunc(void* params) { return NULL; } -#if SB_API_VERSION >= 16 bool CreateThread(size_t stack_size, SbThreadPriority priority, bool joinable, @@ -106,30 +103,7 @@ bool CreateThread(size_t stack_size, return false; } -#else -bool CreateThread(size_t stack_size, - SbThreadPriority priority, - bool joinable, - const char* name, - PlatformThread::Delegate* delegate, - PlatformThreadHandle* thread_handle) { - ThreadParams* params = new ThreadParams; - params->delegate = delegate; - params->joinable = joinable; - SbThread thread = SbThreadCreate(stack_size, priority, kSbThreadNoAffinity, joinable, - name, ThreadFunc, params); - if (SbThreadIsValid(thread)) { - if (thread_handle) { - *thread_handle = PlatformThreadHandle(thread); - } - - return true; - } - - return false; -} -#endif // SB_API_VERSION >= 16 inline SbThreadPriority toSbPriority(ThreadType priority) { switch (priority) { diff --git a/cobalt/audio/audio_helpers.h b/cobalt/audio/audio_helpers.h index 8580b75ebcdf..0264933957c0 100644 --- a/cobalt/audio/audio_helpers.h +++ b/cobalt/audio/audio_helpers.h @@ -68,19 +68,8 @@ inline size_t GetSampleTypeSize(SampleType sample_type) { // an internal SampleType. If we are not running on starboard or using the // starboard media pipeline, then the preferred sample type is always float32. inline SampleType GetPreferredOutputSampleType() { -#if SB_API_VERSION >= 16 DCHECK(SbAudioSinkIsAudioSampleTypeSupported(kSbMediaAudioSampleTypeFloat32)); return kSampleTypeFloat32; -#else // SB_API_VERSION >= 16 - if (SbAudioSinkIsAudioSampleTypeSupported(kSbMediaAudioSampleTypeFloat32)) { - return kSampleTypeFloat32; - } - DCHECK(SbAudioSinkIsAudioSampleTypeSupported( - kSbMediaAudioSampleTypeInt16Deprecated)) - << "At least one starboard audio sample type must be supported if using " - "starboard media pipeline."; - return kSampleTypeInt16; -#endif // SB_API_VERSION >= 16 } #if defined(STARBOARD) diff --git a/cobalt/base/wrap_main_starboard.h b/cobalt/base/wrap_main_starboard.h index 7a85063edda6..25abdee3cc30 100644 --- a/cobalt/base/wrap_main_starboard.h +++ b/cobalt/base/wrap_main_starboard.h @@ -130,11 +130,7 @@ void BaseEventHandler(const SbEvent* event) { case kSbEventTypeOsNetworkDisconnected: case kSbEventTypeOsNetworkConnected: case kSbEventDateTimeConfigurationChanged: -#if SB_API_VERSION >= 16 case kSbEventTypeReserved1: -#else - case kSbEventTypeOnScreenKeyboardSuggestionsUpdated: -#endif // SB_API_VERSION >= 16 event_function(event); break; } diff --git a/cobalt/browser/application.cc b/cobalt/browser/application.cc index f708ebcacc33..d10cb82ab9cb 100644 --- a/cobalt/browser/application.cc +++ b/cobalt/browser/application.cc @@ -127,17 +127,10 @@ std::string GetDevServersListenIp() { // Default to INADDR_ANY std::string listen_ip(ip_v6 ? "::" : "0.0.0.0"); -#if SB_API_VERSION < 15 - // Desktop PCs default to loopback. - if (SbSystemGetDeviceType() == kSbSystemDeviceTypeDesktopPC) { - listen_ip = ip_v6 ? "::1" : "127.0.0.1"; - } -#else if (starboard::GetSystemPropertyString(kSbSystemPropertyDeviceType) == starboard::kSystemDeviceTypeDesktopPC) { listen_ip = ip_v6 ? "::1" : "127.0.0.1"; } -#endif #if defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES) base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); @@ -1176,11 +1169,7 @@ void Application::HandleStarboardEvent(const SbEvent* starboard_event) { case kSbEventTypeStop: case kSbEventTypeUser: case kSbEventTypeVerticalSync: -#if SB_API_VERSION >= 16 case kSbEventTypeReserved1: -#else - case kSbEventTypeOnScreenKeyboardSuggestionsUpdated: -#endif // SB_API_VERSION >= 16 DLOG(WARNING) << "Unhandled Starboard event of type: " << starboard_event->type; } @@ -1267,11 +1256,7 @@ void Application::OnApplicationEvent(SbEventType event_type, case kSbEventTypeOsNetworkDisconnected: case kSbEventTypeOsNetworkConnected: case kSbEventDateTimeConfigurationChanged: -#if SB_API_VERSION >= 16 case kSbEventTypeReserved1: -#else - case kSbEventTypeOnScreenKeyboardSuggestionsUpdated: -#endif // SB_API_VERSION >= 16 NOTREACHED() << "Unexpected event type: " << event_type; return; } diff --git a/cobalt/browser/user_agent_platform_info.cc b/cobalt/browser/user_agent_platform_info.cc index 5c0d65895531..a6563bf9b43d 100644 --- a/cobalt/browser/user_agent_platform_info.cc +++ b/cobalt/browser/user_agent_platform_info.cc @@ -110,47 +110,6 @@ void GetUserAgentInputMap( namespace { -#if SB_API_VERSION < 15 - -struct DeviceTypeName { - SbSystemDeviceType device_type; - char device_type_string[10]; -}; - -const DeviceTypeName kDeviceTypeStrings[] = { - {kSbSystemDeviceTypeBlueRayDiskPlayer, "BDP"}, - {kSbSystemDeviceTypeGameConsole, "GAME"}, - {kSbSystemDeviceTypeOverTheTopBox, "OTT"}, - {kSbSystemDeviceTypeSetTopBox, "STB"}, - {kSbSystemDeviceTypeTV, "TV"}, - {kSbSystemDeviceTypeAndroidTV, "ATV"}, - {kSbSystemDeviceTypeDesktopPC, "DESKTOP"}, - {kSbSystemDeviceTypeVideoProjector, "PROJECTOR"}, - {kSbSystemDeviceTypeUnknown, "UNKNOWN"}}; - -std::string CreateDeviceTypeString(SbSystemDeviceType device_type) { - for (auto& map : kDeviceTypeStrings) { - if (map.device_type == device_type) { - return std::string(map.device_type_string); - } - } - NOTREACHED(); - return "UNKNOWN"; -} - -#if !defined(COBALT_BUILD_TYPE_GOLD) -SbSystemDeviceType GetDeviceType(std::string device_type_string) { - for (auto& map : kDeviceTypeStrings) { - if (!SbStringCompareNoCase(map.device_type_string, - device_type_string.c_str())) { - return map.device_type; - } - } - return kSbSystemDeviceTypeUnknown; -} -#endif -#endif // SB_API_VERSION < 15 - static bool isAsciiAlphaDigit(int c) { return base::IsAsciiAlpha(c) || base::IsAsciiDigit(c); } @@ -320,15 +279,10 @@ void InitializeUserAgentPlatformInfoFields(UserAgentPlatformInfo& info) { info.set_aux_field(value); } -#if SB_API_VERSION >= 15 result = SbSystemGetProperty(kSbSystemPropertyDeviceType, value, kSystemPropertyMaxLength); SB_DCHECK(result); info.set_device_type(value); -#else - // Fill platform info if it is a hardware TV device. - info.set_device_type(SbSystemGetDeviceType()); -#endif // Chipset model number result = SbSystemGetProperty(kSbSystemPropertyChipsetModelNumber, value, @@ -395,11 +349,7 @@ void InitializeUserAgentPlatformInfoFields(UserAgentPlatformInfo& info) { info.set_original_design_manufacturer(input.second); LOG(INFO) << "Set original design manufacturer to " << input.second; } else if (!input.first.compare("device_type")) { -#if SB_API_VERSION < 15 - info.set_device_type(GetDeviceType(input.second)); -#else info.set_device_type(input.second); -#endif LOG(INFO) << "Set device type to " << input.second; } else if (!input.first.compare("chipset_model_number")) { info.set_chipset_model_number(input.second); @@ -485,12 +435,6 @@ void UserAgentPlatformInfo::set_original_design_manufacturer( } } -#if SB_API_VERSION < 15 -void UserAgentPlatformInfo::set_device_type(SbSystemDeviceType device_type) { - device_type_ = device_type; - device_type_string_ = CreateDeviceTypeString(device_type_); -} -#endif void UserAgentPlatformInfo::set_device_type(const std::string& device_type) { device_type_string_ = device_type; } diff --git a/cobalt/browser/user_agent_platform_info.h b/cobalt/browser/user_agent_platform_info.h index 193b7691bee9..d0a5cd1f5e23 100644 --- a/cobalt/browser/user_agent_platform_info.h +++ b/cobalt/browser/user_agent_platform_info.h @@ -97,9 +97,6 @@ class UserAgentPlatformInfo : public web::UserAgentPlatformInfo { void set_os_name_and_version(const std::string& os_name_and_version); void set_original_design_manufacturer( base::Optional original_design_manufacturer); -#if SB_API_VERSION < 15 - void set_device_type(SbSystemDeviceType device_type); -#endif void set_device_type(const std::string& device_type); void set_chipset_model_number( base::Optional chipset_model_number); diff --git a/cobalt/dom/captions/system_caption_settings.cc b/cobalt/dom/captions/system_caption_settings.cc index b0f978f631ff..185502ecb4df 100644 --- a/cobalt/dom/captions/system_caption_settings.cc +++ b/cobalt/dom/captions/system_caption_settings.cc @@ -473,7 +473,6 @@ bool SystemCaptionSettings::is_enabled() { void SystemCaptionSettings::set_is_enabled(bool active) { DCHECK(supports_set_enabled()); -#if SB_API_VERSION >= 16 auto accessibility_api = static_cast( SbSystemGetExtension(kStarboardExtensionAccessibilityName)); @@ -483,9 +482,6 @@ void SystemCaptionSettings::set_is_enabled(bool active) { accessibility_api->version >= 1) { accessibility_api->SetCaptionsEnabled(active); } -#else // SB_API_VERSION >= 16 - SbAccessibilitySetCaptionsEnabled(active); -#endif // SB_API_VERSION >= 16 } bool SystemCaptionSettings::supports_is_enabled() { @@ -643,7 +639,6 @@ const char* SystemCaptionSettings::CaptionOpacityPercentageToString( bool SystemCaptionSettings::GetCaptionSettings( SbAccessibilityCaptionSettings* caption_settings) { -#if SB_API_VERSION >= 16 auto accessibility_api = static_cast( SbSystemGetExtension(kStarboardExtensionAccessibilityName)); @@ -655,9 +650,6 @@ bool SystemCaptionSettings::GetCaptionSettings( } else { return false; } -#else // SB_API_VERSION >= 16 - return SbAccessibilityGetCaptionSettings(caption_settings); -#endif // SB_API_VERSION >= 16 } } // namespace captions diff --git a/cobalt/dom/html_media_element.cc b/cobalt/dom/html_media_element.cc index 2be5f86f59ba..e1629285e7ba 100644 --- a/cobalt/dom/html_media_element.cc +++ b/cobalt/dom/html_media_element.cc @@ -708,16 +708,12 @@ void HTMLMediaElement::ScheduleEvent(const scoped_refptr& event) { } std::string HTMLMediaElement::h5vcc_audio_connectors() const { -#if SB_API_VERSION >= 15 if (!player_) { return ""; } std::vector configs = player_->GetAudioConnectors(); return base::JoinString(configs, ";"); -#else // SB_API_VERSION >= 15 - return ""; -#endif // SB_API_VERSION >= 15 } void HTMLMediaElement::CreateMediaPlayer() { diff --git a/cobalt/dom/keyboard_event.cc b/cobalt/dom/keyboard_event.cc index ad854118b1db..37cda49e9a7d 100644 --- a/cobalt/dom/keyboard_event.cc +++ b/cobalt/dom/keyboard_event.cc @@ -337,10 +337,8 @@ std::string KeyboardEvent::NonPrintableKey(int32_t key_code) const { return "MediaStop"; case keycode::kMediaPlayPause: return "MediaPlayPause"; -#if SB_API_VERSION >= 15 case keycode::kMediaRecord: return "MediaRecord"; -#endif case keycode::kMediaLaunchMail: return "LaunchMail"; case keycode::kMediaLaunchMediaSelect: diff --git a/cobalt/dom/keyboard_event_test.cc b/cobalt/dom/keyboard_event_test.cc index 0f9843e72881..c189ccc1ddc4 100644 --- a/cobalt/dom/keyboard_event_test.cc +++ b/cobalt/dom/keyboard_event_test.cc @@ -135,14 +135,12 @@ TEST_F(KeyboardEventTest, CanGetKeyIdentifierAndKeyAndCode) { EXPECT_EQ(keyboard_event_space->key(), " "); EXPECT_EQ(keyboard_event_space->code(), "Space"); -#if SB_API_VERSION >= 15 init.set_key_code(keycode::kMediaRecord); scoped_refptr keyboard_event_record = new KeyboardEvent("keydown", init); EXPECT_EQ(keyboard_event_record->key_identifier(), "MediaRecord"); EXPECT_EQ(keyboard_event_record->key(), "MediaRecord"); EXPECT_EQ(keyboard_event_record->code(), "MediaRecord"); -#endif } TEST_F(KeyboardEventTest, CanGetAltKey) { diff --git a/cobalt/dom/keycode.h b/cobalt/dom/keycode.h index afda18fa6df4..5623e52f745b 100644 --- a/cobalt/dom/keycode.h +++ b/cobalt/dom/keycode.h @@ -200,9 +200,7 @@ enum { // Not present in Windows virtual key codes, but would be used by the client. kMediaRewind = 0xE3, kMediaFastForward = 0xE4, -#if SB_API_VERSION >= 15 kMediaRecord = 0x1A0, -#endif }; } // namespace keycode diff --git a/cobalt/h5vcc/h5vcc_accessibility.cc b/cobalt/h5vcc/h5vcc_accessibility.cc index 70b09024293d..0e5861c0ef5f 100644 --- a/cobalt/h5vcc/h5vcc_accessibility.cc +++ b/cobalt/h5vcc/h5vcc_accessibility.cc @@ -74,7 +74,6 @@ void H5vccAccessibility::set_built_in_screen_reader(bool value) { bool H5vccAccessibility::high_contrast_text() const { SbAccessibilityDisplaySettings settings; memset(&settings, 0, sizeof(settings)); -#if SB_API_VERSION >= 16 auto accessibility_api = static_cast( SbSystemGetExtension(kStarboardExtensionAccessibilityName)); @@ -88,11 +87,6 @@ bool H5vccAccessibility::high_contrast_text() const { } else { return false; } -#else // SB_API_VERSION >= 16 - if (!SbAccessibilityGetDisplaySettings(&settings)) { - return false; - } -#endif // SB_API_VERSION >= 16 return settings.is_high_contrast_text_enabled; } @@ -103,7 +97,6 @@ bool H5vccAccessibility::text_to_speech() const { } SbAccessibilityTextToSpeechSettings settings; memset(&settings, 0, sizeof(settings)); -#if SB_API_VERSION >= 16 auto accessibility_api = static_cast( SbSystemGetExtension(kStarboardExtensionAccessibilityName)); @@ -117,11 +110,6 @@ bool H5vccAccessibility::text_to_speech() const { } else { return false; } -#else // SB_API_VERSION >= 16 - if (!SbAccessibilityGetTextToSpeechSettings(&settings)) { - return false; - } -#endif // SB_API_VERSION >= 16 return settings.has_text_to_speech_setting && settings.is_text_to_speech_enabled; } diff --git a/cobalt/ui_navigation/interface.cc b/cobalt/ui_navigation/interface.cc index e4ae99fcff26..50a78c71bad1 100644 --- a/cobalt/ui_navigation/interface.cc +++ b/cobalt/ui_navigation/interface.cc @@ -14,12 +14,10 @@ #include "cobalt/ui_navigation/interface.h" -#include "starboard/common/spin_lock.h" -#if SB_API_VERSION >= 16 #include +#include "starboard/common/spin_lock.h" #include "starboard/system.h" -#endif // SB_API_VERSION namespace cobalt { namespace ui_navigation { diff --git a/cobalt/web/testing/mock_user_agent_platform_info.h b/cobalt/web/testing/mock_user_agent_platform_info.h index c8eeb2295448..16b37927a247 100644 --- a/cobalt/web/testing/mock_user_agent_platform_info.h +++ b/cobalt/web/testing/mock_user_agent_platform_info.h @@ -40,11 +40,6 @@ class MockUserAgentPlatformInfo : public web::UserAgentPlatformInfo { base::Optional original_design_manufacturer() const override { return optional_empty_string_; } -#if SB_API_VERSION < 15 - SbSystemDeviceType device_type() const override { - return kSbSystemDeviceTypeUnknown; - } -#endif const std::string& device_type_string() const override { return empty_string_; } diff --git a/cobalt/web/user_agent_platform_info.h b/cobalt/web/user_agent_platform_info.h index f523addd888d..e75faa902fa6 100644 --- a/cobalt/web/user_agent_platform_info.h +++ b/cobalt/web/user_agent_platform_info.h @@ -32,9 +32,6 @@ class UserAgentPlatformInfo { virtual const std::string& starboard_version() const = 0; virtual const std::string& os_name_and_version() const = 0; virtual base::Optional original_design_manufacturer() const = 0; -#if SB_API_VERSION < 15 - virtual SbSystemDeviceType device_type() const = 0; -#endif virtual const std::string& device_type_string() const = 0; virtual base::Optional chipset_model_number() const = 0; virtual base::Optional model_year() const = 0;