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

Side by Side Diff: chrome/browser/gpu_process_host.h

Issue 6343006: Route IPC through browser when creating a viewable command buffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Some final cleanup before review. Created 9 years, 11 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 | « no previous file | chrome/browser/gpu_process_host.cc » ('j') | chrome/browser/gpu_process_host.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 CHROME_BROWSER_GPU_PROCESS_HOST_H_ 5 #ifndef CHROME_BROWSER_GPU_PROCESS_HOST_H_
6 #define CHROME_BROWSER_GPU_PROCESS_HOST_H_ 6 #define CHROME_BROWSER_GPU_PROCESS_HOST_H_
7 #pragma once 7 #pragma once
8 8
9 #include <queue> 9 #include <queue>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
13 #include "base/threading/non_thread_safe.h" 13 #include "base/threading/non_thread_safe.h"
14 #include "chrome/browser/browser_child_process_host.h" 14 #include "chrome/browser/browser_child_process_host.h"
15 #include "gfx/native_widget_types.h" 15 #include "gfx/native_widget_types.h"
16 16
17 class GpuBlacklist; 17 class GpuBlacklist;
18 struct GPUCreateCommandBufferConfig;
18 class GPUInfo; 19 class GPUInfo;
19 class RenderMessageFilter; 20 class RenderMessageFilter;
20 21
21 namespace IPC { 22 namespace IPC {
22 struct ChannelHandle; 23 struct ChannelHandle;
23 class Message; 24 class Message;
24 } 25 }
25 26
26 class GpuProcessHost : public BrowserChildProcessHost, 27 class GpuProcessHost : public BrowserChildProcessHost,
27 public base::NonThreadSafe { 28 public base::NonThreadSafe {
28 public: 29 public:
29 // Getter for the singleton. This will return NULL on failure. 30 // Getter for the singleton. This will return NULL on failure.
30 static GpuProcessHost* Get(); 31 static GpuProcessHost* Get();
31 32
32 virtual bool Send(IPC::Message* msg); 33 virtual bool Send(IPC::Message* msg);
33 34
34 // IPC::Channel::Listener implementation. 35 // IPC::Channel::Listener implementation.
35 virtual bool OnMessageReceived(const IPC::Message& message); 36 virtual bool OnMessageReceived(const IPC::Message& message);
36 37
37 // Tells the GPU process to create a new channel for communication with a 38 // Tells the GPU process to create a new channel for communication with a
38 // renderer. Will asynchronously send message to object with given routing id 39 // renderer. Will asynchronously send message to object with given routing id
39 // on completion. 40 // on completion.
40 void EstablishGpuChannel(int renderer_id, RenderMessageFilter* filter); 41 void EstablishGpuChannel(int renderer_id, RenderMessageFilter* filter);
41 42
42 // Sends a reply message later when the next GpuHostMsg_SynchronizeReply comes 43 // Sends a reply message later when the next GpuHostMsg_SynchronizeReply comes
43 // in. 44 // in.
44 void Synchronize(IPC::Message* reply, RenderMessageFilter* filter); 45 void Synchronize(IPC::Message* reply, RenderMessageFilter* filter);
45 46
47 // Tells the GPU process to create a new command buffer that draws into the
48 // window associated with the given renderer.
49 void CreateViewCommandBuffer(
50 int32 render_view_id,
51 int32 renderer_id,
52 const GPUCreateCommandBufferConfig& init_params,
53 IPC::Message* reply,
54 RenderMessageFilter* filter);
55
56 // We need to hop threads when creating the command buffer.
57 // Let these tasks access our internals.
58 friend class CVCBThreadHopping;
59
46 private: 60 private:
47 // Used to queue pending channel requests. 61 // Used to queue pending channel requests.
48 struct ChannelRequest { 62 struct ChannelRequest {
49 explicit ChannelRequest(RenderMessageFilter* filter); 63 explicit ChannelRequest(RenderMessageFilter* filter);
50 ~ChannelRequest(); 64 ~ChannelRequest();
51 65
52 // Used to send the reply message back to the renderer. 66 // Used to send the reply message back to the renderer.
53 scoped_refptr<RenderMessageFilter> filter; 67 scoped_refptr<RenderMessageFilter> filter;
54 }; 68 };
55 69
56 // Used to queue pending synchronization requests. 70 struct DelayedReply {
57 struct SynchronizationRequest { 71 DelayedReply(IPC::Message* reply, RenderMessageFilter* filter);
58 SynchronizationRequest(IPC::Message* reply, RenderMessageFilter* filter); 72 ~DelayedReply();
59 ~SynchronizationRequest();
60 73
61 // The delayed reply message which needs to be sent to the 74 // The delayed reply message which needs to be sent to the
62 // renderer. 75 // renderer.
63 IPC::Message* reply; 76 IPC::Message* reply;
64 77
65 // Used to send the reply message back to the renderer. 78 // Used to send the reply message back to the renderer.
66 scoped_refptr<RenderMessageFilter> filter; 79 scoped_refptr<RenderMessageFilter> filter;
67 }; 80 };
68 81
69 GpuProcessHost(); 82 GpuProcessHost();
70 virtual ~GpuProcessHost(); 83 virtual ~GpuProcessHost();
71 84
72 bool EnsureInitialized(); 85 bool EnsureInitialized();
73 bool Init(); 86 bool Init();
74 87
75 bool OnControlMessageReceived(const IPC::Message& message); 88 bool OnControlMessageReceived(const IPC::Message& message);
76 89
77 // Message handlers. 90 // Message handlers.
78 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle, 91 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle,
79 const GPUInfo& gpu_info); 92 const GPUInfo& gpu_info);
80 void OnSynchronizeReply(); 93 void OnSynchronizeReply();
94 void OnCommandBufferCreated(const int32 route_id);
81 95
82 // Sends the response for establish channel request to the renderer. 96 // Sends the response for establish channel request to the renderer.
83 void SendEstablishChannelReply(const IPC::ChannelHandle& channel, 97 void SendEstablishChannelReply(const IPC::ChannelHandle& channel,
84 const GPUInfo& gpu_info, 98 const GPUInfo& gpu_info,
85 RenderMessageFilter* filter); 99 RenderMessageFilter* filter);
86 // Sends the response for synchronization request to the renderer.
87 void SendSynchronizationReply(IPC::Message* reply,
88 RenderMessageFilter* filter);
89 100
90 // Sends outstanding replies to renderer processes. This is only called 101 // Sends outstanding replies to renderer processes. This is only called
91 // in error situations like the GPU process crashing -- but is necessary 102 // in error situations like the GPU process crashing -- but is necessary
92 // to prevent the renderer process from hanging. 103 // to prevent the renderer process from hanging.
93 void SendOutstandingReplies(); 104 void SendOutstandingReplies();
94 105
95 virtual bool CanShutdown(); 106 virtual bool CanShutdown();
96 virtual void OnChildDied(); 107 virtual void OnChildDied();
97 virtual void OnProcessCrashed(int exit_code); 108 virtual void OnProcessCrashed(int exit_code);
98 109
99 bool CanLaunchGpuProcess() const; 110 bool CanLaunchGpuProcess() const;
100 bool LaunchGpuProcess(); 111 bool LaunchGpuProcess();
101 112
102 bool LoadGpuBlacklist(); 113 bool LoadGpuBlacklist();
103 114
104 bool initialized_; 115 bool initialized_;
105 bool initialized_successfully_; 116 bool initialized_successfully_;
106 117
107 bool blacklist_result_recorded_; 118 bool blacklist_result_recorded_;
108 119
109 scoped_ptr<GpuBlacklist> gpu_blacklist_; 120 scoped_ptr<GpuBlacklist> gpu_blacklist_;
110 121
111 // These are the channel requests that we have already sent to 122 // These are the channel requests that we have already sent to
112 // the GPU process, but haven't heard back about yet. 123 // the GPU process, but haven't heard back about yet.
113 std::queue<ChannelRequest> sent_requests_; 124 std::queue<ChannelRequest> sent_requests_;
114 125
115 // The pending synchronization requests we need to reply to. 126 // The pending synchronization requests we need to reply to.
116 std::queue<SynchronizationRequest> queued_synchronization_replies_; 127 std::queue<DelayedReply> queued_synchronization_replies_;
128
129 // The pending create command buffer requests we need to reply to.
130 std::queue<DelayedReply> create_command_buffer_replies_;
117 131
118 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); 132 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost);
119 }; 133 };
120 134
135
121 #endif // CHROME_BROWSER_GPU_PROCESS_HOST_H_ 136 #endif // CHROME_BROWSER_GPU_PROCESS_HOST_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/gpu_process_host.cc » ('j') | chrome/browser/gpu_process_host.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698