| 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 "chrome/common/child_process_logging.h" | 5 #include "chrome/common/child_process_logging.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "chrome/common/metrics/variations/variations_util.h" | 16 #include "chrome/common/metrics/variations/variations_util.h" |
| 17 #include "chrome/installer/util/google_update_settings.h" | 17 #include "chrome/installer/util/google_update_settings.h" |
| 18 #include "gpu/config/gpu_info.h" | |
| 19 | 18 |
| 20 namespace child_process_logging { | 19 namespace child_process_logging { |
| 21 | 20 |
| 22 using base::debug::SetCrashKeyValueFuncT; | 21 using base::debug::SetCrashKeyValueFuncT; |
| 23 using base::debug::ClearCrashKeyValueFuncT; | 22 using base::debug::ClearCrashKeyValueFuncT; |
| 24 using base::debug::SetCrashKeyValue; | 23 using base::debug::SetCrashKeyValue; |
| 25 using base::debug::ClearCrashKey; | 24 using base::debug::ClearCrashKey; |
| 26 | 25 |
| 27 const char* kGuidParamName = "guid"; | 26 const char* kGuidParamName = "guid"; |
| 28 const char* kGPUVendorIdParamName = "gpu-venid"; | |
| 29 const char* kGPUDeviceIdParamName = "gpu-devid"; | |
| 30 const char* kGPUDriverVersionParamName = "gpu-driver"; | |
| 31 const char* kGPUPixelShaderVersionParamName = "gpu-psver"; | |
| 32 const char* kGPUVertexShaderVersionParamName = "gpu-vsver"; | |
| 33 const char* kGPUGLVersionParamName = "gpu-glver"; | |
| 34 const char* kNumberOfViews = "num-views"; | 27 const char* kNumberOfViews = "num-views"; |
| 35 const char* kNumExtensionsName = "num-extensions"; | 28 const char* kNumExtensionsName = "num-extensions"; |
| 36 const char* kExtensionNameFormat = "extension-%zu"; | 29 const char* kExtensionNameFormat = "extension-%zu"; |
| 37 const char* kPrinterInfoNameFormat = "prn-info-%zu"; | 30 const char* kPrinterInfoNameFormat = "prn-info-%zu"; |
| 38 | 31 |
| 39 // Account for the terminating null character. | 32 // Account for the terminating null character. |
| 40 static const size_t kClientIdSize = 32 + 1; | 33 static const size_t kClientIdSize = 32 + 1; |
| 41 static char g_client_id[kClientIdSize]; | 34 static char g_client_id[kClientIdSize]; |
| 42 | 35 |
| 43 void SetClientIdImpl(const std::string& client_id, | 36 void SetClientIdImpl(const std::string& client_id, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 72 std::string key = base::StringPrintf(kExtensionNameFormat, i); | 65 std::string key = base::StringPrintf(kExtensionNameFormat, i); |
| 73 if (iter != extension_ids.end()) { | 66 if (iter != extension_ids.end()) { |
| 74 SetCrashKeyValue(key, *iter); | 67 SetCrashKeyValue(key, *iter); |
| 75 ++iter; | 68 ++iter; |
| 76 } else { | 69 } else { |
| 77 ClearCrashKey(key); | 70 ClearCrashKey(key); |
| 78 } | 71 } |
| 79 } | 72 } |
| 80 } | 73 } |
| 81 | 74 |
| 82 void SetGpuKeyValue(const char* param_name, const std::string& value_str, | |
| 83 SetCrashKeyValueFuncT set_key_func) { | |
| 84 set_key_func(param_name, value_str); | |
| 85 } | |
| 86 | |
| 87 void SetGpuInfoImpl(const gpu::GPUInfo& gpu_info, | |
| 88 SetCrashKeyValueFuncT set_key_func) { | |
| 89 SetGpuKeyValue(kGPUVendorIdParamName, | |
| 90 base::StringPrintf("0x%04x", gpu_info.gpu.vendor_id), | |
| 91 set_key_func); | |
| 92 SetGpuKeyValue(kGPUDeviceIdParamName, | |
| 93 base::StringPrintf("0x%04x", gpu_info.gpu.device_id), | |
| 94 set_key_func); | |
| 95 SetGpuKeyValue(kGPUDriverVersionParamName, | |
| 96 gpu_info.driver_version, | |
| 97 set_key_func); | |
| 98 SetGpuKeyValue(kGPUPixelShaderVersionParamName, | |
| 99 gpu_info.pixel_shader_version, | |
| 100 set_key_func); | |
| 101 SetGpuKeyValue(kGPUVertexShaderVersionParamName, | |
| 102 gpu_info.vertex_shader_version, | |
| 103 set_key_func); | |
| 104 SetGpuKeyValue(kGPUGLVersionParamName, | |
| 105 gpu_info.gl_version, | |
| 106 set_key_func); | |
| 107 } | |
| 108 | |
| 109 void SetGpuInfo(const gpu::GPUInfo& gpu_info) { | |
| 110 SetGpuInfoImpl(gpu_info, SetCrashKeyValue); | |
| 111 } | |
| 112 | |
| 113 void SetPrinterInfo(const char* printer_info) { | 75 void SetPrinterInfo(const char* printer_info) { |
| 114 std::vector<std::string> info; | 76 std::vector<std::string> info; |
| 115 base::SplitString(printer_info, ';', &info); | 77 base::SplitString(printer_info, ';', &info); |
| 116 info.resize(kMaxReportedPrinterRecords); | 78 info.resize(kMaxReportedPrinterRecords); |
| 117 for (size_t i = 0; i < info.size(); ++i) { | 79 for (size_t i = 0; i < info.size(); ++i) { |
| 118 std::string key = base::StringPrintf(kPrinterInfoNameFormat, i); | 80 std::string key = base::StringPrintf(kPrinterInfoNameFormat, i); |
| 119 if (!info[i].empty()) { | 81 if (!info[i].empty()) { |
| 120 SetCrashKeyValue(key, info[i]); | 82 SetCrashKeyValue(key, info[i]); |
| 121 } else { | 83 } else { |
| 122 ClearCrashKey(key); | 84 ClearCrashKey(key); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 base::StringPrintf("%zu", experiments.size())); | 151 base::StringPrintf("%zu", experiments.size())); |
| 190 } | 152 } |
| 191 | 153 |
| 192 void SetChannel(const std::string& channel) { | 154 void SetChannel(const std::string& channel) { |
| 193 // This should match the corresponding string in breakpad_win.cc. | 155 // This should match the corresponding string in breakpad_win.cc. |
| 194 const std::string kChannelKey = "channel"; | 156 const std::string kChannelKey = "channel"; |
| 195 SetCrashKeyValue(kChannelKey, channel); | 157 SetCrashKeyValue(kChannelKey, channel); |
| 196 } | 158 } |
| 197 | 159 |
| 198 } // namespace child_process_logging | 160 } // namespace child_process_logging |
| OLD | NEW |