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

Side by Side Diff: content/browser/gpu/browser_gpu_channel_host_factory.h

Issue 2197613003: gpu: Introduce GpuChannelEstablishFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot merge Created 4 years, 4 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ 5 #ifndef CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_
6 #define CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ 6 #define CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
19 #include "gpu/ipc/client/gpu_channel_host.h" 19 #include "gpu/ipc/client/gpu_channel_host.h"
20 #include "ipc/message_filter.h" 20 #include "ipc/message_filter.h"
21 21
22 namespace content { 22 namespace content {
23 class BrowserGpuMemoryBufferManager; 23 class BrowserGpuMemoryBufferManager;
24 24
25 class CONTENT_EXPORT BrowserGpuChannelHostFactory 25 class CONTENT_EXPORT BrowserGpuChannelHostFactory
26 : public gpu::GpuChannelHostFactory { 26 : public gpu::GpuChannelHostFactory,
27 public gpu::GpuChannelEstablishFactory {
27 public: 28 public:
28 static void Initialize(bool establish_gpu_channel); 29 static void Initialize(bool establish_gpu_channel);
29 static void Terminate(); 30 static void Terminate();
30 static BrowserGpuChannelHostFactory* instance() { return instance_; } 31 static BrowserGpuChannelHostFactory* instance() { return instance_; }
31 32
32 // Overridden from gpu::GpuChannelHostFactory: 33 // Overridden from gpu::GpuChannelHostFactory:
33 bool IsMainThread() override; 34 bool IsMainThread() override;
34 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; 35 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override;
35 std::unique_ptr<base::SharedMemory> AllocateSharedMemory( 36 std::unique_ptr<base::SharedMemory> AllocateSharedMemory(
36 size_t size) override; 37 size_t size) override;
37 38
38 int GpuProcessHostId() { return gpu_host_id_; } 39 int GpuProcessHostId() { return gpu_host_id_; }
39 #if !defined(OS_ANDROID)
40 scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync();
41 #endif
42 void EstablishGpuChannel(const base::Closure& callback);
43 gpu::GpuChannelHost* GetGpuChannel(); 40 gpu::GpuChannelHost* GetGpuChannel();
44 int GetGpuChannelId() { return gpu_client_id_; } 41 int GetGpuChannelId() { return gpu_client_id_; }
45 42
46 // Used to skip GpuChannelHost tests when there can be no GPU process. 43 // Used to skip GpuChannelHost tests when there can be no GPU process.
47 static bool CanUseForTesting(); 44 static bool CanUseForTesting();
48 45
46 // Overridden from gpu::GpuChannelEstablishFactory:
47 void EstablishGpuChannel(
48 const gpu::GpuChannelEstablishedCallback& callback) override;
49 scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync() override;
50
49 private: 51 private:
50 struct CreateRequest; 52 struct CreateRequest;
51 class EstablishRequest; 53 class EstablishRequest;
52 54
53 BrowserGpuChannelHostFactory(); 55 BrowserGpuChannelHostFactory();
54 ~BrowserGpuChannelHostFactory() override; 56 ~BrowserGpuChannelHostFactory() override;
55 57
56 void GpuChannelEstablished(); 58 void GpuChannelEstablished();
57 59
58 static void AddFilterOnIO(int gpu_host_id, 60 static void AddFilterOnIO(int gpu_host_id,
59 scoped_refptr<IPC::MessageFilter> filter); 61 scoped_refptr<IPC::MessageFilter> filter);
60 static void InitializeShaderDiskCacheOnIO(int gpu_client_id, 62 static void InitializeShaderDiskCacheOnIO(int gpu_client_id,
61 const base::FilePath& cache_dir); 63 const base::FilePath& cache_dir);
62 64
63 const int gpu_client_id_; 65 const int gpu_client_id_;
64 const uint64_t gpu_client_tracing_id_; 66 const uint64_t gpu_client_tracing_id_;
65 std::unique_ptr<base::WaitableEvent> shutdown_event_; 67 std::unique_ptr<base::WaitableEvent> shutdown_event_;
66 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; 68 scoped_refptr<gpu::GpuChannelHost> gpu_channel_;
67 std::unique_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_; 69 std::unique_ptr<BrowserGpuMemoryBufferManager> gpu_memory_buffer_manager_;
68 int gpu_host_id_; 70 int gpu_host_id_;
69 scoped_refptr<EstablishRequest> pending_request_; 71 scoped_refptr<EstablishRequest> pending_request_;
70 std::vector<base::Closure> established_callbacks_; 72 std::vector<gpu::GpuChannelEstablishedCallback> established_callbacks_;
71 73
72 static BrowserGpuChannelHostFactory* instance_; 74 static BrowserGpuChannelHostFactory* instance_;
73 75
74 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory); 76 DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory);
75 }; 77 };
76 78
77 } // namespace content 79 } // namespace content
78 80
79 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_ 81 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_CHANNEL_HOST_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698