OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/crash_keys.h" | 5 #include "chrome/common/crash_keys.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_split.h" |
9 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
11 | 12 |
12 #if defined(OS_MACOSX) | 13 #if defined(OS_MACOSX) |
13 #include "breakpad/src/common/simple_string_dictionary.h" | 14 #include "breakpad/src/common/simple_string_dictionary.h" |
14 #elif defined(OS_WIN) | 15 #elif defined(OS_WIN) |
15 #include "breakpad/src/client/windows/common/ipc_protocol.h" | 16 #include "breakpad/src/client/windows/common/ipc_protocol.h" |
16 #endif | 17 #endif |
17 | 18 |
18 namespace crash_keys { | 19 namespace crash_keys { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 const char kGPUDriverVersion[] = "gpu-driver"; | 65 const char kGPUDriverVersion[] = "gpu-driver"; |
65 const char kGPUPixelShaderVersion[] = "gpu-psver"; | 66 const char kGPUPixelShaderVersion[] = "gpu-psver"; |
66 const char kGPUVertexShaderVersion[] = "gpu-vsver"; | 67 const char kGPUVertexShaderVersion[] = "gpu-vsver"; |
67 #if defined(OS_LINUX) | 68 #if defined(OS_LINUX) |
68 const char kGPUVendor[] = "gpu-gl-vendor"; | 69 const char kGPUVendor[] = "gpu-gl-vendor"; |
69 const char kGPURenderer[] = "gpu-gl-renderer"; | 70 const char kGPURenderer[] = "gpu-gl-renderer"; |
70 #elif defined(OS_MACOSX) | 71 #elif defined(OS_MACOSX) |
71 const char kGPUGLVersion[] = "gpu-glver"; | 72 const char kGPUGLVersion[] = "gpu-glver"; |
72 #endif | 73 #endif |
73 | 74 |
| 75 const char kPrinterInfo[] = "prn-info-%" PRIuS; |
| 76 |
74 #if defined(OS_MACOSX) | 77 #if defined(OS_MACOSX) |
75 namespace mac { | 78 namespace mac { |
76 | 79 |
77 const char kFirstNSException[] = "firstexception"; | 80 const char kFirstNSException[] = "firstexception"; |
78 const char kFirstNSExceptionTrace[] = "firstexception_bt"; | 81 const char kFirstNSExceptionTrace[] = "firstexception_bt"; |
79 | 82 |
80 const char kLastNSException[] = "lastexception"; | 83 const char kLastNSException[] = "lastexception"; |
81 const char kLastNSExceptionTrace[] = "lastexception_bt"; | 84 const char kLastNSExceptionTrace[] = "lastexception_bt"; |
82 | 85 |
83 const char kNSException[] = "nsexception"; | 86 const char kNSException[] = "nsexception"; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 const size_t formatted_key_len = sizeof(formatted_keys[0]); | 156 const size_t formatted_key_len = sizeof(formatted_keys[0]); |
154 for (size_t i = 0; i < kExtensionIDMaxCount; ++i) { | 157 for (size_t i = 0; i < kExtensionIDMaxCount; ++i) { |
155 int n = base::snprintf( | 158 int n = base::snprintf( |
156 formatted_keys[i], formatted_key_len, kExtensionID, i); | 159 formatted_keys[i], formatted_key_len, kExtensionID, i); |
157 DCHECK_GT(n, 0); | 160 DCHECK_GT(n, 0); |
158 base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize }; | 161 base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize }; |
159 keys.push_back(crash_key); | 162 keys.push_back(crash_key); |
160 } | 163 } |
161 } | 164 } |
162 | 165 |
| 166 // Register the printer info. |
| 167 { |
| 168 static char formatted_keys[kPrinterInfoCount][sizeof(kPrinterInfo) + 1] = |
| 169 {{ 0 }}; |
| 170 const size_t formatted_key_len = sizeof(formatted_keys[0]); |
| 171 for (size_t i = 0; i < kPrinterInfoCount; ++i) { |
| 172 // Key names are 1-indexed. |
| 173 int n = base::snprintf( |
| 174 formatted_keys[i], formatted_key_len, kPrinterInfo, i + 1); |
| 175 DCHECK_GT(n, 0); |
| 176 base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize }; |
| 177 keys.push_back(crash_key); |
| 178 } |
| 179 } |
| 180 |
163 return base::debug::InitCrashKeys(&keys.at(0), keys.size(), | 181 return base::debug::InitCrashKeys(&keys.at(0), keys.size(), |
164 kSingleChunkLength); | 182 kSingleChunkLength); |
165 } | 183 } |
166 | 184 |
167 void SetActiveExtensions(const std::set<std::string>& extensions) { | 185 void SetActiveExtensions(const std::set<std::string>& extensions) { |
168 base::debug::SetCrashKeyValue(kNumExtensionsCount, | 186 base::debug::SetCrashKeyValue(kNumExtensionsCount, |
169 base::StringPrintf("%" PRIuS, extensions.size())); | 187 base::StringPrintf("%" PRIuS, extensions.size())); |
170 | 188 |
171 std::set<std::string>::const_iterator it = extensions.begin(); | 189 std::set<std::string>::const_iterator it = extensions.begin(); |
172 for (size_t i = 0; i < kExtensionIDMaxCount; ++i) { | 190 for (size_t i = 0; i < kExtensionIDMaxCount; ++i) { |
173 std::string key = base::StringPrintf(kExtensionID, i); | 191 std::string key = base::StringPrintf(kExtensionID, i); |
174 if (it == extensions.end()) { | 192 if (it == extensions.end()) { |
175 base::debug::ClearCrashKey(key); | 193 base::debug::ClearCrashKey(key); |
176 } else { | 194 } else { |
177 base::debug::SetCrashKeyValue(key, *it); | 195 base::debug::SetCrashKeyValue(key, *it); |
178 ++it; | 196 ++it; |
179 } | 197 } |
180 } | 198 } |
181 } | 199 } |
182 | 200 |
| 201 ScopedPrinterInfo::ScopedPrinterInfo(const base::StringPiece& data) { |
| 202 std::vector<std::string> info; |
| 203 base::SplitString(data.as_string(), ';', &info); |
| 204 for (size_t i = 0; i < kPrinterInfoCount; ++i) { |
| 205 std::string key = base::StringPrintf(kPrinterInfo, i + 1); |
| 206 std::string value; |
| 207 if (i < info.size()) |
| 208 value = info[i]; |
| 209 base::debug::SetCrashKeyValue(key, value); |
| 210 } |
| 211 } |
| 212 |
| 213 ScopedPrinterInfo::~ScopedPrinterInfo() { |
| 214 for (size_t i = 0; i < kPrinterInfoCount; ++i) { |
| 215 std::string key = base::StringPrintf(kPrinterInfo, i + 1); |
| 216 base::debug::ClearCrashKey(key); |
| 217 } |
| 218 } |
| 219 |
183 } // namespace crash_keys | 220 } // namespace crash_keys |
OLD | NEW |