| Index: services/util/cpp/factory_service_base.h
|
| diff --git a/services/media/factory_service/factory_service.h b/services/util/cpp/factory_service_base.h
|
| similarity index 58%
|
| copy from services/media/factory_service/factory_service.h
|
| copy to services/util/cpp/factory_service_base.h
|
| index f2a7fd518c938185b884d1afd6f8906682a65327..9a5ec4a1e3ac02d450e0a96bb106ebabc387fba2 100644
|
| --- a/services/media/factory_service/factory_service.h
|
| +++ b/services/util/cpp/factory_service_base.h
|
| @@ -2,21 +2,20 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef MOJO_SERVICES_MEDIA_FACTORY_FACTORY_SERVICE_H_
|
| -#define MOJO_SERVICES_MEDIA_FACTORY_FACTORY_SERVICE_H_
|
| +#ifndef MOJO_SERVICES_UTIL_CPP_FACTORY_SERVICE_BASE_H_
|
| +#define MOJO_SERVICES_UTIL_CPP_FACTORY_SERVICE_BASE_H_
|
|
|
| +#include <memory>
|
| #include <unordered_set>
|
|
|
| -#include "mojo/common/binding_set.h"
|
| +#include "base/logging.h"
|
| #include "mojo/public/cpp/application/application_delegate.h"
|
| #include "mojo/public/cpp/application/application_impl.h"
|
| -#include "mojo/services/media/control/interfaces/media_factory.mojom.h"
|
|
|
| namespace mojo {
|
| -namespace media {
|
| +namespace util {
|
|
|
| -class MediaFactoryService : public ApplicationDelegate,
|
| - public MediaFactory {
|
| +class FactoryServiceBase : public ApplicationDelegate {
|
| public:
|
| // Provides common behavior for all objects created by the factory service.
|
| class ProductBase : public std::enable_shared_from_this<ProductBase> {
|
| @@ -24,7 +23,7 @@ class MediaFactoryService : public ApplicationDelegate,
|
| virtual ~ProductBase();
|
|
|
| protected:
|
| - ProductBase(MediaFactoryService* owner);
|
| + ProductBase(FactoryServiceBase* owner);
|
|
|
| // Returns the ApplicationImpl.
|
| ApplicationImpl* app() {
|
| @@ -39,7 +38,7 @@ class MediaFactoryService : public ApplicationDelegate,
|
| }
|
|
|
| private:
|
| - MediaFactoryService* owner_;
|
| + FactoryServiceBase* owner_;
|
| };
|
|
|
| template <typename Interface>
|
| @@ -50,7 +49,7 @@ class MediaFactoryService : public ApplicationDelegate,
|
| protected:
|
| Product(Interface* impl,
|
| InterfaceRequest<Interface> request,
|
| - MediaFactoryService* owner)
|
| + FactoryServiceBase* owner)
|
| : ProductBase(owner), binding_(impl, request.Pass()) {
|
| DCHECK(impl);
|
| binding_.set_connection_error_handler([this]() { ReleaseFromOwner(); });
|
| @@ -69,39 +68,20 @@ class MediaFactoryService : public ApplicationDelegate,
|
| Binding<Interface> binding_;
|
| };
|
|
|
| - MediaFactoryService();
|
| + FactoryServiceBase();
|
|
|
| - ~MediaFactoryService() override;
|
| + ~FactoryServiceBase() override;
|
|
|
| // ApplicationDelegate implementation.
|
| void Initialize(ApplicationImpl* app) override;
|
|
|
| - bool ConfigureIncomingConnection(
|
| - ServiceProviderImpl* service_provider_impl) override;
|
| -
|
| - // MediaFactory implementation.
|
| - void CreatePlayer(InterfaceHandle<SeekingReader> reader,
|
| - InterfaceRequest<MediaPlayer> player) override;
|
| -
|
| - void CreateSource(InterfaceHandle<SeekingReader> reader,
|
| - Array<MediaTypeSetPtr> allowed_media_types,
|
| - InterfaceRequest<MediaSource> source) override;
|
| -
|
| - void CreateSink(const String& destination_url,
|
| - MediaTypePtr media_type,
|
| - InterfaceRequest<MediaSink> sink) override;
|
| -
|
| - void CreateDemux(InterfaceHandle<SeekingReader> reader,
|
| - InterfaceRequest<MediaDemux> demux) override;
|
| -
|
| - void CreateDecoder(MediaTypePtr input_media_type,
|
| - InterfaceRequest<MediaTypeConverter> decoder) override;
|
| -
|
| - void CreateNetworkReader(const String& url,
|
| - InterfaceRequest<SeekingReader> reader) override;
|
| + protected:
|
| + template <typename ProductImpl>
|
| + void AddProduct(std::shared_ptr<ProductImpl> product) {
|
| + products_.insert(std::static_pointer_cast<ProductBase>(product));
|
| + }
|
|
|
| private:
|
| - BindingSet<MediaFactory> bindings_;
|
| ApplicationImpl* app_;
|
| std::unordered_set<std::shared_ptr<ProductBase>> products_;
|
| };
|
| @@ -117,7 +97,7 @@ class MediaFactoryService : public ApplicationDelegate,
|
| return; \
|
| }
|
|
|
| -} // namespace media
|
| +} // namespace util
|
| } // namespace mojo
|
|
|
| -#endif // MOJO_SERVICES_MEDIA_FACTORY_FACTORY_SERVICE_H_
|
| +#endif // MOJO_SERVICES_UTIL_CPP_FACTORY_SERVICE_BASE_H_
|
|
|