Don't preload rarely seen large images
[chromium-blink-merge.git] / components / html_viewer / media_factory.h
blob75a2e697465860d8f97ccf5dffcd3509ae65d205
1 // Copyright 2014 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.
5 #ifndef COMPONENTS_HTML_VIEWER_MEDIA_FACTORY_H_
6 #define COMPONENTS_HTML_VIEWER_MEDIA_FACTORY_H_
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/threading/thread.h"
12 #include "media/audio/fake_audio_log_factory.h"
13 #include "media/base/audio_hardware_config.h"
14 #include "mojo/application/public/interfaces/service_provider.mojom.h"
16 namespace base {
17 class SingleThreadTaskRunner;
20 namespace blink {
21 class WebContentDecryptionModule;
22 class WebEncryptedMediaClient;
23 class WebMediaPlayer;
24 class WebLocalFrame;
25 class WebURL;
26 class WebMediaPlayerClient;
29 namespace media {
30 class AudioManager;
31 class AudioRendererSink;
32 class CdmFactory;
33 class MediaPermission;
34 class WebEncryptedMediaClientImpl;
37 namespace mojo {
38 class ServiceProvider;
39 class Shell;
42 namespace html_viewer {
44 // Helper class used to create blink::WebMediaPlayer objects.
45 // This class stores the "global state" shared across all WebMediaPlayer
46 // instances.
47 class MediaFactory {
48 public:
49 MediaFactory(
50 const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner,
51 mojo::Shell* shell);
52 ~MediaFactory();
54 blink::WebMediaPlayer* CreateMediaPlayer(
55 blink::WebLocalFrame* frame,
56 const blink::WebURL& url,
57 blink::WebMediaPlayerClient* client,
58 blink::WebContentDecryptionModule* initial_cdm,
59 mojo::Shell* shell);
61 blink::WebEncryptedMediaClient* GetEncryptedMediaClient();
63 private:
64 mojo::ServiceProvider* GetMediaServiceProvider();
65 media::MediaPermission* GetMediaPermission();
66 media::CdmFactory* GetCdmFactory();
68 #if !defined(OS_ANDROID)
69 const media::AudioHardwareConfig& GetAudioHardwareConfig();
70 scoped_refptr<media::AudioRendererSink> CreateAudioRendererSink();
71 scoped_refptr<base::SingleThreadTaskRunner> GetMediaThreadTaskRunner();
73 base::Thread media_thread_;
74 media::FakeAudioLogFactory fake_audio_log_factory_;
75 scoped_ptr<media::AudioManager> audio_manager_;
76 media::AudioHardwareConfig audio_hardware_config_;
77 #endif
79 const bool enable_mojo_media_renderer_;
80 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
81 mojo::Shell* shell_;
83 // Lazily initialized objects.
84 mojo::ServiceProviderPtr media_service_provider_;
85 scoped_ptr<media::WebEncryptedMediaClientImpl> web_encrypted_media_client_;
86 scoped_ptr<media::MediaPermission> media_permission_;
87 scoped_ptr<media::CdmFactory> cdm_factory_;
89 DISALLOW_COPY_AND_ASSIGN(MediaFactory);
92 } // namespace html_viewer
94 #endif // COMPONENTS_HTML_VIEWER_MEDIA_FACTORY_H_