Changes from review.

This commit is contained in:
Kevin Ring 2025-07-30 11:03:23 +10:00
parent 7f07bc93a3
commit c4a14c54cc
3 changed files with 20 additions and 11 deletions

View File

@ -2,9 +2,19 @@
### ? - ?
##### Breaking Changes :mega:
- The `RasterOverlayTileProvider` and `QuadtreeRasterOverlayTileProvider` constructors now require a `CreditSystem` parameter.
##### Additions :tada:
- Added `ImplicitTilingUtilities::getParentID` to derive the ID of the parent for a given tile ID.
- `IonRasterOverlay` now automatically handles refreshing the Cesium ion asset token as needed.
- Added `CesiumIonAssetAccessor`, which is useful for implementing token refresh for Cesium ion assets.
- Added `refreshTileProviderWithNewKey` method to `BingMapsRasterOverlay`.
- Added `refreshTileProviderWithNewUrlAndHeaders` method to `TileMapServiceRasterOverlay`.
- Added `getAsyncDestructionCompleteEvent` method to `RasterOverlayTileProvider`.
- Added `getCreditSystem` method to `RasterOverlayTileProvider`.
### v0.49.0 - 2025-07-01

View File

@ -89,7 +89,7 @@ private:
std::string _assetEndpointUrl;
std::vector<IAssetAccessor::THeader> _assetEndpointHeaders;
std::optional<std::function<Future<void>(const UpdatedToken&)>>
_updatedTokenCallback;
_maybeUpdatedTokenCallback;
std::optional<SharedFuture<UpdatedToken>> _tokenRefreshInProgress;
};

View File

@ -38,7 +38,7 @@ CesiumIonAssetAccessor::CesiumIonAssetAccessor(
_pAggregatedAccessor(pAggregatedAccessor),
_assetEndpointUrl(assetEndpointUrl),
_assetEndpointHeaders(assetEndpointHeaders),
_updatedTokenCallback(std::move(updatedTokenCallback)),
_maybeUpdatedTokenCallback(std::move(updatedTokenCallback)),
_tokenRefreshInProgress() {}
CesiumAsync::Future<std::shared_ptr<CesiumAsync::IAssetRequest>>
@ -52,7 +52,7 @@ CesiumIonAssetAccessor::get(
[pThis = this->shared_from_this()](
const CesiumAsync::AsyncSystem& asyncSystem,
std::shared_ptr<CesiumAsync::IAssetRequest>&& pRequest) {
if (!pThis->_updatedTokenCallback) {
if (!pThis->_maybeUpdatedTokenCallback) {
// The owner has been destroyed, so just return the
// original (failed) request.
return asyncSystem.createResolvedFuture(std::move(pRequest));
@ -155,7 +155,7 @@ void CesiumIonAssetAccessor::tick() noexcept {
}
void CesiumIonAssetAccessor::notifyOwnerIsBeingDestroyed() {
this->_updatedTokenCallback.reset();
this->_maybeUpdatedTokenCallback.reset();
}
namespace {
@ -250,7 +250,7 @@ CesiumIonAssetAccessor::refreshTokenInMainThread(
.thenInMainThread([this, asyncSystem](
std::shared_ptr<CesiumAsync::IAssetRequest>&&
pIonRequest) {
if (!this->_updatedTokenCallback) {
if (!this->_maybeUpdatedTokenCallback) {
// Owner is already destroyed.
return asyncSystem.createResolvedFuture(UpdatedToken());
}
@ -269,12 +269,12 @@ CesiumIonAssetAccessor::refreshTokenInMainThread(
uint16_t statusCode = pIonResponse->statusCode();
if (statusCode >= 200 && statusCode < 300) {
auto accessToken =
std::optional<std::string> maybeAccessToken =
getNewAccessToken(pIonResponse, this->_pLogger);
if (accessToken) {
std::string authorizationHeader = "Bearer " + *accessToken;
UpdatedToken update{*accessToken, authorizationHeader};
return this->_updatedTokenCallback.value()(update)
if (maybeAccessToken) {
std::string authorizationHeader = "Bearer " + *maybeAccessToken;
UpdatedToken update{*maybeAccessToken, authorizationHeader};
return (*this->_maybeUpdatedTokenCallback)(update)
.thenImmediately([update,
pLogger = this->_pLogger,
url = this->_assetEndpointUrl]() {
@ -285,7 +285,6 @@ CesiumIonAssetAccessor::refreshTokenInMainThread(
return update;
});
} else {
// This error is logged from within `getNewAccessToken`.
return asyncSystem.createResolvedFuture(UpdatedToken());