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_process_id, int client_id) | 96 GpuChannelHostFactory* factory, int gpu_host_id, int client_id) |
97 : factory_(factory), | 97 : factory_(factory), |
98 gpu_process_id_(gpu_process_id), | |
99 client_id_(client_id), | 98 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) { | |
109 DCHECK(factory_->IsMainThread()); | 108 DCHECK(factory_->IsMainThread()); |
110 // Open a channel to the GPU process. We pass NULL as the main listener here | 109 // Open a channel to the GPU process. We pass NULL as the main listener here |
111 // since we need to filter everything to route it to the right thread. | 110 // since we need to filter everything to route it to the right thread. |
112 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); | 111 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); |
113 channel_.reset(new IPC::SyncChannel( | 112 channel_.reset(new IPC::SyncChannel( |
114 channel_handle, IPC::Channel::MODE_CLIENT, NULL, | 113 channel_handle, IPC::Channel::MODE_CLIENT, NULL, |
115 io_loop, true, | 114 io_loop, true, |
116 factory_->GetShutDownEvent())); | 115 factory_->GetShutDownEvent())); |
117 | 116 |
118 sync_filter_ = new IPC::SyncMessageFilter( | 117 sync_filter_ = new IPC::SyncMessageFilter( |
119 factory_->GetShutDownEvent()); | 118 factory_->GetShutDownEvent()); |
120 | 119 |
121 channel_->AddFilter(sync_filter_.get()); | 120 channel_->AddFilter(sync_filter_.get()); |
122 | 121 |
123 channel_filter_ = new MessageFilter(this); | 122 channel_filter_ = new MessageFilter(this); |
124 | 123 |
125 // Install the filter last, because we intercept all leftover | 124 // Install the filter last, because we intercept all leftover |
126 // messages. | 125 // messages. |
127 channel_->AddFilter(channel_filter_.get()); | 126 channel_->AddFilter(channel_filter_.get()); |
128 | 127 |
129 // It is safe to send IPC messages before the channel completes the connection | 128 // It is safe to send IPC messages before the channel completes the connection |
130 // and receives the hello message from the GPU process. The messages get | 129 // and receives the hello message from the GPU process. The messages get |
131 // cached. | 130 // cached. |
132 state_ = kConnected; | 131 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)); | |
137 } | 132 } |
138 | 133 |
139 void GpuChannelHost::set_gpu_info(const content::GPUInfo& gpu_info) { | 134 void GpuChannelHost::set_gpu_info(const content::GPUInfo& gpu_info) { |
140 gpu_info_ = gpu_info; | 135 gpu_info_ = gpu_info; |
141 } | 136 } |
142 | 137 |
143 const content::GPUInfo& GpuChannelHost::gpu_info() const { | 138 const content::GPUInfo& GpuChannelHost::gpu_info() const { |
144 return gpu_info_; | 139 return gpu_info_; |
145 } | 140 } |
146 | 141 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 &result))) { | 302 &result))) { |
308 return false; | 303 return false; |
309 } | 304 } |
310 return result; | 305 return result; |
311 } | 306 } |
312 | 307 |
313 void GpuChannelHost::ForciblyCloseChannel() { | 308 void GpuChannelHost::ForciblyCloseChannel() { |
314 Send(new GpuChannelMsg_CloseChannel()); | 309 Send(new GpuChannelMsg_CloseChannel()); |
315 SetStateLost(); | 310 SetStateLost(); |
316 } | 311 } |
OLD | NEW |