Flutter Engine
 
Loading...
Searching...
No Matches
flutter::testing::ThreadCheckingAssetResolver Class Reference
Inheritance diagram for flutter::testing::ThreadCheckingAssetResolver:
flutter::AssetResolver

Public Member Functions

 ThreadCheckingAssetResolver (std::shared_ptr< fml::ConcurrentMessageLoop > concurrent_loop)
 
bool IsValid () const override
 
bool IsValidAfterAssetManagerChange () const override
 Certain asset resolvers are still valid after the asset manager is replaced before a hot reload, or after a new run configuration is created during a hot restart. By preserving these resolvers and re-inserting them into the new resolver or run configuration, the tooling can avoid needing to sync all application assets through the Dart devFS upon connecting to the VM Service. Besides improving the startup performance of running a Flutter application, it also reduces the occurrence of tool failures due to repeated network flakes caused by damaged cables or hereto unknown bugs in the Dart HTTP server implementation.
 
AssetResolverType GetType () const
 Gets the type of AssetResolver this is. Types are defined in AssetResolverType.
 
std::unique_ptr< fml::MappingGetAsMapping (const std::string &asset_name) const override
 
bool operator== (const AssetResolver &other) const override
 
- Public Member Functions inherited from flutter::AssetResolver
 AssetResolver ()=default
 
virtual ~AssetResolver ()=default
 
virtual const AssetManageras_asset_manager () const
 
virtual const APKAssetProvideras_apk_asset_provider () const
 
virtual const DirectoryAssetBundleas_directory_asset_bundle () const
 
virtual std::vector< std::unique_ptr< fml::Mapping > > GetAsMappings (const std::string &asset_pattern, const std::optional< std::string > &subdir) const
 Same as GetAsMapping() but returns mappings for all files who's name matches a given pattern. Returns empty vector if no matching assets are found.
 
bool operator!= (const AssetResolver &other) const
 

Public Attributes

std::vector< std::string > mapping_requests
 

Additional Inherited Members

- Public Types inherited from flutter::AssetResolver
enum  AssetResolverType {
  kAssetManager ,
  kApkAssetProvider ,
  kDirectoryAssetBundle
}
 Identifies the type of AssetResolver an instance is. More...
 

Detailed Description

Definition at line 307 of file shell_unittests.cc.

Constructor & Destructor Documentation

◆ ThreadCheckingAssetResolver()

flutter::testing::ThreadCheckingAssetResolver::ThreadCheckingAssetResolver ( std::shared_ptr< fml::ConcurrentMessageLoop concurrent_loop)
inlineexplicit

Definition at line 309 of file shell_unittests.cc.

311 : concurrent_loop_(std::move(concurrent_loop)) {}

Member Function Documentation

◆ GetAsMapping()

std::unique_ptr< fml::Mapping > flutter::testing::ThreadCheckingAssetResolver::GetAsMapping ( const std::string &  asset_name) const
inlineoverridevirtual

Implements flutter::AssetResolver.

Definition at line 325 of file shell_unittests.cc.

326 {
327 if (asset_name == "FontManifest.json" ||
328 asset_name == "NativeAssetsManifest.json") {
329 // This file is loaded directly by the engine.
330 return nullptr;
331 }
332 mapping_requests.push_back(asset_name);
333 EXPECT_TRUE(concurrent_loop_->RunsTasksOnCurrentThread())
335 return nullptr;
336 }
std::string BacktraceHere(size_t offset)
Definition backtrace.cc:43

References fml::BacktraceHere(), and mapping_requests.

◆ GetType()

AssetResolverType flutter::testing::ThreadCheckingAssetResolver::GetType ( ) const
inlinevirtual

Gets the type of AssetResolver this is. Types are defined in AssetResolverType.

Returns
Returns the AssetResolverType that this resolver is.

Implements flutter::AssetResolver.

Definition at line 320 of file shell_unittests.cc.

References flutter::AssetResolver::kApkAssetProvider.

◆ IsValid()

bool flutter::testing::ThreadCheckingAssetResolver::IsValid ( ) const
inlineoverridevirtual

Implements flutter::AssetResolver.

Definition at line 314 of file shell_unittests.cc.

314{ return true; }

◆ IsValidAfterAssetManagerChange()

bool flutter::testing::ThreadCheckingAssetResolver::IsValidAfterAssetManagerChange ( ) const
inlineoverridevirtual

Certain asset resolvers are still valid after the asset manager is replaced before a hot reload, or after a new run configuration is created during a hot restart. By preserving these resolvers and re-inserting them into the new resolver or run configuration, the tooling can avoid needing to sync all application assets through the Dart devFS upon connecting to the VM Service. Besides improving the startup performance of running a Flutter application, it also reduces the occurrence of tool failures due to repeated network flakes caused by damaged cables or hereto unknown bugs in the Dart HTTP server implementation.

Returns
Returns whether this resolver is valid after the asset manager or run configuration is updated.

Implements flutter::AssetResolver.

Definition at line 317 of file shell_unittests.cc.

317{ return true; }

◆ operator==()

bool flutter::testing::ThreadCheckingAssetResolver::operator== ( const AssetResolver other) const
inlineoverridevirtual

Implements flutter::AssetResolver.

Definition at line 340 of file shell_unittests.cc.

340 {
341 return this == &other;
342 }

Member Data Documentation

◆ mapping_requests

std::vector<std::string> flutter::testing::ThreadCheckingAssetResolver::mapping_requests
mutable

Definition at line 338 of file shell_unittests.cc.

Referenced by GetAsMapping().


The documentation for this class was generated from the following file: