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

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

Issue 9559013: Refactor GpuProcessHost::GetForClient to GpuProcessHost::Get, which takes a GPU process kind rather… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/gpu/gpu_data_manager_impl.cc ('k') | content/browser/gpu/gpu_process_host.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 (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_GPU_PROCESS_HOST_H_ 5 #ifndef CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_
6 #define CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ 6 #define CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <queue> 10 #include <queue>
(...skipping 14 matching lines...) Expand all
25 struct GPUCreateCommandBufferConfig; 25 struct GPUCreateCommandBufferConfig;
26 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; 26 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params;
27 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; 27 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params;
28 28
29 class BrowserChildProcessHostImpl; 29 class BrowserChildProcessHostImpl;
30 30
31 class GpuProcessHost : public content::BrowserChildProcessHostDelegate, 31 class GpuProcessHost : public content::BrowserChildProcessHostDelegate,
32 public IPC::Message::Sender, 32 public IPC::Message::Sender,
33 public base::NonThreadSafe { 33 public base::NonThreadSafe {
34 public: 34 public:
35 enum GpuProcessKind {
36 GPU_PROCESS_KIND_UNSANDBOXED,
37 GPU_PROCESS_KIND_SANDBOXED
38 };
39
35 typedef base::Callback<void(const IPC::ChannelHandle&, 40 typedef base::Callback<void(const IPC::ChannelHandle&,
36 base::ProcessHandle, 41 base::ProcessHandle,
37 const content::GPUInfo&)> 42 const content::GPUInfo&)>
38 EstablishChannelCallback; 43 EstablishChannelCallback;
39 44
40 typedef base::Callback<void(int32)> CreateCommandBufferCallback; 45 typedef base::Callback<void(int32)> CreateCommandBufferCallback;
41 46
42 static bool gpu_enabled() { return gpu_enabled_; } 47 static bool gpu_enabled() { return gpu_enabled_; }
43 48
44 // Creates a new GpuProcessHost or gets one for a particular client, resulting 49 // Creates a new GpuProcessHost or gets an existing one, resulting in the
45 // in the launching of a GPU process if required. Returns null on failure. It 50 // launching of a GPU process if required. Returns null on failure. It
46 // is not safe to store the pointer once control has returned to the message 51 // is not safe to store the pointer once control has returned to the message
47 // loop as it can be destroyed. Instead store the associated GPU host ID. 52 // loop as it can be destroyed. Instead store the associated GPU host ID.
48 // This could return NULL if GPU access is not allowed (blacklisted). 53 // This could return NULL if GPU access is not allowed (blacklisted).
49 static GpuProcessHost* GetForClient(int client_id, 54 static GpuProcessHost* Get(GpuProcessKind kind,
50 content::CauseForGpuLaunch cause); 55 content::CauseForGpuLaunch cause);
51 56
52 // Helper function to send the given message to the GPU process on the IO 57 // Helper function to send the given message to the GPU process on the IO
53 // thread. Calls GetForClient and if a host is returned, sends it. 58 // thread. Calls Get and if a host is returned, sends it. Can be called from
54 // Can be called from any thread. 59 // any thread.
55 CONTENT_EXPORT static void SendOnIO(int client_id, 60 CONTENT_EXPORT static void SendOnIO(GpuProcessKind kind,
56 content::CauseForGpuLaunch cause, 61 content::CauseForGpuLaunch cause,
57 IPC::Message* message); 62 IPC::Message* message);
58 63
59 // Get the GPU process host for the GPU process with the given ID. Returns 64 // Get the GPU process host for the GPU process with the given ID. Returns
60 // null if the process no longer exists. 65 // null if the process no longer exists.
61 static GpuProcessHost* FromID(int host_id); 66 static GpuProcessHost* FromID(int host_id);
62 int host_id() const { return host_id_; } 67 int host_id() const { return host_id_; }
63 68
64 // IPC::Message::Sender implementation. 69 // IPC::Message::Sender implementation.
65 virtual bool Send(IPC::Message* msg) OVERRIDE; 70 virtual bool Send(IPC::Message* msg) OVERRIDE;
(...skipping 10 matching lines...) Expand all
76 void CreateViewCommandBuffer( 81 void CreateViewCommandBuffer(
77 const gfx::GLSurfaceHandle& compositing_surface, 82 const gfx::GLSurfaceHandle& compositing_surface,
78 int surface_id, 83 int surface_id,
79 int client_id, 84 int client_id,
80 const GPUCreateCommandBufferConfig& init_params, 85 const GPUCreateCommandBufferConfig& init_params,
81 const CreateCommandBufferCallback& callback); 86 const CreateCommandBufferCallback& callback);
82 87
83 // Whether this GPU process is set up to use software rendering. 88 // Whether this GPU process is set up to use software rendering.
84 bool software_rendering(); 89 bool software_rendering();
85 90
86 // Whether this GPU process is sandboxed. 91 // What kind of GPU process, e.g. sandboxed or unsandboxed.
87 bool sandboxed(); 92 GpuProcessKind kind();
88 93
89 void ForceShutdown(); 94 void ForceShutdown();
90 95
91 private: 96 private:
92 static bool HostIsValid(GpuProcessHost* host); 97 static bool HostIsValid(GpuProcessHost* host);
93 98
94 GpuProcessHost(int host_id, bool sandboxed); 99 GpuProcessHost(int host_id, GpuProcessKind kind);
95 virtual ~GpuProcessHost(); 100 virtual ~GpuProcessHost();
96 101
97 bool Init(); 102 bool Init();
98 103
99 // Post an IPC message to the UI shim's message handler on the UI thread. 104 // Post an IPC message to the UI shim's message handler on the UI thread.
100 void RouteOnUIThread(const IPC::Message& message); 105 void RouteOnUIThread(const IPC::Message& message);
101 106
102 // BrowserChildProcessHostDelegate implementation. 107 // BrowserChildProcessHostDelegate implementation.
103 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 108 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
104 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 109 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 std::queue<IPC::Message*> queued_messages_; 161 std::queue<IPC::Message*> queued_messages_;
157 162
158 // The handle for the GPU process or null if it is not known to be launched. 163 // The handle for the GPU process or null if it is not known to be launched.
159 base::ProcessHandle gpu_process_; 164 base::ProcessHandle gpu_process_;
160 165
161 // Whether we are running a GPU thread inside the browser process instead 166 // Whether we are running a GPU thread inside the browser process instead
162 // of a separate GPU process. 167 // of a separate GPU process.
163 bool in_process_; 168 bool in_process_;
164 169
165 bool software_rendering_; 170 bool software_rendering_;
166 bool sandboxed_; 171 GpuProcessKind kind_;
167 172
168 scoped_ptr<GpuMainThread> in_process_gpu_thread_; 173 scoped_ptr<GpuMainThread> in_process_gpu_thread_;
169 174
170 // Whether we actually launched a GPU process. 175 // Whether we actually launched a GPU process.
171 bool process_launched_; 176 bool process_launched_;
172 177
173 // Master switch for enabling/disabling GPU acceleration for the current 178 // Master switch for enabling/disabling GPU acceleration for the current
174 // browser session. It does not change the acceleration settings for 179 // browser session. It does not change the acceleration settings for
175 // existing tabs, just the future ones. 180 // existing tabs, just the future ones.
176 static bool gpu_enabled_; 181 static bool gpu_enabled_;
177 182
178 static bool hardware_gpu_enabled_; 183 static bool hardware_gpu_enabled_;
179 184
180 scoped_ptr<BrowserChildProcessHostImpl> process_; 185 scoped_ptr<BrowserChildProcessHostImpl> process_;
181 186
182 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); 187 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost);
183 }; 188 };
184 189
185 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ 190 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_data_manager_impl.cc ('k') | content/browser/gpu/gpu_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698