OLD | NEW |
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 #include "chrome/browser/gpu_process_host.h" | 5 #include "chrome/browser/gpu_process_host.h" |
6 | 6 |
7 #include "app/app_switches.h" | 7 #include "app/app_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/common/render_messages.h" | 21 #include "chrome/common/render_messages.h" |
22 #include "chrome/gpu/gpu_thread.h" | 22 #include "chrome/gpu/gpu_thread.h" |
23 #include "grit/browser_resources.h" | 23 #include "grit/browser_resources.h" |
24 #include "ipc/ipc_channel_handle.h" | 24 #include "ipc/ipc_channel_handle.h" |
25 #include "ipc/ipc_switches.h" | 25 #include "ipc/ipc_switches.h" |
26 #include "media/base/media_switches.h" | 26 #include "media/base/media_switches.h" |
27 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 enum GPUBlacklistTestResult { | |
32 BLOCKED, | |
33 ALLOWED, | |
34 BLACKLIST_TEST_RESULT_MAX | |
35 }; | |
36 | |
37 enum GPUProcessLifetimeEvent { | 31 enum GPUProcessLifetimeEvent { |
38 LAUNCED, | 32 LAUNCED, |
39 CRASHED, | 33 CRASHED, |
40 GPU_PROCESS_LIFETIME_EVENT_MAX | 34 GPU_PROCESS_LIFETIME_EVENT_MAX |
41 }; | 35 }; |
42 | 36 |
43 // Tasks used by this file | 37 // Tasks used by this file |
44 class RouteOnUIThreadTask : public Task { | 38 class RouteOnUIThreadTask : public Task { |
45 public: | 39 public: |
46 explicit RouteOnUIThreadTask(const IPC::Message& msg) : msg_(msg) { | 40 explicit RouteOnUIThreadTask(const IPC::Message& msg) : msg_(msg) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 private: | 93 private: |
100 scoped_ptr<GpuThread> gpu_thread_; | 94 scoped_ptr<GpuThread> gpu_thread_; |
101 std::string channel_id_; | 95 std::string channel_id_; |
102 DISALLOW_COPY_AND_ASSIGN(GpuMainThread); | 96 DISALLOW_COPY_AND_ASSIGN(GpuMainThread); |
103 }; | 97 }; |
104 | 98 |
105 GpuProcessHost::GpuProcessHost() | 99 GpuProcessHost::GpuProcessHost() |
106 : BrowserChildProcessHost(GPU_PROCESS, NULL), | 100 : BrowserChildProcessHost(GPU_PROCESS, NULL), |
107 initialized_(false), | 101 initialized_(false), |
108 initialized_successfully_(false), | 102 initialized_successfully_(false), |
109 blacklist_result_recorded_(false) { | 103 gpu_feature_flags_set_(false) { |
110 DCHECK_EQ(sole_instance_, static_cast<GpuProcessHost*>(NULL)); | 104 DCHECK_EQ(sole_instance_, static_cast<GpuProcessHost*>(NULL)); |
111 } | 105 } |
112 | 106 |
113 GpuProcessHost::~GpuProcessHost() { | 107 GpuProcessHost::~GpuProcessHost() { |
114 while (!queued_synchronization_replies_.empty()) { | 108 while (!queued_synchronization_replies_.empty()) { |
115 delete queued_synchronization_replies_.front().reply; | 109 delete queued_synchronization_replies_.front().reply; |
116 queued_synchronization_replies_.pop(); | 110 queued_synchronization_replies_.pop(); |
117 } | 111 } |
118 DCHECK_EQ(sole_instance_, this); | 112 DCHECK_EQ(sole_instance_, this); |
119 sole_instance_ = NULL; | 113 sole_instance_ = NULL; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // handle it. | 213 // handle it. |
220 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) | 214 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) |
221 IPC_END_MESSAGE_MAP() | 215 IPC_END_MESSAGE_MAP() |
222 | 216 |
223 return true; | 217 return true; |
224 } | 218 } |
225 | 219 |
226 void GpuProcessHost::OnChannelEstablished( | 220 void GpuProcessHost::OnChannelEstablished( |
227 const IPC::ChannelHandle& channel_handle, | 221 const IPC::ChannelHandle& channel_handle, |
228 const GPUInfo& gpu_info) { | 222 const GPUInfo& gpu_info) { |
229 GpuFeatureFlags gpu_feature_flags; | 223 if (channel_handle.name.size() != 0 && !gpu_feature_flags_set_) { |
230 if (channel_handle.name.size() != 0) { | 224 gpu_feature_flags_ = gpu_blacklist_->DetermineGpuFeatureFlags( |
231 gpu_feature_flags = gpu_blacklist_->DetermineGpuFeatureFlags( | |
232 GpuBlacklist::kOsAny, NULL, gpu_info); | 225 GpuBlacklist::kOsAny, NULL, gpu_info); |
| 226 gpu_feature_flags_set_ = true; |
| 227 uint32 max_entry_id = gpu_blacklist_->max_entry_id(); |
| 228 if (gpu_feature_flags_.flags() != 0) { |
| 229 std::vector<uint32> flag_entries; |
| 230 gpu_blacklist_->GetGpuFeatureFlagEntries(GpuFeatureFlags::kGpuFeatureAll, |
| 231 flag_entries); |
| 232 DCHECK_GT(flag_entries.size(), 0u); |
| 233 for (size_t i = 0; i < flag_entries.size(); ++i) { |
| 234 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", |
| 235 flag_entries[i], max_entry_id + 1); |
| 236 } |
| 237 } else { |
| 238 // id 0 is never used by any entry, so we use it here to indicate that |
| 239 // gpu is allowed. |
| 240 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", |
| 241 0, max_entry_id + 1); |
| 242 } |
233 } | 243 } |
234 const ChannelRequest& request = sent_requests_.front(); | 244 const ChannelRequest& request = sent_requests_.front(); |
235 // Currently if any of the GPU features are blacklised, we don't establish a | 245 // Currently if any of the GPU features are blacklised, we don't establish a |
236 // GPU channel. | 246 // GPU channel. |
237 GPUBlacklistTestResult test_result; | 247 if (gpu_feature_flags_.flags() != 0) { |
238 if (gpu_feature_flags.flags() != 0) { | |
239 Send(new GpuMsg_CloseChannel(channel_handle)); | 248 Send(new GpuMsg_CloseChannel(channel_handle)); |
240 SendEstablishChannelReply(IPC::ChannelHandle(), gpu_info, request.filter); | 249 SendEstablishChannelReply(IPC::ChannelHandle(), gpu_info, request.filter); |
241 test_result = BLOCKED; | |
242 } else { | 250 } else { |
243 SendEstablishChannelReply(channel_handle, gpu_info, request.filter); | 251 SendEstablishChannelReply(channel_handle, gpu_info, request.filter); |
244 test_result = ALLOWED; | |
245 } | |
246 if (!blacklist_result_recorded_) { | |
247 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResults", | |
248 test_result, BLACKLIST_TEST_RESULT_MAX); | |
249 blacklist_result_recorded_ = true; | |
250 } | 252 } |
251 sent_requests_.pop(); | 253 sent_requests_.pop(); |
252 } | 254 } |
253 | 255 |
254 void GpuProcessHost::OnSynchronizeReply() { | 256 void GpuProcessHost::OnSynchronizeReply() { |
255 // Guard against race conditions in abrupt GPU process termination. | 257 // Guard against race conditions in abrupt GPU process termination. |
256 if (queued_synchronization_replies_.size() > 0) { | 258 if (queued_synchronization_replies_.size() > 0) { |
257 const SynchronizationRequest& request = | 259 const SynchronizationRequest& request = |
258 queued_synchronization_replies_.front(); | 260 queued_synchronization_replies_.front(); |
259 SendSynchronizationReply(request.reply, request.filter); | 261 SendSynchronizationReply(request.reply, request.filter); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 402 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
401 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || | 403 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || |
402 blacklist->LoadGpuBlacklist(gpu_blacklist_json.as_string(), true)) { | 404 blacklist->LoadGpuBlacklist(gpu_blacklist_json.as_string(), true)) { |
403 gpu_blacklist_.reset(blacklist); | 405 gpu_blacklist_.reset(blacklist); |
404 return true; | 406 return true; |
405 } | 407 } |
406 delete blacklist; | 408 delete blacklist; |
407 return false; | 409 return false; |
408 } | 410 } |
409 | 411 |
OLD | NEW |