// Copyright 2018 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_MOJO_SERVICES_DEFERRED_DESTROY_UNIQUE_RECEIVER_SET_H_ #define MEDIA_MOJO_SERVICES_DEFERRED_DESTROY_UNIQUE_RECEIVER_SET_H_ #include <stdint.h> #include <map> #include <memory> #include "base/functional/bind.h" #include "base/logging.h" #include "base/memory/ptr_util.h" #include "base/memory/weak_ptr.h" #include "base/task/bind_post_task.h" #include "mojo/public/cpp/bindings/unique_receiver_set.h" namespace media { // A class that can be deferred destroyed by its owner. For example, when used // in DeferredDestroyUniqueReceiverSet. template <typename Interface> class DeferredDestroy : public Interface { … }; // Similar to mojo::UniqueReceiverSet, but provide a way to defer the // destruction of the interface implementation: // - When disconnection happened on a receiver, the receiver is immediately // destroyed and removed from the set. The interface implementation will be // destroyed when the DestroyCallback is called. // - When the DeferredDestroyUniqueReceiverSet is destructed, all outstanding // receivers and interface implementations in the set are destroyed immediately // without any deferral. template <typename Interface> class DeferredDestroyUniqueReceiverSet { … }; } // namespace media #endif // MEDIA_MOJO_SERVICES_DEFERRED_DESTROY_UNIQUE_RECEIVER_SET_H_