mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Follow up from #21436 . That PR works for all embeddings except for Android, which creates a special JNI AssetResolver. Since the shell cannot recreate this resolver, update the logic to preserve existing resolvers instead.
52 lines
1.8 KiB
C++
52 lines
1.8 KiB
C++
// Copyright 2013 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef FLUTTER_ASSETS_ASSET_RESOLVER_H_
|
|
#define FLUTTER_ASSETS_ASSET_RESOLVER_H_
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "flutter/fml/macros.h"
|
|
#include "flutter/fml/mapping.h"
|
|
|
|
namespace flutter {
|
|
|
|
class AssetResolver {
|
|
public:
|
|
AssetResolver() = default;
|
|
|
|
virtual ~AssetResolver() = default;
|
|
|
|
virtual bool IsValid() const = 0;
|
|
|
|
//----------------------------------------------------------------------------
|
|
/// @brief 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.
|
|
///
|
|
/// @return Returns whether this resolver is valid after the asset manager
|
|
/// or run configuration is updated.
|
|
///
|
|
virtual bool IsValidAfterAssetManagerChange() const = 0;
|
|
|
|
[[nodiscard]] virtual std::unique_ptr<fml::Mapping> GetAsMapping(
|
|
const std::string& asset_name) const = 0;
|
|
|
|
private:
|
|
FML_DISALLOW_COPY_AND_ASSIGN(AssetResolver);
|
|
};
|
|
|
|
} // namespace flutter
|
|
|
|
#endif // FLUTTER_ASSETS_ASSET_RESOLVER_H_
|