Skip to content

Commit c7871c3

Browse files
[WebKitSettings] Add API for OpportunisticSweepingAndGarbageCollectionEnabled
1 parent 9dc80fd commit c7871c3

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ enum {
198198
PROP_WEBRTC_UDP_PORTS_RANGE,
199199
PROP_ENABLE_NON_COMPOSITED_WEBGL,
200200
PROP_SCREEN_SUPPORTS_HDR,
201+
PROP_OPPORTUNISTIC_SWEEPING_AND_GC,
201202
N_PROPERTIES,
202203
};
203204

@@ -459,6 +460,9 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
459460
case PROP_SCREEN_SUPPORTS_HDR:
460461
webkit_settings_set_screen_supports_hdr(settings, g_value_get_boolean(value));
461462
break;
463+
case PROP_OPPORTUNISTIC_SWEEPING_AND_GC:
464+
webkit_settings_set_opportunistic_sweeping_and_gc(settings, g_value_get_boolean(value));
465+
break;
462466
default:
463467
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
464468
break;
@@ -700,6 +704,9 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
700704
case PROP_SCREEN_SUPPORTS_HDR:
701705
g_value_set_boolean(value, webkit_settings_get_screen_supports_hdr(settings));
702706
break;
707+
case PROP_OPPORTUNISTIC_SWEEPING_AND_GC:
708+
g_value_set_boolean(value, webkit_settings_get_opportunistic_sweeping_and_gc(settings));
709+
break;
703710
default:
704711
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
705712
break;
@@ -1895,6 +1902,20 @@ static void webkit_settings_class_init(WebKitSettingsClass* klass)
18951902
FALSE,
18961903
readWriteConstructParamFlags);
18971904

1905+
/**
1906+
* WebKitSettings:opportunistic-sweeping-and-gc:
1907+
*
1908+
* Enable or disable opportunistic sweeping and garbage collection.
1909+
* GC timers will be postponed if any critical tasks are pending.
1910+
*
1911+
*/
1912+
sObjProperties[PROP_OPPORTUNISTIC_SWEEPING_AND_GC] = g_param_spec_boolean(
1913+
"opportunistic-sweeping-and-gc",
1914+
_("Enable opportunistic sweeping and garbage collection"),
1915+
_("Whether opportunistic sweeping and garbage collection should be enabled"),
1916+
FEATURE_DEFAULT(OpportunisticSweepingAndGarbageCollectionEnabled),
1917+
readWriteConstructParamFlags);
1918+
18981919
g_object_class_install_properties(gObjectClass, N_PROPERTIES, sObjProperties);
18991920
}
19001921

@@ -4958,3 +4979,38 @@ webkit_settings_set_screen_supports_hdr(WebKitSettings* settings, gboolean scree
49584979
priv->preferences->setScreenSupportsHDR(screenSupportsHDR);
49594980
g_object_notify_by_pspec(G_OBJECT(settings), sObjProperties[PROP_SCREEN_SUPPORTS_HDR]);
49604981
}
4982+
4983+
/**
4984+
* webkit_settings_get_opportunistic_sweeping_and_gc:
4985+
* @settings: a #WebKitSettings
4986+
*
4987+
* Get the #WebKitSettings:opportunistic-sweeping-and-gc property.
4988+
*
4989+
* Returns: %TRUE if opportunistic sweeping and garbage collection is enabled or %FALSE otherwise.
4990+
*/
4991+
gboolean
4992+
webkit_settings_get_opportunistic_sweeping_and_gc(WebKitSettings* settings)
4993+
{
4994+
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
4995+
return settings->priv->preferences->opportunisticSweepingAndGarbageCollectionEnabled();
4996+
}
4997+
4998+
/**
4999+
* webkit_settings_set_opportunistic_sweeping_and_gc:
5000+
* @settings: a #WebKitSettings
5001+
* @enabled: Value to be set
5002+
*
5003+
* Set the #WebKitSettings:opportunistic-sweeping-and-gc property.
5004+
*/
5005+
void
5006+
webkit_settings_set_opportunistic_sweeping_and_gc(WebKitSettings* settings, gboolean enabled)
5007+
{
5008+
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
5009+
WebKitSettingsPrivate* priv = settings->priv;
5010+
bool currentValue = priv->preferences->opportunisticSweepingAndGarbageCollectionEnabled();
5011+
if (currentValue == enabled)
5012+
return;
5013+
5014+
priv->preferences->setOpportunisticSweepingAndGarbageCollectionEnabled(enabled);
5015+
g_object_notify_by_pspec(G_OBJECT(settings), sObjProperties[PROP_OPPORTUNISTIC_SWEEPING_AND_GC]);
5016+
}

Source/WebKit/UIProcess/API/glib/WebKitSettings.h.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,12 @@ WEBKIT_API void
643643
webkit_settings_set_screen_supports_hdr (WebKitSettings* settings,
644644
gboolean screenSupportsHDR);
645645

646+
WEBKIT_API gboolean
647+
webkit_settings_get_opportunistic_sweeping_and_gc (WebKitSettings* settings);
648+
WEBKIT_API void
649+
webkit_settings_set_opportunistic_sweeping_and_gc (WebKitSettings* settings,
650+
gboolean enabled);
651+
646652
G_END_DECLS
647653

648654
#endif /* WebKitSettings_h */

0 commit comments

Comments
 (0)