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

Side by Side Diff: services/ui/public/cpp/gpu_service.h

Issue 2249413004: services/ui: Allow injecting the IO thread task runner for gpu channel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « content/renderer/render_thread_impl.cc ('k') | services/ui/public/cpp/gpu_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 SERVICES_UI_PUBLIC_CPP_GPU_SERVICE_H_ 5 #ifndef SERVICES_UI_PUBLIC_CPP_GPU_SERVICE_H_
6 #define SERVICES_UI_PUBLIC_CPP_GPU_SERVICE_H_ 6 #define SERVICES_UI_PUBLIC_CPP_GPU_SERVICE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 17 matching lines...) Expand all
28 class GpuService : public gpu::GpuChannelHostFactory, 28 class GpuService : public gpu::GpuChannelHostFactory,
29 public gpu::GpuChannelEstablishFactory { 29 public gpu::GpuChannelEstablishFactory {
30 public: 30 public:
31 ~GpuService() override; 31 ~GpuService() override;
32 32
33 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager() const { 33 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager() const {
34 return gpu_memory_buffer_manager_.get(); 34 return gpu_memory_buffer_manager_.get();
35 } 35 }
36 36
37 // The GpuService has to be initialized in the main thread before establishing 37 // The GpuService has to be initialized in the main thread before establishing
38 // the gpu channel. 38 // the gpu channel. The IO thread task-runner needed for the gpu channel can
39 // be set using SetIOTaskRunner(). If no task-runner is set, then a new thread
40 // is created for IO instead.
39 static std::unique_ptr<GpuService> Initialize(shell::Connector* connector); 41 static std::unique_ptr<GpuService> Initialize(shell::Connector* connector);
40 42
43 void SetIOThreadTaskRunner(
44 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
Fady Samuel 2016/08/18 11:00:56 Can this not be passed in Initialize to avoid givi
sadrul 2016/08/18 12:56:53 It's not straight forward, because for the chrome
Fady Samuel 2016/08/18 13:05:39 LGTM but I still feel like this is brittle because
45
41 // gpu::GpuChannelEstablishFactory: 46 // gpu::GpuChannelEstablishFactory:
42 void EstablishGpuChannel( 47 void EstablishGpuChannel(
43 const gpu::GpuChannelEstablishedCallback& callback) override; 48 const gpu::GpuChannelEstablishedCallback& callback) override;
44 scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync() override; 49 scoped_refptr<gpu::GpuChannelHost> EstablishGpuChannelSync() override;
45 gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override; 50 gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override;
46 51
47 private: 52 private:
48 friend struct base::DefaultSingletonTraits<GpuService>; 53 friend struct base::DefaultSingletonTraits<GpuService>;
49 54
50 explicit GpuService(shell::Connector* connector); 55 explicit GpuService(shell::Connector* connector);
51 56
52 scoped_refptr<gpu::GpuChannelHost> GetGpuChannelLocked(); 57 scoped_refptr<gpu::GpuChannelHost> GetGpuChannelLocked();
53 void EstablishGpuChannelOnMainThread(); 58 void EstablishGpuChannelOnMainThread();
54 void EstablishGpuChannelOnMainThreadSyncLocked(); 59 void EstablishGpuChannelOnMainThreadSyncLocked();
55 void EstablishGpuChannelOnMainThreadDone( 60 void EstablishGpuChannelOnMainThreadDone(
56 bool locked, 61 bool locked,
57 int client_id, 62 int client_id,
58 mojom::ChannelHandlePtr channel_handle, 63 mojom::ChannelHandlePtr channel_handle,
59 const gpu::GPUInfo& gpu_info); 64 const gpu::GPUInfo& gpu_info);
60 65
61 // gpu::GpuChannelHostFactory overrides: 66 // gpu::GpuChannelHostFactory overrides:
62 bool IsMainThread() override; 67 bool IsMainThread() override;
63 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; 68 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override;
64 std::unique_ptr<base::SharedMemory> AllocateSharedMemory( 69 std::unique_ptr<base::SharedMemory> AllocateSharedMemory(
65 size_t size) override; 70 size_t size) override;
66 71
67 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 72 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
73 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
68 shell::Connector* connector_; 74 shell::Connector* connector_;
69 base::WaitableEvent shutdown_event_; 75 base::WaitableEvent shutdown_event_;
70 base::Thread io_thread_; 76 std::unique_ptr<base::Thread> io_thread_;
71 std::unique_ptr<MojoGpuMemoryBufferManager> gpu_memory_buffer_manager_; 77 std::unique_ptr<MojoGpuMemoryBufferManager> gpu_memory_buffer_manager_;
72 78
73 // Lock for |gpu_channel_|, |establish_callbacks_| & |is_establishing_|. 79 // Lock for |gpu_channel_|, |establish_callbacks_| & |is_establishing_|.
74 base::Lock lock_; 80 base::Lock lock_;
75 bool is_establishing_; 81 bool is_establishing_;
76 ui::mojom::GpuServicePtr gpu_service_; 82 ui::mojom::GpuServicePtr gpu_service_;
77 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; 83 scoped_refptr<gpu::GpuChannelHost> gpu_channel_;
78 std::vector<gpu::GpuChannelEstablishedCallback> establish_callbacks_; 84 std::vector<gpu::GpuChannelEstablishedCallback> establish_callbacks_;
79 base::ConditionVariable establishing_condition_; 85 base::ConditionVariable establishing_condition_;
80 86
81 DISALLOW_COPY_AND_ASSIGN(GpuService); 87 DISALLOW_COPY_AND_ASSIGN(GpuService);
82 }; 88 };
83 89
84 } // namespace ui 90 } // namespace ui
85 91
86 #endif // SERVICES_UI_PUBLIC_CPP_GPU_SERVICE_H_ 92 #endif // SERVICES_UI_PUBLIC_CPP_GPU_SERVICE_H_
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.cc ('k') | services/ui/public/cpp/gpu_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698