Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Unified Diff: services/util/cpp/factory_service_base.h

Issue 2007593004: Motown: Factor FactoryServiceBase out of MediaFactoryService (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/util/cpp/BUILD.gn ('k') | services/util/cpp/factory_service_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « services/util/cpp/BUILD.gn ('k') | services/util/cpp/factory_service_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698