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/browser/gpu/browser_gpu_channel_host_factory.h" | 5 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "content/browser/gpu/gpu_data_manager_impl.h" | 8 #include "content/browser/gpu/gpu_data_manager_impl.h" |
9 #include "content/browser/gpu/gpu_process_host.h" | 9 #include "content/browser/gpu/gpu_process_host.h" |
10 #include "content/browser/gpu/gpu_surface_tracker.h" | 10 #include "content/browser/gpu/gpu_surface_tracker.h" |
11 #include "content/common/gpu/gpu_messages.h" | 11 #include "content/common/gpu/gpu_messages.h" |
12 #include "content/common/child_process_host_impl.h" | 12 #include "content/common/child_process_host_impl.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
| 18 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; |
| 19 |
18 BrowserGpuChannelHostFactory::CreateRequest::CreateRequest() | 20 BrowserGpuChannelHostFactory::CreateRequest::CreateRequest() |
19 : event(false, false), | 21 : event(false, false), |
20 route_id(MSG_ROUTING_NONE) { | 22 route_id(MSG_ROUTING_NONE) { |
21 } | 23 } |
22 | 24 |
23 BrowserGpuChannelHostFactory::CreateRequest::~CreateRequest() { | 25 BrowserGpuChannelHostFactory::CreateRequest::~CreateRequest() { |
24 } | 26 } |
25 | 27 |
26 BrowserGpuChannelHostFactory::EstablishRequest::EstablishRequest() | 28 BrowserGpuChannelHostFactory::EstablishRequest::EstablishRequest() |
27 : event(false, false), | 29 : event(false, false), |
28 gpu_process_handle(base::kNullProcessHandle) { | 30 gpu_process_handle(base::kNullProcessHandle) { |
29 } | 31 } |
30 | 32 |
31 BrowserGpuChannelHostFactory::EstablishRequest::~EstablishRequest() { | 33 BrowserGpuChannelHostFactory::EstablishRequest::~EstablishRequest() { |
32 } | 34 } |
33 | 35 |
34 void BrowserGpuChannelHostFactory::Initialize() { | 36 void BrowserGpuChannelHostFactory::Initialize() { |
35 new BrowserGpuChannelHostFactory(); | 37 instance_ = new BrowserGpuChannelHostFactory(); |
36 } | 38 } |
37 | 39 |
38 void BrowserGpuChannelHostFactory::Terminate() { | 40 void BrowserGpuChannelHostFactory::Terminate() { |
39 delete instance(); | 41 delete instance_; |
40 } | 42 instance_ = NULL; |
41 | |
42 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::Get() { | |
43 return static_cast<BrowserGpuChannelHostFactory*>(instance()); | |
44 } | 43 } |
45 | 44 |
46 BrowserGpuChannelHostFactory::BrowserGpuChannelHostFactory() | 45 BrowserGpuChannelHostFactory::BrowserGpuChannelHostFactory() |
47 : gpu_client_id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), | 46 : gpu_client_id_(ChildProcessHostImpl::GenerateChildProcessUniqueId()), |
48 shutdown_event_(new base::WaitableEvent(true, false)), | 47 shutdown_event_(new base::WaitableEvent(true, false)), |
49 gpu_host_id_(0) { | 48 gpu_host_id_(0) { |
50 set_instance(this); | |
51 } | 49 } |
52 | 50 |
53 BrowserGpuChannelHostFactory::~BrowserGpuChannelHostFactory() { | 51 BrowserGpuChannelHostFactory::~BrowserGpuChannelHostFactory() { |
54 shutdown_event_->Signal(); | 52 shutdown_event_->Signal(); |
55 set_instance(NULL); | |
56 } | 53 } |
57 | 54 |
58 bool BrowserGpuChannelHostFactory::IsMainThread() { | 55 bool BrowserGpuChannelHostFactory::IsMainThread() { |
59 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 56 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
60 } | 57 } |
61 | 58 |
62 bool BrowserGpuChannelHostFactory::IsIOThread() { | 59 bool BrowserGpuChannelHostFactory::IsIOThread() { |
63 return BrowserThread::CurrentlyOn(BrowserThread::IO); | 60 return BrowserThread::CurrentlyOn(BrowserThread::IO); |
64 } | 61 } |
65 | 62 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 gpu_channel_->set_gpu_info(request.gpu_info); | 208 gpu_channel_->set_gpu_info(request.gpu_info); |
212 content::GetContentClient()->SetGpuInfo(request.gpu_info); | 209 content::GetContentClient()->SetGpuInfo(request.gpu_info); |
213 | 210 |
214 // Connect to the GPU process if a channel name was received. | 211 // Connect to the GPU process if a channel name was received. |
215 gpu_channel_->Connect(request.channel_handle, browser_process_for_gpu); | 212 gpu_channel_->Connect(request.channel_handle, browser_process_for_gpu); |
216 | 213 |
217 return gpu_channel_.get(); | 214 return gpu_channel_.get(); |
218 } | 215 } |
219 | 216 |
220 } // namespace content | 217 } // namespace content |
OLD | NEW |