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