Skip to content

Commit

Permalink
Optionally avoid disk cache check if product is disabled
Browse files Browse the repository at this point in the history
Reviewed By: kartavya-ramnani

Differential Revision: D65215578

fbshipit-source-id: 098275e89f07bd0fa2c2895841424d3963af2dd9
  • Loading branch information
Artem Kholodnyi authored and facebook-github-bot committed Oct 30, 2024
1 parent 78806f8 commit f224fe7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package com.facebook.fresco.vito.core

import com.facebook.common.callercontext.ContextChain
import com.facebook.common.internal.Supplier
import com.facebook.common.internal.Suppliers

Expand Down Expand Up @@ -51,6 +52,13 @@ constructor(override val prefetchConfig: PrefetchConfig = DefaultPrefetchConfig(

override fun experimentalDynamicSizeDisableWhenAppIsStarting(): Boolean = false

override fun experimentalDynamicSizeCheckIfProductIsEnabled(): Boolean = false

override fun experimentalDynamicSizeIsProductEnabled(
callerContext: Any?,
contextChain: ContextChain?
): Boolean = true

open class DefaultPrefetchConfig : PrefetchConfig {
override fun prefetchInOnPrepare(): Boolean = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package com.facebook.fresco.vito.core

import com.facebook.common.callercontext.ContextChain
import com.facebook.common.internal.Supplier

interface FrescoVitoConfig {
Expand Down Expand Up @@ -47,4 +48,11 @@ interface FrescoVitoConfig {
fun isAppStarting(): Boolean

fun experimentalDynamicSizeDisableWhenAppIsStarting(): Boolean

fun experimentalDynamicSizeCheckIfProductIsEnabled(): Boolean

fun experimentalDynamicSizeIsProductEnabled(
callerContext: Any?,
contextChain: ContextChain?
): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ object FrescoVitoImage2Spec {
// We don't want to check cache if we are running on the main thread
// By default uses the original URL
forceKeepOriginalSize.set(!experimentalDynamicSizeOnPrepareMainThreadVito2())
} else if (isProductEnabled(callerContext, contextChain) == false) {
forceKeepOriginalSize.set(true)
} else {
forceKeepOriginalSize.set(
FrescoVitoProvider.getImagePipeline()
Expand Down Expand Up @@ -211,6 +213,14 @@ object FrescoVitoImage2Spec {
}
}

private fun isProductEnabled(callerContext: Any?, contextChain: ContextChain?): Boolean? {
val config = FrescoVitoProvider.getConfig()
if (!config.experimentalDynamicSizeCheckIfProductIsEnabled()) {
return null
}
return config.experimentalDynamicSizeIsProductEnabled(callerContext, contextChain)
}

@JvmStatic
@OnMount
fun onMount(
Expand Down

0 comments on commit f224fe7

Please sign in to comment.