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

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
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 Kind {
36 kSandboxed,
jam 2012/03/01 01:38:31 nit KIND_SANDBOXED per the chromium style guide. t
Ami GONE FROM CHROMIUM 2012/03/01 02:33:04 If you reversed the order then the old "sandboxed"
apatrick_chromium 2012/03/01 02:57:39 Good idea. Done.
37 kUnsandboxed
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(Kind kind, content::CauseForGpuLaunch cause);
50 content::CauseForGpuLaunch cause);
51 55
52 // Helper function to send the given message to the GPU process on the IO 56 // 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. 57 // thread. Calls Get and if a host is returned, sends it. Can be called from
Ami GONE FROM CHROMIUM 2012/03/01 02:33:04 What a strange contract; Get() returning NULL is s
apatrick_chromium 2012/03/01 02:57:39 It handles Get returning NULL by deleting the mess
54 // Can be called from any thread. 58 // any thread.
55 CONTENT_EXPORT static void SendOnIO(int client_id, 59 CONTENT_EXPORT static void SendOnIO(Kind kind,
56 content::CauseForGpuLaunch cause, 60 content::CauseForGpuLaunch cause,
57 IPC::Message* message); 61 IPC::Message* message);
58 62
59 // Get the GPU process host for the GPU process with the given ID. Returns 63 // Get the GPU process host for the GPU process with the given ID. Returns
60 // null if the process no longer exists. 64 // null if the process no longer exists.
61 static GpuProcessHost* FromID(int host_id); 65 static GpuProcessHost* FromID(int host_id);
62 int host_id() const { return host_id_; } 66 int host_id() const { return host_id_; }
63 67
64 // IPC::Message::Sender implementation. 68 // IPC::Message::Sender implementation.
65 virtual bool Send(IPC::Message* msg) OVERRIDE; 69 virtual bool Send(IPC::Message* msg) OVERRIDE;
(...skipping 10 matching lines...) Expand all
76 void CreateViewCommandBuffer( 80 void CreateViewCommandBuffer(
77 const gfx::GLSurfaceHandle& compositing_surface, 81 const gfx::GLSurfaceHandle& compositing_surface,
78 int surface_id, 82 int surface_id,
79 int client_id, 83 int client_id,
80 const GPUCreateCommandBufferConfig& init_params, 84 const GPUCreateCommandBufferConfig& init_params,
81 const CreateCommandBufferCallback& callback); 85 const CreateCommandBufferCallback& callback);
82 86
83 // Whether this GPU process is set up to use software rendering. 87 // Whether this GPU process is set up to use software rendering.
84 bool software_rendering(); 88 bool software_rendering();
85 89
86 // Whether this GPU process is sandboxed. 90 // What kind of GPU process, e.g. sandboxed or unsandboxed.
87 bool sandboxed(); 91 Kind kind();
88 92
89 void ForceShutdown(); 93 void ForceShutdown();
90 94
91 private: 95 private:
92 static bool HostIsValid(GpuProcessHost* host); 96 static bool HostIsValid(GpuProcessHost* host);
93 97
94 GpuProcessHost(int host_id, bool sandboxed); 98 GpuProcessHost(int host_id, Kind kind);
95 virtual ~GpuProcessHost(); 99 virtual ~GpuProcessHost();
96 100
97 bool Init(); 101 bool Init();
98 102
99 // Post an IPC message to the UI shim's message handler on the UI thread. 103 // Post an IPC message to the UI shim's message handler on the UI thread.
100 void RouteOnUIThread(const IPC::Message& message); 104 void RouteOnUIThread(const IPC::Message& message);
101 105
102 // BrowserChildProcessHostDelegate implementation. 106 // BrowserChildProcessHostDelegate implementation.
103 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 107 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
104 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 108 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 std::queue<IPC::Message*> queued_messages_; 159 std::queue<IPC::Message*> queued_messages_;
156 160
157 // The handle for the GPU process or null if it is not known to be launched. 161 // The handle for the GPU process or null if it is not known to be launched.
158 base::ProcessHandle gpu_process_; 162 base::ProcessHandle gpu_process_;
159 163
160 // Whether we are running a GPU thread inside the browser process instead 164 // Whether we are running a GPU thread inside the browser process instead
161 // of a separate GPU process. 165 // of a separate GPU process.
162 bool in_process_; 166 bool in_process_;
163 167
164 bool software_rendering_; 168 bool software_rendering_;
165 bool sandboxed_; 169 Kind kind_;
166 170
167 scoped_ptr<GpuMainThread> in_process_gpu_thread_; 171 scoped_ptr<GpuMainThread> in_process_gpu_thread_;
168 172
169 // Whether we actually launched a GPU process. 173 // Whether we actually launched a GPU process.
170 bool process_launched_; 174 bool process_launched_;
171 175
172 // Master switch for enabling/disabling GPU acceleration for the current 176 // Master switch for enabling/disabling GPU acceleration for the current
173 // browser session. It does not change the acceleration settings for 177 // browser session. It does not change the acceleration settings for
174 // existing tabs, just the future ones. 178 // existing tabs, just the future ones.
175 static bool gpu_enabled_; 179 static bool gpu_enabled_;
176 180
177 static bool hardware_gpu_enabled_; 181 static bool hardware_gpu_enabled_;
178 182
179 scoped_ptr<BrowserChildProcessHostImpl> process_; 183 scoped_ptr<BrowserChildProcessHostImpl> process_;
180 184
181 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); 185 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost);
182 }; 186 };
183 187
184 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ 188 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698