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/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 | 22 |
23 // 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 |
24 // 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 |
25 // these strings to the browser. | 25 // these strings to the browser. |
26 char g_active_url[kMaxActiveURLSize]; | 26 char g_active_url[kMaxActiveURLSize]; |
27 char g_client_id[kClientIdSize]; | 27 char g_client_id[kClientIdSize]; |
28 | 28 |
29 char g_channel[kChannelSize] = ""; | 29 char g_channel[kChannelSize] = ""; |
30 | 30 |
31 static const size_t kGpuStringSize = 32; | 31 static const size_t kGpuStringSize = 32; |
32 | |
33 char g_gpu_vendor_id[kGpuStringSize] = ""; | 32 char g_gpu_vendor_id[kGpuStringSize] = ""; |
34 char g_gpu_device_id[kGpuStringSize] = ""; | 33 char g_gpu_device_id[kGpuStringSize] = ""; |
35 char g_gpu_driver_ver[kGpuStringSize] = ""; | 34 char g_gpu_driver_ver[kGpuStringSize] = ""; |
36 char g_gpu_ps_ver[kGpuStringSize] = ""; | 35 char g_gpu_ps_ver[kGpuStringSize] = ""; |
37 char g_gpu_vs_ver[kGpuStringSize] = ""; | 36 char g_gpu_vs_ver[kGpuStringSize] = ""; |
38 | 37 |
38 char g_printer_info[256] = ""; | |
Lei Zhang
2012/03/14 04:20:05
This is unused. You need to put this into the cras
Vitaly Buka (NO REVIEWS)
2012/03/14 20:37:42
Done.
| |
39 | |
39 static const size_t kNumSize = 32; | 40 static const size_t kNumSize = 32; |
40 char g_num_extensions[kNumSize] = ""; | 41 char g_num_extensions[kNumSize] = ""; |
41 char g_num_switches[kNumSize] = ""; | 42 char g_num_switches[kNumSize] = ""; |
42 char g_num_views[kNumSize] = ""; | 43 char g_num_views[kNumSize] = ""; |
43 | 44 |
44 static const size_t kMaxExtensionSize = | 45 static const size_t kMaxExtensionSize = |
45 kExtensionLen * kMaxReportedActiveExtensions + 1; | 46 kExtensionLen * kMaxReportedActiveExtensions + 1; |
46 char g_extension_ids[kMaxExtensionSize] = ""; | 47 char g_extension_ids[kMaxExtensionSize] = ""; |
47 | 48 |
48 // Assume command line switches are less than 64 chars. | 49 // Assume command line switches are less than 64 chars. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 strncpy(g_gpu_ps_ver, | 97 strncpy(g_gpu_ps_ver, |
97 gpu_info.pixel_shader_version.c_str(), | 98 gpu_info.pixel_shader_version.c_str(), |
98 kGpuStringSize - 1); | 99 kGpuStringSize - 1); |
99 g_gpu_ps_ver[kGpuStringSize - 1] = '\0'; | 100 g_gpu_ps_ver[kGpuStringSize - 1] = '\0'; |
100 strncpy(g_gpu_vs_ver, | 101 strncpy(g_gpu_vs_ver, |
101 gpu_info.vertex_shader_version.c_str(), | 102 gpu_info.vertex_shader_version.c_str(), |
102 kGpuStringSize - 1); | 103 kGpuStringSize - 1); |
103 g_gpu_vs_ver[kGpuStringSize - 1] = '\0'; | 104 g_gpu_vs_ver[kGpuStringSize - 1] = '\0'; |
104 } | 105 } |
105 | 106 |
107 void SetPrinterInfo(const char* printer_info) { | |
eroman
2012/03/14 02:12:49
This is using a different format than the mac/wind
Vitaly Buka (NO REVIEWS)
2012/03/14 20:37:42
Actually it's like URL and extensions here. It's d
| |
108 strncpy(g_printer_info, printer_info, arraysize(g_printer_info) - 1); | |
109 g_printer_info[arraysize(g_printer_info) - 1] = '\0'; | |
110 } | |
111 | |
106 void SetNumberOfViews(int number_of_views) { | 112 void SetNumberOfViews(int number_of_views) { |
107 snprintf(g_num_views, kNumSize - 1, "%d", number_of_views); | 113 snprintf(g_num_views, kNumSize - 1, "%d", number_of_views); |
108 g_num_views[kNumSize - 1] = '\0'; | 114 g_num_views[kNumSize - 1] = '\0'; |
109 } | 115 } |
110 | 116 |
111 void SetCommandLine(const CommandLine* command_line) { | 117 void SetCommandLine(const CommandLine* command_line) { |
112 const CommandLine::StringVector& argv = command_line->argv(); | 118 const CommandLine::StringVector& argv = command_line->argv(); |
113 | 119 |
114 snprintf(g_num_switches, kNumSize - 1, "%" PRIuS, argv.size() - 1); | 120 snprintf(g_num_switches, kNumSize - 1, "%" PRIuS, argv.size() - 1); |
115 g_num_switches[kNumSize - 1] = '\0'; | 121 g_num_switches[kNumSize - 1] = '\0'; |
116 | 122 |
117 std::string command_line_str; | 123 std::string command_line_str; |
118 for (size_t argv_i = 1; | 124 for (size_t argv_i = 1; |
119 argv_i < argv.size() && argv_i <= kMaxSwitches; | 125 argv_i < argv.size() && argv_i <= kMaxSwitches; |
120 ++argv_i) { | 126 ++argv_i) { |
121 command_line_str += argv[argv_i]; | 127 command_line_str += argv[argv_i]; |
122 // Truncate long switches, align short ones with spaces to be trimmed later. | 128 // Truncate long switches, align short ones with spaces to be trimmed later. |
123 command_line_str.resize(argv_i * kSwitchLen, ' '); | 129 command_line_str.resize(argv_i * kSwitchLen, ' '); |
124 } | 130 } |
125 strncpy(g_switches, command_line_str.c_str(), kMaxSwitchesSize - 1); | 131 strncpy(g_switches, command_line_str.c_str(), kMaxSwitchesSize - 1); |
126 g_switches[kMaxSwitchesSize - 1] = '\0'; | 132 g_switches[kMaxSwitchesSize - 1] = '\0'; |
127 } | 133 } |
128 | 134 |
129 void SetChannel(const std::string& channel) { | 135 void SetChannel(const std::string& channel) { |
130 strncpy(g_channel, channel.c_str(), kChannelSize - 1); | 136 strncpy(g_channel, channel.c_str(), kChannelSize - 1); |
131 g_channel[kChannelSize - 1] = '\0'; | 137 g_channel[kChannelSize - 1] = '\0'; |
132 } | 138 } |
133 | 139 |
134 } // namespace child_process_logging | 140 } // namespace child_process_logging |
OLD | NEW |