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

Side by Side Diff: content/gpu/gpu_child_thread.h

Issue 1716813002: Use GpuPreferences to avoid directly accessing switches in gpu related code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 4 years, 9 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_GPU_GPU_CHILD_THREAD_H_ 5 #ifndef CONTENT_GPU_GPU_CHILD_THREAD_H_
6 #define CONTENT_GPU_GPU_CHILD_THREAD_H_ 6 #define CONTENT_GPU_GPU_CHILD_THREAD_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <queue> 10 #include <queue>
11 #include <string> 11 #include <string>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "content/child/child_thread_impl.h" 19 #include "content/child/child_thread_impl.h"
20 #include "content/common/gpu/gpu_channel.h" 20 #include "content/common/gpu/gpu_channel.h"
21 #include "content/common/gpu/gpu_channel_manager.h" 21 #include "content/common/gpu/gpu_channel_manager.h"
22 #include "content/common/gpu/gpu_channel_manager_delegate.h" 22 #include "content/common/gpu/gpu_channel_manager_delegate.h"
23 #include "content/common/gpu/gpu_config.h" 23 #include "content/common/gpu/gpu_config.h"
24 #include "content/common/gpu/x_util.h" 24 #include "content/common/gpu/x_util.h"
25 #include "content/common/process_control.mojom.h" 25 #include "content/common/process_control.mojom.h"
26 #include "gpu/command_buffer/service/gpu_preferences.h"
26 #include "gpu/config/gpu_info.h" 27 #include "gpu/config/gpu_info.h"
27 #include "mojo/public/cpp/bindings/binding_set.h" 28 #include "mojo/public/cpp/bindings/binding_set.h"
28 #include "mojo/public/cpp/bindings/interface_request.h" 29 #include "mojo/public/cpp/bindings/interface_request.h"
29 #include "ui/gfx/native_widget_types.h" 30 #include "ui/gfx/native_widget_types.h"
30 31
31 namespace gpu { 32 namespace gpu {
32 class SyncPointManager; 33 class SyncPointManager;
33 } 34 }
34 35
35 namespace sandbox { 36 namespace sandbox {
36 class TargetServices; 37 class TargetServices;
37 } 38 }
38 39
39 namespace content { 40 namespace content {
40 class GpuMemoryBufferFactory; 41 class GpuMemoryBufferFactory;
41 class GpuProcessControlImpl; 42 class GpuProcessControlImpl;
42 class GpuWatchdogThread; 43 class GpuWatchdogThread;
43 44
44 // The main thread of the GPU child process. There will only ever be one of 45 // The main thread of the GPU child process. There will only ever be one of
45 // these per process. It does process initialization and shutdown. It forwards 46 // these per process. It does process initialization and shutdown. It forwards
46 // IPC messages to GpuChannelManager, which is responsible for issuing rendering 47 // IPC messages to GpuChannelManager, which is responsible for issuing rendering
47 // commands to the GPU. 48 // commands to the GPU.
48 class GpuChildThread : public ChildThreadImpl, 49 class GpuChildThread : public ChildThreadImpl,
49 public GpuChannelManagerDelegate { 50 public GpuChannelManagerDelegate {
50 public: 51 public:
51 typedef std::queue<IPC::Message*> DeferredMessages; 52 typedef std::queue<IPC::Message*> DeferredMessages;
52 53
53 GpuChildThread(GpuWatchdogThread* gpu_watchdog_thread, 54 GpuChildThread(const gpu::GpuPreferences* gpu_preferences,
boliu 2016/02/26 22:17:32 these should be const&
Peng 2016/02/29 16:09:22 pointer is necessary, so the caller can use a null
boliu 2016/02/29 16:26:40 Then maybe you want another constructor instead.
Peng 2016/02/29 19:29:50 Do we really need another constructor with duplica
boliu 2016/02/29 19:48:22 Just a general preference to not have parameters t
Peng 2016/02/29 20:30:50 I do agree it is better to avoid using const point
boliu 2016/02/29 20:40:07 content/gpu then? You can just expose that as a st
Peng 2016/02/29 21:18:29 Done.
55 GpuWatchdogThread* gpu_watchdog_thread,
54 bool dead_on_arrival, 56 bool dead_on_arrival,
55 const gpu::GPUInfo& gpu_info, 57 const gpu::GPUInfo& gpu_info,
56 const DeferredMessages& deferred_messages, 58 const DeferredMessages& deferred_messages,
57 GpuMemoryBufferFactory* gpu_memory_buffer_factory, 59 GpuMemoryBufferFactory* gpu_memory_buffer_factory,
58 gpu::SyncPointManager* sync_point_manager); 60 gpu::SyncPointManager* sync_point_manager);
59 61
60 GpuChildThread(const InProcessChildThreadParams& params, 62 GpuChildThread(const gpu::GpuPreferences* gpu_preferences,
63 const InProcessChildThreadParams& params,
61 GpuMemoryBufferFactory* gpu_memory_buffer_factory, 64 GpuMemoryBufferFactory* gpu_memory_buffer_factory,
62 gpu::SyncPointManager* sync_point_manager); 65 gpu::SyncPointManager* sync_point_manager);
63 66
64 ~GpuChildThread() override; 67 ~GpuChildThread() override;
65 68
66 void Shutdown() override; 69 void Shutdown() override;
67 70
68 void Init(const base::Time& process_start_time); 71 void Init(const base::Time& process_start_time);
69 void StopWatchdog(); 72 void StopWatchdog();
70 73
74 private:
71 // ChildThread overrides. 75 // ChildThread overrides.
72 bool Send(IPC::Message* msg) override; 76 bool Send(IPC::Message* msg) override;
73 bool OnControlMessageReceived(const IPC::Message& msg) override; 77 bool OnControlMessageReceived(const IPC::Message& msg) override;
74 bool OnMessageReceived(const IPC::Message& msg) override; 78 bool OnMessageReceived(const IPC::Message& msg) override;
75 79
76 private:
77 // GpuChannelManagerDelegate implementation. 80 // GpuChannelManagerDelegate implementation.
78 void AddSubscription(int32_t client_id, unsigned int target) override; 81 void AddSubscription(int32_t client_id, unsigned int target) override;
79 void ChannelEstablished(const IPC::ChannelHandle& channel_handle) override; 82 void ChannelEstablished(const IPC::ChannelHandle& channel_handle) override;
80 void DidCreateOffscreenContext(const GURL& active_url) override; 83 void DidCreateOffscreenContext(const GURL& active_url) override;
81 void DidDestroyChannel(int client_id) override; 84 void DidDestroyChannel(int client_id) override;
82 void DidDestroyOffscreenContext(const GURL& active_url) override; 85 void DidDestroyOffscreenContext(const GURL& active_url) override;
83 void DidLoseContext(bool offscreen, 86 void DidLoseContext(bool offscreen,
84 gpu::error::ContextLostReason reason, 87 gpu::error::ContextLostReason reason,
85 const GURL& active_url) override; 88 const GURL& active_url) override;
86 void GpuMemoryUmaStats(const GPUMemoryUmaStats& params) override; 89 void GpuMemoryUmaStats(const GPUMemoryUmaStats& params) override;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 unsigned int target, 127 unsigned int target,
125 const gpu::ValueState& state); 128 const gpu::ValueState& state);
126 #if defined(OS_ANDROID) 129 #if defined(OS_ANDROID)
127 void OnWakeUpGpu(); 130 void OnWakeUpGpu();
128 #endif 131 #endif
129 void OnLoseAllContexts(); 132 void OnLoseAllContexts();
130 133
131 void BindProcessControlRequest( 134 void BindProcessControlRequest(
132 mojo::InterfaceRequest<ProcessControl> request); 135 mojo::InterfaceRequest<ProcessControl> request);
133 136
137 gpu::GpuPreferences gpu_preferences_;
138
134 // Set this flag to true if a fatal error occurred before we receive the 139 // Set this flag to true if a fatal error occurred before we receive the
135 // OnInitialize message, in which case we just declare ourselves DOA. 140 // OnInitialize message, in which case we just declare ourselves DOA.
136 bool dead_on_arrival_; 141 bool dead_on_arrival_;
137 base::Time process_start_time_; 142 base::Time process_start_time_;
138 scoped_refptr<GpuWatchdogThread> watchdog_thread_; 143 scoped_refptr<GpuWatchdogThread> watchdog_thread_;
139 144
140 #if defined(OS_WIN) 145 #if defined(OS_WIN)
141 // Windows specific client sandbox interface. 146 // Windows specific client sandbox interface.
142 sandbox::TargetServices* target_services_; 147 sandbox::TargetServices* target_services_;
143 #endif 148 #endif
(...skipping 20 matching lines...) Expand all
164 169
165 // Bindings to the ProcessControl impl. 170 // Bindings to the ProcessControl impl.
166 mojo::BindingSet<ProcessControl> process_control_bindings_; 171 mojo::BindingSet<ProcessControl> process_control_bindings_;
167 172
168 DISALLOW_COPY_AND_ASSIGN(GpuChildThread); 173 DISALLOW_COPY_AND_ASSIGN(GpuChildThread);
169 }; 174 };
170 175
171 } // namespace content 176 } // namespace content
172 177
173 #endif // CONTENT_GPU_GPU_CHILD_THREAD_H_ 178 #endif // CONTENT_GPU_GPU_CHILD_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698