OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gpu_data_manager.h" | 5 #include "content/browser/gpu/gpu_data_manager.h" |
6 | 6 |
7 #if defined(OS_MACOSX) | 7 #if defined(OS_MACOSX) |
8 #include <CoreGraphics/CGDisplayConfiguration.h> | 8 #include <CoreGraphics/CGDisplayConfiguration.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/sys_info.h" |
| 16 #include "base/values.h" |
| 17 #include "base/version.h" |
15 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
16 #include "content/browser/gpu/gpu_blacklist.h" | 19 #include "content/browser/gpu/gpu_blacklist.h" |
17 #include "content/browser/gpu/gpu_process_host.h" | 20 #include "content/browser/gpu/gpu_process_host.h" |
18 #include "content/common/content_client.h" | 21 #include "content/common/content_client.h" |
19 #include "content/common/content_switches.h" | 22 #include "content/common/content_switches.h" |
20 #include "content/common/gpu/gpu_messages.h" | 23 #include "content/common/gpu/gpu_messages.h" |
21 #include "content/gpu/gpu_info_collector.h" | 24 #include "content/gpu/gpu_info_collector.h" |
22 #include "ui/gfx/gl/gl_implementation.h" | 25 #include "ui/gfx/gl/gl_implementation.h" |
23 #include "ui/gfx/gl/gl_switches.h" | 26 #include "ui/gfx/gl/gl_switches.h" |
24 | 27 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 it != node.children.end(); | 75 it != node.children.end(); |
73 ++it) { | 76 ++it) { |
74 ListValue* sublist = DxDiagNodeToList(it->second); | 77 ListValue* sublist = DxDiagNodeToList(it->second); |
75 list->Append(NewDescriptionValuePair(it->first, sublist)); | 78 list->Append(NewDescriptionValuePair(it->first, sublist)); |
76 } | 79 } |
77 return list; | 80 return list; |
78 } | 81 } |
79 | 82 |
80 #endif // OS_WIN | 83 #endif // OS_WIN |
81 | 84 |
| 85 std::string GetOSString() { |
| 86 std::string rt; |
| 87 #if defined(OS_CHROMEOS) |
| 88 rt = "ChromeOS"; |
| 89 #elif defined(OS_WIN) |
| 90 rt = "Win"; |
| 91 std::string version_str = base::SysInfo::OperatingSystemVersion(); |
| 92 size_t pos = version_str.find_first_not_of("0123456789."); |
| 93 if (pos != std::string::npos) |
| 94 version_str = version_str.substr(0, pos); |
| 95 scoped_ptr<Version> os_version(Version::GetVersionFromString(version_str)); |
| 96 if (os_version.get() && os_version->components().size() >= 2) { |
| 97 const std::vector<uint16>& version_numbers = os_version->components(); |
| 98 if (version_numbers[0] == 5) |
| 99 rt += "XP"; |
| 100 else if (version_numbers[0] == 6 && version_numbers[1] == 0) |
| 101 rt += "Vista"; |
| 102 else if (version_numbers[0] == 6 && version_numbers[1] == 1) |
| 103 rt += "7"; |
| 104 } |
| 105 #elif defined(OS_LINUX) |
| 106 rt = "Linux"; |
| 107 #elif defined(OS_MACOSX) |
| 108 rt = "Mac"; |
| 109 #else |
| 110 rt = "UnknownOS"; |
| 111 #endif |
| 112 return rt; |
| 113 } |
| 114 |
82 } // namespace anonymous | 115 } // namespace anonymous |
83 | 116 |
84 GpuDataManager::GpuDataManager() | 117 GpuDataManager::GpuDataManager() |
85 : complete_gpu_info_already_requested_(false) { | 118 : complete_gpu_info_already_requested_(false) { |
86 // Certain tests doesn't go through the browser startup path that | 119 // Certain tests doesn't go through the browser startup path that |
87 // initializes GpuDataManager on FILE thread; therefore, it is initialized | 120 // initializes GpuDataManager on FILE thread; therefore, it is initialized |
88 // on UI thread later, and we skip the preliminary gpu info collection | 121 // on UI thread later, and we skip the preliminary gpu info collection |
89 // in such situation. | 122 // in such situation. |
90 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) | 123 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) |
91 return; | 124 return; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 gpu_feature_flags_.set_flags(0); | 390 gpu_feature_flags_.set_flags(0); |
358 return; | 391 return; |
359 } | 392 } |
360 | 393 |
361 { | 394 { |
362 base::AutoLock auto_lock(gpu_info_lock_); | 395 base::AutoLock auto_lock(gpu_info_lock_); |
363 gpu_feature_flags_ = gpu_blacklist->DetermineGpuFeatureFlags( | 396 gpu_feature_flags_ = gpu_blacklist->DetermineGpuFeatureFlags( |
364 GpuBlacklist::kOsAny, NULL, gpu_info_); | 397 GpuBlacklist::kOsAny, NULL, gpu_info_); |
365 } | 398 } |
366 | 399 |
367 uint32 max_entry_id = gpu_blacklist->max_entry_id(); | |
368 if (!gpu_feature_flags_.flags()) { | |
369 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", | |
370 0, max_entry_id + 1); | |
371 return; | |
372 } | |
373 | |
374 // Notify clients that GpuInfo state has changed | 400 // Notify clients that GpuInfo state has changed |
375 RunGpuInfoUpdateCallbacks(); | 401 RunGpuInfoUpdateCallbacks(); |
376 | 402 |
377 // TODO(zmo): move histograming to GpuBlacklist::DetermineGpuFeatureFlags. | 403 uint32 flags = gpu_feature_flags_.flags(); |
378 std::vector<uint32> flag_entries; | 404 uint32 max_entry_id = gpu_blacklist->max_entry_id(); |
379 gpu_blacklist->GetGpuFeatureFlagEntries( | 405 if (flags == 0) { |
380 GpuFeatureFlags::kGpuFeatureAll, flag_entries); | |
381 DCHECK_GT(flag_entries.size(), 0u); | |
382 for (size_t i = 0; i < flag_entries.size(); ++i) { | |
383 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", | 406 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", |
384 flag_entries[i], max_entry_id + 1); | 407 0, max_entry_id + 1); |
| 408 } else { |
| 409 std::vector<uint32> flag_entries; |
| 410 gpu_blacklist->GetGpuFeatureFlagEntries( |
| 411 GpuFeatureFlags::kGpuFeatureAll, flag_entries); |
| 412 DCHECK_GT(flag_entries.size(), 0u); |
| 413 for (size_t i = 0; i < flag_entries.size(); ++i) { |
| 414 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResultsPerEntry", |
| 415 flag_entries[i], max_entry_id + 1); |
| 416 } |
| 417 } |
| 418 |
| 419 const GpuFeatureFlags::GpuFeatureType kGpuFeatures[] = { |
| 420 GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas, |
| 421 GpuFeatureFlags::kGpuFeatureAcceleratedCompositing, |
| 422 GpuFeatureFlags::kGpuFeatureWebgl |
| 423 }; |
| 424 const std::string kOSString = GetOSString(); |
| 425 const std::string kGpuBlacklistFeatureHistogramNames[] = { |
| 426 "GPU.BlacklistAccelerated2dCanvasTestResults" + kOSString, |
| 427 "GPU.BlacklistAcceleratedCompositingTestResults" + kOSString, |
| 428 "GPU.BlacklistWebglTestResults" + kOSString |
| 429 }; |
| 430 const size_t kNumFeatures = |
| 431 sizeof(kGpuFeatures) / sizeof(GpuFeatureFlags::GpuFeatureType); |
| 432 for (size_t i = 0; i < kNumFeatures; ++i) { |
| 433 // We can't use UMA_HISTOGRAM_ENUMERATION here because the same name is |
| 434 // expected if the macro is used within a loop. |
| 435 base::Histogram* histogram_pointer = base::LinearHistogram::FactoryGet( |
| 436 kGpuBlacklistFeatureHistogramNames[i], 1, 2, 3, |
| 437 base::Histogram::kUmaTargetedHistogramFlag); |
| 438 histogram_pointer->Add((flags & kGpuFeatures[i]) ? 1 : 0); |
385 } | 439 } |
386 } | 440 } |
387 | 441 |
388 GpuBlacklist* GpuDataManager::GetGpuBlacklist() { | 442 GpuBlacklist* GpuDataManager::GetGpuBlacklist() { |
389 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 443 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
390 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 444 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
391 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || | 445 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || |
392 browser_command_line.GetSwitchValueASCII( | 446 browser_command_line.GetSwitchValueASCII( |
393 switches::kUseGL) == gfx::kGLImplementationOSMesaName) | 447 switches::kUseGL) == gfx::kGLImplementationOSMesaName) |
394 return NULL; | 448 return NULL; |
395 // No need to return an empty blacklist. | 449 // No need to return an empty blacklist. |
396 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) | 450 if (gpu_blacklist_.get() != NULL && gpu_blacklist_->max_entry_id() == 0) |
397 return NULL; | 451 return NULL; |
398 return gpu_blacklist_.get(); | 452 return gpu_blacklist_.get(); |
399 } | 453 } |
OLD | NEW |