Flutter Engine
flutter::AssetManager Class Referencefinal

#include <asset_manager.h>

Inheritance diagram for flutter::AssetManager:
flutter::AssetResolver

Public Member Functions

 AssetManager ()
 
 ~AssetManager () override
 
void PushFront (std::unique_ptr< AssetResolver > resolver)
 
void PushBack (std::unique_ptr< AssetResolver > resolver)
 
std::deque< std::unique_ptr< AssetResolver > > TakeResolvers ()
 
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 occurance of tool failures due to repeated network flakes caused by damaged cables or hereto unknown bugs in the Dart HTTP server implementation. More...
 
std::unique_ptr< fml::MappingGetAsMapping (const std::string &asset_name) const override
 
- Public Member Functions inherited from flutter::AssetResolver
 AssetResolver ()=default
 
virtual ~AssetResolver ()=default
 

Detailed Description

Definition at line 18 of file asset_manager.h.

Constructor & Destructor Documentation

◆ AssetManager()

flutter::AssetManager::AssetManager ( )
default

◆ ~AssetManager()

flutter::AssetManager::~AssetManager ( )
overridedefault

Member Function Documentation

◆ GetAsMapping()

std::unique_ptr< fml::Mapping > flutter::AssetManager::GetAsMapping ( const std::string &  asset_name) const
overridevirtual

Implements flutter::AssetResolver.

Definition at line 37 of file asset_manager.cc.

References FML_DLOG, and TRACE_EVENT1.

38  {
39  if (asset_name.size() == 0) {
40  return nullptr;
41  }
42  TRACE_EVENT1("flutter", "AssetManager::GetAsMapping", "name",
43  asset_name.c_str());
44  for (const auto& resolver : resolvers_) {
45  auto mapping = resolver->GetAsMapping(asset_name);
46  if (mapping != nullptr) {
47  return mapping;
48  }
49  }
50  FML_DLOG(WARNING) << "Could not find asset: " << asset_name;
51  return nullptr;
52 }
#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val)
Definition: trace_event.h:79
#define FML_DLOG(severity)
Definition: logging.h:85

◆ IsValid()

bool flutter::AssetManager::IsValid ( ) const
overridevirtual

Implements flutter::AssetResolver.

Definition at line 55 of file asset_manager.cc.

55  {
56  return resolvers_.size() > 0;
57 }

◆ IsValidAfterAssetManagerChange()

bool flutter::AssetManager::IsValidAfterAssetManagerChange ( ) const
overridevirtual

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 occurance 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 60 of file asset_manager.cc.

60  {
61  return false;
62 }

◆ PushBack()

void flutter::AssetManager::PushBack ( std::unique_ptr< AssetResolver resolver)

Definition at line 24 of file asset_manager.cc.

24  {
25  if (resolver == nullptr || !resolver->IsValid()) {
26  return;
27  }
28 
29  resolvers_.push_back(std::move(resolver));
30 }

◆ PushFront()

void flutter::AssetManager::PushFront ( std::unique_ptr< AssetResolver resolver)

Definition at line 16 of file asset_manager.cc.

16  {
17  if (resolver == nullptr || !resolver->IsValid()) {
18  return;
19  }
20 
21  resolvers_.push_front(std::move(resolver));
22 }

◆ TakeResolvers()

std::deque< std::unique_ptr< AssetResolver > > flutter::AssetManager::TakeResolvers ( )

Definition at line 32 of file asset_manager.cc.

32  {
33  return std::move(resolvers_);
34 }

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