OLD | NEW |
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 #include "content/common/gpu/client/gpu_channel_host.h" | 5 #include "content/common/gpu/client/gpu_channel_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 10 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 } | 86 } |
87 | 87 |
88 listeners_.clear(); | 88 listeners_.clear(); |
89 | 89 |
90 MessageLoop* main_loop = parent_->factory_->GetMainLoop(); | 90 MessageLoop* main_loop = parent_->factory_->GetMainLoop(); |
91 main_loop->PostTask(FROM_HERE, | 91 main_loop->PostTask(FROM_HERE, |
92 base::Bind(&GpuChannelHost::OnChannelError, parent_)); | 92 base::Bind(&GpuChannelHost::OnChannelError, parent_)); |
93 } | 93 } |
94 | 94 |
95 GpuChannelHost::GpuChannelHost( | 95 GpuChannelHost::GpuChannelHost( |
96 GpuChannelHostFactory* factory, int gpu_host_id, int client_id) | 96 GpuChannelHostFactory* factory, int gpu_process_id, int client_id) |
97 : factory_(factory), | 97 : factory_(factory), |
| 98 gpu_process_id_(gpu_process_id), |
98 client_id_(client_id), | 99 client_id_(client_id), |
99 gpu_host_id_(gpu_host_id), | |
100 state_(kUnconnected) { | 100 state_(kUnconnected) { |
101 } | 101 } |
102 | 102 |
103 GpuChannelHost::~GpuChannelHost() { | 103 GpuChannelHost::~GpuChannelHost() { |
104 } | 104 } |
105 | 105 |
106 void GpuChannelHost::Connect( | 106 void GpuChannelHost::Connect( |
107 const IPC::ChannelHandle& channel_handle) { | 107 const IPC::ChannelHandle& channel_handle, |
| 108 base::ProcessHandle client_process_for_gpu) { |
108 DCHECK(factory_->IsMainThread()); | 109 DCHECK(factory_->IsMainThread()); |
109 // Open a channel to the GPU process. We pass NULL as the main listener here | 110 // Open a channel to the GPU process. We pass NULL as the main listener here |
110 // since we need to filter everything to route it to the right thread. | 111 // since we need to filter everything to route it to the right thread. |
111 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); | 112 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); |
112 channel_.reset(new IPC::SyncChannel( | 113 channel_.reset(new IPC::SyncChannel( |
113 channel_handle, IPC::Channel::MODE_CLIENT, NULL, | 114 channel_handle, IPC::Channel::MODE_CLIENT, NULL, |
114 io_loop, true, | 115 io_loop, true, |
115 factory_->GetShutDownEvent())); | 116 factory_->GetShutDownEvent())); |
116 | 117 |
117 sync_filter_ = new IPC::SyncMessageFilter( | 118 sync_filter_ = new IPC::SyncMessageFilter( |
118 factory_->GetShutDownEvent()); | 119 factory_->GetShutDownEvent()); |
119 | 120 |
120 channel_->AddFilter(sync_filter_.get()); | 121 channel_->AddFilter(sync_filter_.get()); |
121 | 122 |
122 channel_filter_ = new MessageFilter(this); | 123 channel_filter_ = new MessageFilter(this); |
123 | 124 |
124 // Install the filter last, because we intercept all leftover | 125 // Install the filter last, because we intercept all leftover |
125 // messages. | 126 // messages. |
126 channel_->AddFilter(channel_filter_.get()); | 127 channel_->AddFilter(channel_filter_.get()); |
127 | 128 |
128 // It is safe to send IPC messages before the channel completes the connection | 129 // It is safe to send IPC messages before the channel completes the connection |
129 // and receives the hello message from the GPU process. The messages get | 130 // and receives the hello message from the GPU process. The messages get |
130 // cached. | 131 // cached. |
131 state_ = kConnected; | 132 state_ = kConnected; |
| 133 |
| 134 // Notify the GPU process of our process handle. This gives it the ability |
| 135 // to map client handles into the GPU process. |
| 136 Send(new GpuChannelMsg_Initialize(client_process_for_gpu)); |
132 } | 137 } |
133 | 138 |
134 void GpuChannelHost::set_gpu_info(const content::GPUInfo& gpu_info) { | 139 void GpuChannelHost::set_gpu_info(const content::GPUInfo& gpu_info) { |
135 gpu_info_ = gpu_info; | 140 gpu_info_ = gpu_info; |
136 } | 141 } |
137 | 142 |
138 const content::GPUInfo& GpuChannelHost::gpu_info() const { | 143 const content::GPUInfo& GpuChannelHost::gpu_info() const { |
139 return gpu_info_; | 144 return gpu_info_; |
140 } | 145 } |
141 | 146 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 &result))) { | 307 &result))) { |
303 return false; | 308 return false; |
304 } | 309 } |
305 return result; | 310 return result; |
306 } | 311 } |
307 | 312 |
308 void GpuChannelHost::ForciblyCloseChannel() { | 313 void GpuChannelHost::ForciblyCloseChannel() { |
309 Send(new GpuChannelMsg_CloseChannel()); | 314 Send(new GpuChannelMsg_CloseChannel()); |
310 SetStateLost(); | 315 SetStateLost(); |
311 } | 316 } |
OLD | NEW |