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/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/string_split.h" | |
11 #include "base/string_util.h" | 12 #include "base/string_util.h" |
12 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
13 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" |
14 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
15 #include "chrome/installer/util/google_update_settings.h" | 16 #include "chrome/installer/util/google_update_settings.h" |
16 #include "content/public/common/gpu_info.h" | 17 #include "content/public/common/gpu_info.h" |
17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
18 | 19 |
19 namespace child_process_logging { | 20 namespace child_process_logging { |
20 | 21 |
21 using base::mac::SetCrashKeyValueFuncPtr; | 22 using base::mac::SetCrashKeyValueFuncPtr; |
22 using base::mac::ClearCrashKeyValueFuncPtr; | 23 using base::mac::ClearCrashKeyValueFuncPtr; |
23 using base::mac::SetCrashKeyValue; | 24 using base::mac::SetCrashKeyValue; |
24 using base::mac::ClearCrashKey; | 25 using base::mac::ClearCrashKey; |
25 | 26 |
26 const int kMaxNumCrashURLChunks = 8; | 27 const int kMaxNumCrashURLChunks = 8; |
27 const int kMaxNumURLChunkValueLength = 255; | 28 const int kMaxNumURLChunkValueLength = 255; |
28 const char *kUrlChunkFormatStr = "url-chunk-%d"; | 29 const char *kUrlChunkFormatStr = "url-chunk-%d"; |
29 const char *kGuidParamName = "guid"; | 30 const char *kGuidParamName = "guid"; |
30 const char *kGPUVendorIdParamName = "gpu-venid"; | 31 const char *kGPUVendorIdParamName = "gpu-venid"; |
31 const char *kGPUDeviceIdParamName = "gpu-devid"; | 32 const char *kGPUDeviceIdParamName = "gpu-devid"; |
32 const char *kGPUDriverVersionParamName = "gpu-driver"; | 33 const char *kGPUDriverVersionParamName = "gpu-driver"; |
33 const char *kGPUPixelShaderVersionParamName = "gpu-psver"; | 34 const char *kGPUPixelShaderVersionParamName = "gpu-psver"; |
34 const char *kGPUVertexShaderVersionParamName = "gpu-vsver"; | 35 const char *kGPUVertexShaderVersionParamName = "gpu-vsver"; |
35 const char *kGPUGLVersionParamName = "gpu-glver"; | 36 const char *kGPUGLVersionParamName = "gpu-glver"; |
36 const char *kNumberOfViews = "num-views"; | 37 const char *kNumberOfViews = "num-views"; |
37 NSString* const kNumExtensionsName = @"num-extensions"; | 38 NSString* const kNumExtensionsName = @"num-extensions"; |
38 NSString* const kExtensionNameFormat = @"extension-%d"; | 39 NSString* const kExtensionNameFormat = @"extension-%d"; |
40 NSString* const kPrinterInfoNameFormat = @"prn-info-%d"; | |
39 | 41 |
40 // Account for the terminating null character. | 42 // Account for the terminating null character. |
41 static const size_t kClientIdSize = 32 + 1; | 43 static const size_t kClientIdSize = 32 + 1; |
42 static char g_client_id[kClientIdSize]; | 44 static char g_client_id[kClientIdSize]; |
43 | 45 |
44 void SetActiveURLImpl(const GURL& url, | 46 void SetActiveURLImpl(const GURL& url, |
45 SetCrashKeyValueFuncPtr set_key_func, | 47 SetCrashKeyValueFuncPtr set_key_func, |
46 ClearCrashKeyValueFuncPtr clear_key_func) { | 48 ClearCrashKeyValueFuncPtr clear_key_func) { |
47 | 49 |
48 NSString *kUrlChunkFormatStr_utf8 = [NSString | 50 NSString *kUrlChunkFormatStr_utf8 = [NSString |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 set_key_func); | 158 set_key_func); |
157 SetGpuKeyValue(kGPUGLVersionParamName, | 159 SetGpuKeyValue(kGPUGLVersionParamName, |
158 gpu_info.gl_version, | 160 gpu_info.gl_version, |
159 set_key_func); | 161 set_key_func); |
160 } | 162 } |
161 | 163 |
162 void SetGpuInfo(const content::GPUInfo& gpu_info) { | 164 void SetGpuInfo(const content::GPUInfo& gpu_info) { |
163 SetGpuInfoImpl(gpu_info, SetCrashKeyValue); | 165 SetGpuInfoImpl(gpu_info, SetCrashKeyValue); |
164 } | 166 } |
165 | 167 |
168 void SetPrinterInfo(const char* printer_info) { | |
169 std::vector<std::string> info; | |
170 base::SplitString(printer_info, L';', &info); | |
171 info.resize(kMaxReportedPrinterRecords); | |
172 for (size_t i = 0; i < info.size(); ++i) { | |
173 NSString* key = [NSString stringWithFormat:kPrinterInfoNameFormat, i]; | |
174 NSString *value = [NSString stringWithUTF8String:info[i].c_str()]; | |
175 SetCrashKeyValue(key, value); | |
Scott Hess - ex-Googler
2012/03/14 21:26:37
I _think_ this'll leave you with all N keys, every
Vitaly Buka (NO REVIEWS)
2012/03/14 21:37:33
Done.
| |
176 } | |
177 } | |
166 | 178 |
167 void SetNumberOfViewsImpl(int number_of_views, | 179 void SetNumberOfViewsImpl(int number_of_views, |
168 SetCrashKeyValueFuncPtr set_key_func) { | 180 SetCrashKeyValueFuncPtr set_key_func) { |
169 NSString *key = [NSString stringWithUTF8String:kNumberOfViews]; | 181 NSString *key = [NSString stringWithUTF8String:kNumberOfViews]; |
170 NSString *value = [NSString stringWithFormat:@"%d", number_of_views]; | 182 NSString *value = [NSString stringWithFormat:@"%d", number_of_views]; |
171 set_key_func(key, value); | 183 set_key_func(key, value); |
172 } | 184 } |
173 | 185 |
174 void SetNumberOfViews(int number_of_views) { | 186 void SetNumberOfViews(int number_of_views) { |
175 SetNumberOfViewsImpl(number_of_views, SetCrashKeyValue); | 187 SetNumberOfViewsImpl(number_of_views, SetCrashKeyValue); |
(...skipping 30 matching lines...) Expand all Loading... | |
206 } | 218 } |
207 | 219 |
208 void SetChannel(const std::string& channel) { | 220 void SetChannel(const std::string& channel) { |
209 // This should match the corresponding string in breakpad_win.cc. | 221 // This should match the corresponding string in breakpad_win.cc. |
210 NSString* const kChannelKey = @"channel"; | 222 NSString* const kChannelKey = @"channel"; |
211 | 223 |
212 SetCrashKeyValue(kChannelKey, base::SysUTF8ToNSString(channel)); | 224 SetCrashKeyValue(kChannelKey, base::SysUTF8ToNSString(channel)); |
213 } | 225 } |
214 | 226 |
215 } // namespace child_process_logging | 227 } // namespace child_process_logging |
OLD | NEW |