// Copyright 2020 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MEDIA_BASE_ASYNC_DESTROY_VIDEO_DECODER_H_ #define MEDIA_BASE_ASYNC_DESTROY_VIDEO_DECODER_H_ #include <memory> #include <type_traits> #include "media/base/video_decoder.h" namespace media { // Some VideoDecoder implementations must do non-synchronous cleanup before // they are destroyed. This wrapper implementation allows a VideoDecoder // to schedule its own cleanup tasks before its memory is released. // The underlying type must implement a static // `DestroyAsync(std::unique_ptr<T>)` function which fires any pending // callbacks, stops and destroys the decoder. After this call, external // resources (e.g. raw pointers) held by the decoder might be invalidated // immediately. So if the decoder is destroyed asynchronously (e.g. DeleteSoon), // external resources must be released in this call. template <typename T> class AsyncDestroyVideoDecoder final : public VideoDecoder { … }; } // namespace media #endif // MEDIA_BASE_ASYNC_DESTROY_VIDEO_DECODER_H_