Make USB permissions work in the new permission message system
[chromium-blink-merge.git] / content / browser / gpu / browser_gpu_channel_host_factory.h
blob42e46a61bae3f0f386b87f895f51884aff86e032
1 // Copyright (c) 2012 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 CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_
6 #define CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_
8 #include <map>
9 #include <vector>
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "content/common/gpu/client/gpu_channel_host.h"
14 #include "ipc/message_filter.h"
16 namespace content {
17 class BrowserGpuMemoryBufferManager;
19 class CONTENT_EXPORT BrowserGpuChannelHostFactory
20 : public GpuChannelHostFactory {
21 public:
22 static void Initialize(bool establish_gpu_channel);
23 static void Terminate();
24 static BrowserGpuChannelHostFactory* instance() { return instance_; }
26 // Overridden from GpuChannelHostFactory:
27 bool IsMainThread() override;
28 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override;
29 scoped_ptr<base::SharedMemory> AllocateSharedMemory(size_t size) override;
30 CreateCommandBufferResult CreateViewCommandBuffer(
31 int32 surface_id,
32 const GPUCreateCommandBufferConfig& init_params,
33 int32 route_id) override;
34 IPC::AttachmentBroker* GetAttachmentBroker() override;
36 int GpuProcessHostId() { return gpu_host_id_; }
37 #if !defined(OS_ANDROID)
38 GpuChannelHost* EstablishGpuChannelSync(
39 CauseForGpuLaunch cause_for_gpu_launch);
40 #endif
41 void EstablishGpuChannel(CauseForGpuLaunch cause_for_gpu_launch,
42 const base::Closure& callback);
43 GpuChannelHost* GetGpuChannel();
44 int GetGpuChannelId() { return gpu_client_id_; }
46 // Used to skip GpuChannelHost tests when there can be no GPU process.
47 static bool CanUseForTesting();
49 private:
50 struct CreateRequest;
51 class EstablishRequest;
53 BrowserGpuChannelHostFactory();
54 ~BrowserGpuChannelHostFactory() override;
56 void GpuChannelEstablished();
57 void CreateViewCommandBufferOnIO(
58 CreateRequest* request,
59 int32 surface_id,
60 const GPUCreateCommandBufferConfig& init_params);
61 static void CommandBufferCreatedOnIO(CreateRequest* request,
62 CreateCommandBufferResult result);
63 static void AddFilterOnIO(int gpu_host_id,
64 scoped_refptr<IPC::MessageFilter> filter);
66 const int gpu_client_id_;
67 const uint64_t gpu_client_tracing_id_;
68 scoped_ptr<base::WaitableEvent> shutdown_event_;
69 scoped_refptr<GpuChannelHost> gpu_channel_;
70 scoped_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_;
71 int gpu_host_id_;
72 scoped_refptr<EstablishRequest> pending_request_;
73 std::vector<base::Closure> established_callbacks_;
75 static BrowserGpuChannelHostFactory* instance_;
77 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory);
80 } // namespace content
82 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_