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

Side by Side Diff: media/base/renderer_factory_selector.h

Issue 2711153006: Add RendererFactorySelector (Closed)
Patch Set: Typo Created 3 years, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_BASE_RENDERER_FACTORY_SELECTOR_H_
6 #define MEDIA_BASE_RENDERER_FACTORY_SELECTOR_H_
7
8 #include "base/containers/flat_map.h"
9 #include "media/base/renderer_factory.h"
10
11 namespace media {
12
13 // RendererFactorySelector owns RendererFactory instances used within WMPI.
14 // Its purpose is to aggregate the signals and centralize the logic behind
15 // choosing which RendererFactory should be used when creating a new Renderer.
16 class MEDIA_EXPORT RendererFactorySelector {
ncarter (slow) 2017/04/24 17:14:33 https://memegen.googleplex.com/9189713
tguilbert 2017/04/24 19:31:16 +1
17 public:
18 enum FactoryType {
19 DEFAULT, // DefaultRendererFactory.
20 MOJO, // MojoRendererFactory.
21 MEDIA_PLAYER, // MediaPlayerRendererClientFactory.
22 ADAPTIVE, // AdaptiveRendererFactory.
23 UNKNOWN,
whywhat 2017/04/22 15:52:50 nit: you could make base_factory_type_ a base::Opt
tguilbert 2017/04/24 19:31:16 Good idea, thanks!
24 };
25
26 RendererFactorySelector();
27 ~RendererFactorySelector();
28
29 // NOTE: There should be at most one factory per factory type.
30 void AddFactory(FactoryType type, std::unique_ptr<RendererFactory> factory);
31
32 // Sets the "default" factory to be returned in the absence explicit signals
33 // indicating that another factory type should be selected instead.
34 void SetBaseFactoryType(FactoryType type);
whywhat 2017/04/22 15:52:50 nit: Base/Default to match the comment?
tguilbert 2017/04/24 19:31:16 I wanted to avoid confusion between the "default/b
35
36 // Note: This only returns the base factory type at the moment.
37 RendererFactory* GetCurrentFactory();
38
39 private:
40 FactoryType base_factory_type_ = FactoryType::UNKNOWN;
41 base::flat_map<FactoryType, std::unique_ptr<RendererFactory>> factories_;
whywhat 2017/04/22 15:52:50 nit: as I understand flat_map, it's a sorted vecto
tguilbert 2017/04/24 19:31:16 I went with a flat_map instead of a regular map du
whywhat 2017/04/24 20:35:48 Totally agree that it's not worth a map, just thou
42 DISALLOW_COPY_AND_ASSIGN(RendererFactorySelector);
43 };
44
45 } // namespace media
46
47 #endif // MEDIA_BASE_RENDERER_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698