Chromium Code Reviews| 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 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/common/metrics/variations/variations_util.h" | 13 #include "chrome/common/metrics/variations/variations_util.h" |
| 14 #include "chrome/installer/util/google_update_settings.h" | 14 #include "chrome/installer/util/google_update_settings.h" |
| 15 #include "gpu/config/gpu_info.h" | |
| 16 #include "url/gurl.h" | 15 #include "url/gurl.h" |
|
Lei Zhang
2013/08/26 21:41:01
I think we forgot to remove this in the last CL.
Robert Sesek
2013/08/27 15:34:52
Done.
| |
| 17 | 16 |
| 18 namespace child_process_logging { | 17 namespace child_process_logging { |
| 19 | 18 |
| 20 // Account for the terminating null character. | 19 // Account for the terminating null character. |
| 21 static const size_t kClientIdSize = 32 + 1; | 20 static const size_t kClientIdSize = 32 + 1; |
| 22 static const size_t kChannelSize = 32; | 21 static const size_t kChannelSize = 32; |
| 23 | 22 |
| 24 // We use static strings to hold the most recent active url and the client | 23 // We use static strings to hold the most recent active url and the client |
| 25 // identifier. If we crash, the crash handler code will send the contents of | 24 // identifier. If we crash, the crash handler code will send the contents of |
| 26 // these strings to the browser. | 25 // these strings to the browser. |
| 27 char g_client_id[kClientIdSize]; | 26 char g_client_id[kClientIdSize]; |
| 28 | 27 |
| 29 char g_channel[kChannelSize] = ""; | 28 char g_channel[kChannelSize] = ""; |
| 30 | 29 |
| 31 static const size_t kGpuStringSize = 32; | |
| 32 char g_gpu_vendor_id[kGpuStringSize] = ""; | |
| 33 char g_gpu_device_id[kGpuStringSize] = ""; | |
| 34 char g_gpu_gl_vendor[kGpuStringSize] = ""; | |
| 35 char g_gpu_gl_renderer[kGpuStringSize] = ""; | |
| 36 char g_gpu_driver_ver[kGpuStringSize] = ""; | |
| 37 char g_gpu_ps_ver[kGpuStringSize] = ""; | |
| 38 char g_gpu_vs_ver[kGpuStringSize] = ""; | |
| 39 | |
| 40 char g_printer_info[kPrinterInfoStrLen * kMaxReportedPrinterRecords + 1] = ""; | 30 char g_printer_info[kPrinterInfoStrLen * kMaxReportedPrinterRecords + 1] = ""; |
| 41 | 31 |
| 42 static const size_t kNumSize = 32; | 32 static const size_t kNumSize = 32; |
| 43 char g_num_extensions[kNumSize] = ""; | 33 char g_num_extensions[kNumSize] = ""; |
| 44 char g_num_switches[kNumSize] = ""; | 34 char g_num_switches[kNumSize] = ""; |
| 45 char g_num_variations[kNumSize] = ""; | 35 char g_num_variations[kNumSize] = ""; |
| 46 char g_num_views[kNumSize] = ""; | 36 char g_num_views[kNumSize] = ""; |
| 47 | 37 |
| 48 static const size_t kMaxExtensionSize = | 38 static const size_t kMaxExtensionSize = |
| 49 kExtensionLen * kMaxReportedActiveExtensions + 1; | 39 kExtensionLen * kMaxReportedActiveExtensions + 1; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 std::set<std::string>::const_iterator iter = extension_ids.begin(); | 71 std::set<std::string>::const_iterator iter = extension_ids.begin(); |
| 82 for (size_t i = 0; | 72 for (size_t i = 0; |
| 83 i < kMaxReportedActiveExtensions && iter != extension_ids.end(); | 73 i < kMaxReportedActiveExtensions && iter != extension_ids.end(); |
| 84 ++i, ++iter) { | 74 ++i, ++iter) { |
| 85 extension_str += *iter; | 75 extension_str += *iter; |
| 86 } | 76 } |
| 87 base::strlcpy(g_extension_ids, extension_str.c_str(), | 77 base::strlcpy(g_extension_ids, extension_str.c_str(), |
| 88 arraysize(g_extension_ids)); | 78 arraysize(g_extension_ids)); |
| 89 } | 79 } |
| 90 | 80 |
| 91 void SetGpuInfo(const gpu::GPUInfo& gpu_info) { | |
| 92 snprintf(g_gpu_vendor_id, arraysize(g_gpu_vendor_id), "0x%04x", | |
| 93 gpu_info.gpu.vendor_id); | |
| 94 snprintf(g_gpu_device_id, arraysize(g_gpu_device_id), "0x%04x", | |
| 95 gpu_info.gpu.device_id); | |
| 96 base::strlcpy(g_gpu_gl_vendor, gpu_info.gl_vendor.c_str(), | |
| 97 arraysize(g_gpu_gl_vendor)); | |
| 98 base::strlcpy(g_gpu_gl_renderer, gpu_info.gl_renderer.c_str(), | |
| 99 arraysize(g_gpu_gl_renderer)); | |
| 100 base::strlcpy(g_gpu_driver_ver, gpu_info.driver_version.c_str(), | |
| 101 arraysize(g_gpu_driver_ver)); | |
| 102 base::strlcpy(g_gpu_ps_ver, gpu_info.pixel_shader_version.c_str(), | |
| 103 arraysize(g_gpu_ps_ver)); | |
| 104 base::strlcpy(g_gpu_vs_ver, gpu_info.vertex_shader_version.c_str(), | |
| 105 arraysize(g_gpu_vs_ver)); | |
| 106 } | |
| 107 | |
| 108 void SetPrinterInfo(const char* printer_info) { | 81 void SetPrinterInfo(const char* printer_info) { |
| 109 std::string printer_info_str; | 82 std::string printer_info_str; |
| 110 std::vector<std::string> info; | 83 std::vector<std::string> info; |
| 111 base::SplitString(printer_info, L';', &info); | 84 base::SplitString(printer_info, L';', &info); |
| 112 DCHECK_LE(info.size(), kMaxReportedPrinterRecords); | 85 DCHECK_LE(info.size(), kMaxReportedPrinterRecords); |
| 113 for (size_t i = 0; i < info.size(); ++i) { | 86 for (size_t i = 0; i < info.size(); ++i) { |
| 114 printer_info_str += info[i]; | 87 printer_info_str += info[i]; |
| 115 // Truncate long switches, align short ones with spaces to be trimmed later. | 88 // Truncate long switches, align short ones with spaces to be trimmed later. |
| 116 printer_info_str.resize((i + 1) * kPrinterInfoStrLen, ' '); | 89 printer_info_str.resize((i + 1) * kPrinterInfoStrLen, ' '); |
| 117 } | 90 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 // simultaneously. | 135 // simultaneously. |
| 163 snprintf(g_num_variations, arraysize(g_num_variations), "%" PRIuS, | 136 snprintf(g_num_variations, arraysize(g_num_variations), "%" PRIuS, |
| 164 experiments.size()); | 137 experiments.size()); |
| 165 } | 138 } |
| 166 | 139 |
| 167 void SetChannel(const std::string& channel) { | 140 void SetChannel(const std::string& channel) { |
| 168 base::strlcpy(g_channel, channel.c_str(), arraysize(g_channel)); | 141 base::strlcpy(g_channel, channel.c_str(), arraysize(g_channel)); |
| 169 } | 142 } |
| 170 | 143 |
| 171 } // namespace child_process_logging | 144 } // namespace child_process_logging |
| OLD | NEW |