1 // Copyright 2015 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 CONTENT_GPU_GPU_SERVICE_FACTORY_H_ 6 #define CONTENT_GPU_GPU_SERVICE_FACTORY_H_ 7 8 #include "base/macros.h" 9 #include "base/memory/ref_counted.h" 10 #include "base/memory/weak_ptr.h" 11 #include "base/single_thread_task_runner.h" 12 #include "gpu/config/gpu_driver_bug_workarounds.h" 13 #include "gpu/config/gpu_feature_info.h" 14 #include "gpu/config/gpu_preferences.h" 15 #include "media/base/android_overlay_mojo_factory.h" 16 #include "media/mojo/buildflags.h" 17 #include "media/mojo/mojom/media_service.mojom.h" 18 #include "services/service_manager/public/mojom/service.mojom.h" 19 20 namespace gpu { 21 class GpuMemoryBufferFactory; 22 } 23 24 namespace media { 25 class MediaGpuChannelManager; 26 } 27 28 namespace content { 29 30 // Helper for handling incoming RunService requests on GpuChildThread. 31 class GpuServiceFactory { 32 public: 33 GpuServiceFactory( 34 const gpu::GpuPreferences& gpu_preferences, 35 const gpu::GpuDriverBugWorkarounds& gpu_workarounds, 36 const gpu::GpuFeatureInfo& gpu_feature_info, 37 base::WeakPtr<media::MediaGpuChannelManager> media_gpu_channel_manager, 38 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory, 39 media::AndroidOverlayMojoFactoryCB android_overlay_factory_cb); 40 ~GpuServiceFactory(); 41 42 void RunMediaService( 43 mojo::PendingReceiver<media::mojom::MediaService> receiver); 44 45 private: 46 #if BUILDFLAG(ENABLE_MOJO_MEDIA_IN_GPU_PROCESS) 47 // Task runner we were constructed on, and that |media_gpu_channel_manager_| 48 // must be accessed from (the GPU main thread task runner). We expect 49 // RegisterServices() to be called on this task runner as well, but the 50 // implementation doesn't care. 51 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 52 base::WeakPtr<media::MediaGpuChannelManager> media_gpu_channel_manager_; 53 media::AndroidOverlayMojoFactoryCB android_overlay_factory_cb_; 54 // Indirectly owned by GpuChildThread. 55 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory_; 56 gpu::GpuPreferences gpu_preferences_; 57 gpu::GpuDriverBugWorkarounds gpu_workarounds_; 58 gpu::GpuFeatureInfo gpu_feature_info_; 59 #endif 60 61 DISALLOW_COPY_AND_ASSIGN(GpuServiceFactory); 62 }; 63 64 } // namespace content 65 66 #endif // CONTENT_GPU_GPU_SERVICE_FACTORY_H_ 67