| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 const char *kGuidParamName = "guid"; | 21 const char *kGuidParamName = "guid"; |
| 22 const char *kGPUVendorIdParamName = "vendid"; | 22 const char *kGPUVendorIdParamName = "vendid"; |
| 23 const char *kGPUDeviceIdParamName = "devid"; | 23 const char *kGPUDeviceIdParamName = "devid"; |
| 24 const char *kGPUDriverVersionParamName = "driver"; | 24 const char *kGPUDriverVersionParamName = "driver"; |
| 25 const char *kGPUPixelShaderVersionParamName = "psver"; | 25 const char *kGPUPixelShaderVersionParamName = "psver"; |
| 26 const char *kGPUVertexShaderVersionParamName = "vsver"; | 26 const char *kGPUVertexShaderVersionParamName = "vsver"; |
| 27 | 27 |
| 28 static SetCrashKeyValueFuncPtr g_set_key_func; | 28 static SetCrashKeyValueFuncPtr g_set_key_func; |
| 29 static ClearCrashKeyValueFuncPtr g_clear_key_func; | 29 static ClearCrashKeyValueFuncPtr g_clear_key_func; |
| 30 | 30 |
| 31 // Account for the terminating null character. |
| 32 static const size_t kClientIdSize = 32 + 1; |
| 33 static char g_client_id[kClientIdSize]; |
| 34 |
| 31 void SetCrashKeyFunctions(SetCrashKeyValueFuncPtr set_key_func, | 35 void SetCrashKeyFunctions(SetCrashKeyValueFuncPtr set_key_func, |
| 32 ClearCrashKeyValueFuncPtr clear_key_func) { | 36 ClearCrashKeyValueFuncPtr clear_key_func) { |
| 33 g_set_key_func = set_key_func; | 37 g_set_key_func = set_key_func; |
| 34 g_clear_key_func = clear_key_func; | 38 g_clear_key_func = clear_key_func; |
| 35 } | 39 } |
| 36 | 40 |
| 37 void SetActiveURLImpl(const GURL& url, | 41 void SetActiveURLImpl(const GURL& url, |
| 38 SetCrashKeyValueFuncPtr set_key_func, | 42 SetCrashKeyValueFuncPtr set_key_func, |
| 39 ClearCrashKeyValueFuncPtr clear_key_func) { | 43 ClearCrashKeyValueFuncPtr clear_key_func) { |
| 40 | 44 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 90 |
| 87 void SetActiveURL(const GURL& url) { | 91 void SetActiveURL(const GURL& url) { |
| 88 if (g_set_key_func && g_clear_key_func) | 92 if (g_set_key_func && g_clear_key_func) |
| 89 SetActiveURLImpl(url, g_set_key_func, g_clear_key_func); | 93 SetActiveURLImpl(url, g_set_key_func, g_clear_key_func); |
| 90 } | 94 } |
| 91 | 95 |
| 92 void SetClientId(const std::string& client_id) { | 96 void SetClientId(const std::string& client_id) { |
| 93 std::string str(client_id); | 97 std::string str(client_id); |
| 94 ReplaceSubstringsAfterOffset(&str, 0, "-", ""); | 98 ReplaceSubstringsAfterOffset(&str, 0, "-", ""); |
| 95 | 99 |
| 100 base::strlcpy(g_client_id, str.c_str(), kClientIdSize); |
| 96 if (g_set_key_func) | 101 if (g_set_key_func) |
| 97 SetClientIdImpl(str, g_set_key_func); | 102 SetClientIdImpl(str, g_set_key_func); |
| 98 | 103 |
| 99 std::wstring wstr = ASCIIToWide(str); | 104 std::wstring wstr = ASCIIToWide(str); |
| 100 GoogleUpdateSettings::SetMetricsId(wstr); | 105 GoogleUpdateSettings::SetMetricsId(wstr); |
| 101 } | 106 } |
| 102 | 107 |
| 108 std::string GetClientId() { |
| 109 return std::string(g_client_id); |
| 110 } |
| 111 |
| 103 void SetActiveExtensions(const std::set<std::string>& extension_ids) { | 112 void SetActiveExtensions(const std::set<std::string>& extension_ids) { |
| 104 // TODO(port) | 113 // TODO(port) |
| 105 } | 114 } |
| 106 | 115 |
| 107 void SetGpuKeyValue(const char* param_name, const std::string& value_str, | 116 void SetGpuKeyValue(const char* param_name, const std::string& value_str, |
| 108 SetCrashKeyValueFuncPtr set_key_func) { | 117 SetCrashKeyValueFuncPtr set_key_func) { |
| 109 NSString *key = [NSString stringWithUTF8String:param_name]; | 118 NSString *key = [NSString stringWithUTF8String:param_name]; |
| 110 NSString *value = [NSString stringWithUTF8String:value_str.c_str()]; | 119 NSString *value = [NSString stringWithUTF8String:value_str.c_str()]; |
| 111 set_key_func(key, value); | 120 set_key_func(key, value); |
| 112 } | 121 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 129 base::UintToString(gpu_info.vertex_shader_version()), | 138 base::UintToString(gpu_info.vertex_shader_version()), |
| 130 set_key_func); | 139 set_key_func); |
| 131 } | 140 } |
| 132 | 141 |
| 133 void SetGpuInfo(const GPUInfo& gpu_info) { | 142 void SetGpuInfo(const GPUInfo& gpu_info) { |
| 134 if (g_set_key_func) | 143 if (g_set_key_func) |
| 135 SetGpuInfoImpl(gpu_info, g_set_key_func); | 144 SetGpuInfoImpl(gpu_info, g_set_key_func); |
| 136 } | 145 } |
| 137 | 146 |
| 138 } // namespace child_process_logging | 147 } // namespace child_process_logging |
| OLD | NEW |