-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[core] Modularize FileSource codebase #15768
Conversation
04ca71c
to
2cace7a
Compare
0a7262a
to
07c6b5d
Compare
@tobrun @LukasPaczos could you please take a look at Android part : bb2c870 @julianrex @fabian-guerra similarly, could you check darwin related changes: d8eb4e7 |
c6887a8
to
84e2f00
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Further, we can reconsider using actor
// TODO: the callback should include a potential error info when https://github.com/mapbox/mapbox-gl-native/issues/14759 is resolved | ||
using PathChangeCallback = std::function<void ()>; | ||
// FileSource overrides | ||
std::unique_ptr<AsyncRequest> request(const Resource&, Callback) override; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Callback
I'd also substitute with the aliased type
|
||
FileSourceManager* FileSourceManager::get() noexcept { | ||
static DefaultFileSourceManagerImpl instance; | ||
return &instance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is non-nullable, why not return a reference insteaf of a pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two reasons:
- API style. Layer manager uses same pattern
- Map don't even need file source manager, for example, when fully inlined style is used (map.cpp)
FileSourceManager::get() ? FileSourceManager::get()->getFileSource(ResourceLoader, resourceOptions) : nullptr,
|
||
namespace mbgl { | ||
|
||
class DefaultFileSourceManagerImpl final : public FileSourceManager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only issue I see with this is it is a linking time dependency, meaning that if you don't implement FileSourceManager::get()
it will not link. Would't be better if the platform could simple register the factories or not explicitly during initialization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with keeping like this btw and migrate everything later.
bdd3f7c
to
315d917
Compare
315d917
to
b208892
Compare
* [core] Introduce FileSourceManager and use it for default platform impl - Add `FileSourceManager` interface that provides access to `FileSource` instances and means of registering / unregistering `FileSource` factories - Split `DefaultFileSource` into smaller parts - Add `DatabaseFileSource` interface and it's default implementation - Remove inter-dependencies between concrete `FileSource` classes * [build] Add files to next build system * [core] Add generic property setters / getters * [core] Remove setOnlineStatus from OnlineFileSource interface * [core] Hide threading implementation details from DatabaseFileSource interface * [core] Make DB file source methods virtual * [core] Add documentation for DatabaseFileSource and rename one method * [core] Use simple callback instead of ActorRef * [core] Remove ActorRef from OnlineFileSource public header * [core] Add callback to FileSource::forward async API * [core] Pass OfflineRegionDefinition by value * [core] Update tests to use modular file sources * [core] Update unit tests * [core] Update unit tests after rebase * [core] Backport low prio fix for cached requests * [core] Backport pack database * [core] Return removed factory from unRegisterFileSourceFactory * [core] Rename shadowed args in onlinefilesource * [core] Remove simple std::function callback aliases * [core] Expose online file source property keys in public header file * [test-runner] Add proxy file source test runner * [cache] Update mbgl-cache utility to use new file source * [metrics] Rebaseline binary size metrics * [offline] Update offline utility * [core] Update changelog
Use new interface for android jni adaptation classes.
b208892
to
e1ed063
Compare
* [core] Introduce FileSourceManager and use it for default platform impl - Add `FileSourceManager` interface that provides access to `FileSource` instances and means of registering / unregistering `FileSource` factories - Split `DefaultFileSource` into smaller parts - Add `DatabaseFileSource` interface and it's default implementation - Remove inter-dependencies between concrete `FileSource` classes * [build] Add files to next build system * [core] Add generic property setters / getters * [core] Remove setOnlineStatus from OnlineFileSource interface * [core] Hide threading implementation details from DatabaseFileSource interface * [core] Make DB file source methods virtual * [core] Add documentation for DatabaseFileSource and rename one method * [core] Use simple callback instead of ActorRef * [core] Remove ActorRef from OnlineFileSource public header * [core] Add callback to FileSource::forward async API * [core] Pass OfflineRegionDefinition by value * [core] Update tests to use modular file sources * [core] Update unit tests * [core] Update unit tests after rebase * [core] Backport low prio fix for cached requests * [core] Backport pack database * [core] Return removed factory from unRegisterFileSourceFactory * [core] Rename shadowed args in onlinefilesource * [core] Remove simple std::function callback aliases * [core] Expose online file source property keys in public header file * [test-runner] Add proxy file source test runner * [cache] Update mbgl-cache utility to use new file source * [metrics] Rebaseline binary size metrics * [offline] Update offline utility * [core] Update changelog
This reverts commit 879c44f.
FileSource modularization
At the moment, gl-native has monolithic
FileSource
codebase that suffers from following issues:FileSource
implementation and override default backends (offline, local file, asset file sources)FileSource
naming is confusing, as we have manySomethingSource
classes and most of them have nothing to do withFileSource
codeThis PR aims to modularize
FileSource
codebase and introduces following changes:FileSourceManager
interface that provides access toFileSource
instances and means of registering / unregisteringFileSource
factoriesDefaultFileSource
into smaller partsDatabaseFileSource
interface and it's default implementationFileSource
classesMainResourceLoader
that acts as a dispatcher and works on thread that requested it.TODO:
/next
build systemIdentified improvements for follow-up PRs
#include <mbgl/storage/sqlite3.hpp>
headers in Android FileSource implFileSource
and other related classes toResourceProvider
to avoid confusion with GeoJSONSource, RasterSource, VectorSource, CustomGeometrySource and other *Sources.AssetResourceProvider
,FileSystemResourceProvider
,NetworkResourceProvider
...gl-native
can be built without features that are not required, for instance:MBGL_WITH_FILESYSTEM_RESOURCE_PROVIDER
,MBGL_WITH_DATABASE_RESOURCE_PROVIDER
etc.base::PostTask*