| 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 ClearCrashKey(key); |
| 175 if (!info[i].empty()) { |
| 176 NSString *value = [NSString stringWithUTF8String:info[i].c_str()]; |
| 177 SetCrashKeyValue(key, value); |
| 178 } |
| 179 } |
| 180 } |
| 166 | 181 |
| 167 void SetNumberOfViewsImpl(int number_of_views, | 182 void SetNumberOfViewsImpl(int number_of_views, |
| 168 SetCrashKeyValueFuncPtr set_key_func) { | 183 SetCrashKeyValueFuncPtr set_key_func) { |
| 169 NSString *key = [NSString stringWithUTF8String:kNumberOfViews]; | 184 NSString *key = [NSString stringWithUTF8String:kNumberOfViews]; |
| 170 NSString *value = [NSString stringWithFormat:@"%d", number_of_views]; | 185 NSString *value = [NSString stringWithFormat:@"%d", number_of_views]; |
| 171 set_key_func(key, value); | 186 set_key_func(key, value); |
| 172 } | 187 } |
| 173 | 188 |
| 174 void SetNumberOfViews(int number_of_views) { | 189 void SetNumberOfViews(int number_of_views) { |
| 175 SetNumberOfViewsImpl(number_of_views, SetCrashKeyValue); | 190 SetNumberOfViewsImpl(number_of_views, SetCrashKeyValue); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 206 } | 221 } |
| 207 | 222 |
| 208 void SetChannel(const std::string& channel) { | 223 void SetChannel(const std::string& channel) { |
| 209 // This should match the corresponding string in breakpad_win.cc. | 224 // This should match the corresponding string in breakpad_win.cc. |
| 210 NSString* const kChannelKey = @"channel"; | 225 NSString* const kChannelKey = @"channel"; |
| 211 | 226 |
| 212 SetCrashKeyValue(kChannelKey, base::SysUTF8ToNSString(channel)); | 227 SetCrashKeyValue(kChannelKey, base::SysUTF8ToNSString(channel)); |
| 213 } | 228 } |
| 214 | 229 |
| 215 } // namespace child_process_logging | 230 } // namespace child_process_logging |
| OLD | NEW |