| 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 <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 typedef void (__cdecl *MainSetPrinterInfo)(const wchar_t*); | 41 typedef void (__cdecl *MainSetPrinterInfo)(const wchar_t*); |
| 42 | 42 |
| 43 // exported in breakpad_win.cc: | 43 // exported in breakpad_win.cc: |
| 44 // void __declspec(dllexport) __cdecl SetNumberOfViews. | 44 // void __declspec(dllexport) __cdecl SetNumberOfViews. |
| 45 typedef void (__cdecl *MainSetNumberOfViews)(int); | 45 typedef void (__cdecl *MainSetNumberOfViews)(int); |
| 46 | 46 |
| 47 // exported in breakpad_win.cc: | 47 // exported in breakpad_win.cc: |
| 48 // void __declspec(dllexport) __cdecl SetCommandLine | 48 // void __declspec(dllexport) __cdecl SetCommandLine |
| 49 typedef void (__cdecl *MainSetCommandLine)(const CommandLine*); | 49 typedef void (__cdecl *MainSetCommandLine)(const CommandLine*); |
| 50 | 50 |
| 51 // exported in breakpad_field_trial_win.cc: |
| 52 // void __declspec(dllexport) __cdecl SetExperimentList |
| 53 typedef void (__cdecl *MainSetExperimentList)(const std::vector<string16>&); |
| 54 |
| 51 void SetActiveURL(const GURL& url) { | 55 void SetActiveURL(const GURL& url) { |
| 52 static MainSetActiveURL set_active_url = NULL; | 56 static MainSetActiveURL set_active_url = NULL; |
| 53 // note: benign race condition on set_active_url. | 57 // note: benign race condition on set_active_url. |
| 54 if (!set_active_url) { | 58 if (!set_active_url) { |
| 55 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 59 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 56 if (!exe_module) | 60 if (!exe_module) |
| 57 return; | 61 return; |
| 58 set_active_url = reinterpret_cast<MainSetActiveURL>( | 62 set_active_url = reinterpret_cast<MainSetActiveURL>( |
| 59 GetProcAddress(exe_module, "SetActiveURL")); | 63 GetProcAddress(exe_module, "SetActiveURL")); |
| 60 if (!set_active_url) | 64 if (!set_active_url) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 72 if (str.empty()) | 76 if (str.empty()) |
| 73 return; | 77 return; |
| 74 | 78 |
| 75 std::wstring wstr = ASCIIToWide(str); | 79 std::wstring wstr = ASCIIToWide(str); |
| 76 std::wstring old_wstr; | 80 std::wstring old_wstr; |
| 77 if (!GoogleUpdateSettings::GetMetricsId(&old_wstr) || | 81 if (!GoogleUpdateSettings::GetMetricsId(&old_wstr) || |
| 78 wstr != old_wstr) | 82 wstr != old_wstr) |
| 79 GoogleUpdateSettings::SetMetricsId(wstr); | 83 GoogleUpdateSettings::SetMetricsId(wstr); |
| 80 | 84 |
| 81 static MainSetClientId set_client_id = NULL; | 85 static MainSetClientId set_client_id = NULL; |
| 86 // note: benign race condition on set_client_id. |
| 82 if (!set_client_id) { | 87 if (!set_client_id) { |
| 83 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 88 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 84 if (!exe_module) | 89 if (!exe_module) |
| 85 return; | 90 return; |
| 86 set_client_id = reinterpret_cast<MainSetClientId>( | 91 set_client_id = reinterpret_cast<MainSetClientId>( |
| 87 GetProcAddress(exe_module, "SetClientId")); | 92 GetProcAddress(exe_module, "SetClientId")); |
| 88 if (!set_client_id) | 93 if (!set_client_id) |
| 89 return; | 94 return; |
| 90 } | 95 } |
| 91 (set_client_id)(wstr.c_str()); | 96 (set_client_id)(wstr.c_str()); |
| 92 } | 97 } |
| 93 | 98 |
| 94 std::string GetClientId() { | 99 std::string GetClientId() { |
| 95 std::wstring wstr_client_id; | 100 std::wstring wstr_client_id; |
| 96 if (GoogleUpdateSettings::GetMetricsId(&wstr_client_id)) | 101 if (GoogleUpdateSettings::GetMetricsId(&wstr_client_id)) |
| 97 return WideToASCII(wstr_client_id); | 102 return WideToASCII(wstr_client_id); |
| 98 else | 103 else |
| 99 return std::string(); | 104 return std::string(); |
| 100 } | 105 } |
| 101 | 106 |
| 102 void SetActiveExtensions(const std::set<std::string>& extension_ids) { | 107 void SetActiveExtensions(const std::set<std::string>& extension_ids) { |
| 103 static MainSetNumberOfExtensions set_number_of_extensions = NULL; | 108 static MainSetNumberOfExtensions set_number_of_extensions = NULL; |
| 109 // note: benign race condition on set_number_of_extensions. |
| 104 if (!set_number_of_extensions) { | 110 if (!set_number_of_extensions) { |
| 105 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 111 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 106 if (!exe_module) | 112 if (!exe_module) |
| 107 return; | 113 return; |
| 108 set_number_of_extensions = reinterpret_cast<MainSetNumberOfExtensions>( | 114 set_number_of_extensions = reinterpret_cast<MainSetNumberOfExtensions>( |
| 109 GetProcAddress(exe_module, "SetNumberOfExtensions")); | 115 GetProcAddress(exe_module, "SetNumberOfExtensions")); |
| 110 if (!set_number_of_extensions) | 116 if (!set_number_of_extensions) |
| 111 return; | 117 return; |
| 112 } | 118 } |
| 113 | 119 |
| 114 static MainSetExtensionID set_extension_id = NULL; | 120 static MainSetExtensionID set_extension_id = NULL; |
| 121 // note: benign race condition on set_extension_id. |
| 115 if (!set_extension_id) { | 122 if (!set_extension_id) { |
| 116 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 123 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 117 if (!exe_module) | 124 if (!exe_module) |
| 118 return; | 125 return; |
| 119 set_extension_id = reinterpret_cast<MainSetExtensionID>( | 126 set_extension_id = reinterpret_cast<MainSetExtensionID>( |
| 120 GetProcAddress(exe_module, "SetExtensionID")); | 127 GetProcAddress(exe_module, "SetExtensionID")); |
| 121 if (!set_extension_id) | 128 if (!set_extension_id) |
| 122 return; | 129 return; |
| 123 } | 130 } |
| 124 | 131 |
| 125 (set_number_of_extensions)(static_cast<int>(extension_ids.size())); | 132 (set_number_of_extensions)(static_cast<int>(extension_ids.size())); |
| 126 | 133 |
| 127 std::set<std::string>::const_iterator iter = extension_ids.begin(); | 134 std::set<std::string>::const_iterator iter = extension_ids.begin(); |
| 128 for (size_t i = 0; i < kMaxReportedActiveExtensions; ++i) { | 135 for (size_t i = 0; i < kMaxReportedActiveExtensions; ++i) { |
| 129 if (iter != extension_ids.end()) { | 136 if (iter != extension_ids.end()) { |
| 130 (set_extension_id)(i, ASCIIToWide(iter->c_str()).c_str()); | 137 (set_extension_id)(i, ASCIIToWide(iter->c_str()).c_str()); |
| 131 ++iter; | 138 ++iter; |
| 132 } else { | 139 } else { |
| 133 (set_extension_id)(i, L""); | 140 (set_extension_id)(i, L""); |
| 134 } | 141 } |
| 135 } | 142 } |
| 136 } | 143 } |
| 137 | 144 |
| 138 void SetGpuInfo(const content::GPUInfo& gpu_info) { | 145 void SetGpuInfo(const content::GPUInfo& gpu_info) { |
| 139 static MainSetGpuInfo set_gpu_info = NULL; | 146 static MainSetGpuInfo set_gpu_info = NULL; |
| 147 // note: benign race condition on set_gpu_info. |
| 140 if (!set_gpu_info) { | 148 if (!set_gpu_info) { |
| 141 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 149 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 142 if (!exe_module) | 150 if (!exe_module) |
| 143 return; | 151 return; |
| 144 set_gpu_info = reinterpret_cast<MainSetGpuInfo>( | 152 set_gpu_info = reinterpret_cast<MainSetGpuInfo>( |
| 145 GetProcAddress(exe_module, "SetGpuInfo")); | 153 GetProcAddress(exe_module, "SetGpuInfo")); |
| 146 if (!set_gpu_info) | 154 if (!set_gpu_info) |
| 147 return; | 155 return; |
| 148 } | 156 } |
| 149 (set_gpu_info)( | 157 (set_gpu_info)( |
| 150 base::StringPrintf(L"0x%04x", gpu_info.vendor_id).c_str(), | 158 base::StringPrintf(L"0x%04x", gpu_info.vendor_id).c_str(), |
| 151 base::StringPrintf(L"0x%04x", gpu_info.device_id).c_str(), | 159 base::StringPrintf(L"0x%04x", gpu_info.device_id).c_str(), |
| 152 UTF8ToUTF16(gpu_info.driver_version).c_str(), | 160 UTF8ToUTF16(gpu_info.driver_version).c_str(), |
| 153 UTF8ToUTF16(gpu_info.pixel_shader_version).c_str(), | 161 UTF8ToUTF16(gpu_info.pixel_shader_version).c_str(), |
| 154 UTF8ToUTF16(gpu_info.vertex_shader_version).c_str()); | 162 UTF8ToUTF16(gpu_info.vertex_shader_version).c_str()); |
| 155 } | 163 } |
| 156 | 164 |
| 157 void SetPrinterInfo(const char* printer_info) { | 165 void SetPrinterInfo(const char* printer_info) { |
| 158 static MainSetPrinterInfo set_printer_info = NULL; | 166 static MainSetPrinterInfo set_printer_info = NULL; |
| 167 // note: benign race condition on set_printer_info. |
| 159 if (!set_printer_info) { | 168 if (!set_printer_info) { |
| 160 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 169 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 161 if (!exe_module) | 170 if (!exe_module) |
| 162 return; | 171 return; |
| 163 set_printer_info = reinterpret_cast<MainSetPrinterInfo>( | 172 set_printer_info = reinterpret_cast<MainSetPrinterInfo>( |
| 164 GetProcAddress(exe_module, "SetPrinterInfo")); | 173 GetProcAddress(exe_module, "SetPrinterInfo")); |
| 165 if (!set_printer_info) | 174 if (!set_printer_info) |
| 166 return; | 175 return; |
| 167 } | 176 } |
| 168 (set_printer_info)(UTF8ToWide(printer_info).c_str()); | 177 (set_printer_info)(UTF8ToWide(printer_info).c_str()); |
| 169 } | 178 } |
| 170 | 179 |
| 171 void SetCommandLine(const CommandLine* command_line) { | 180 void SetCommandLine(const CommandLine* command_line) { |
| 172 static MainSetCommandLine set_command_line = NULL; | 181 static MainSetCommandLine set_command_line = NULL; |
| 182 // note: benign race condition on set_command_line. |
| 173 if (!set_command_line) { | 183 if (!set_command_line) { |
| 174 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 184 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 175 if (!exe_module) | 185 if (!exe_module) |
| 176 return; | 186 return; |
| 177 set_command_line = reinterpret_cast<MainSetCommandLine>( | 187 set_command_line = reinterpret_cast<MainSetCommandLine>( |
| 178 GetProcAddress(exe_module, "SetCommandLine")); | 188 GetProcAddress(exe_module, "SetCommandLine")); |
| 179 if (!set_command_line) | 189 if (!set_command_line) |
| 180 return; | 190 return; |
| 181 } | 191 } |
| 182 (set_command_line)(command_line); | 192 (set_command_line)(command_line); |
| 183 } | 193 } |
| 184 | 194 |
| 195 void SetExperimentList(const std::vector<string16>& state) { |
| 196 static MainSetExperimentList set_experiment_list = NULL; |
| 197 // note: benign race condition on set_experiment_list. |
| 198 if (!set_experiment_list) { |
| 199 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 200 if (!exe_module) |
| 201 return; |
| 202 set_experiment_list = reinterpret_cast<MainSetExperimentList>( |
| 203 GetProcAddress(exe_module, "SetExperimentList")); |
| 204 if (!set_experiment_list) |
| 205 return; |
| 206 } |
| 207 (set_experiment_list)(state); |
| 208 } |
| 209 |
| 185 void SetNumberOfViews(int number_of_views) { | 210 void SetNumberOfViews(int number_of_views) { |
| 186 static MainSetNumberOfViews set_number_of_views = NULL; | 211 static MainSetNumberOfViews set_number_of_views = NULL; |
| 212 // note: benign race condition on set_number_of_views. |
| 187 if (!set_number_of_views) { | 213 if (!set_number_of_views) { |
| 188 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 214 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 189 if (!exe_module) | 215 if (!exe_module) |
| 190 return; | 216 return; |
| 191 set_number_of_views = reinterpret_cast<MainSetNumberOfViews>( | 217 set_number_of_views = reinterpret_cast<MainSetNumberOfViews>( |
| 192 GetProcAddress(exe_module, "SetNumberOfViews")); | 218 GetProcAddress(exe_module, "SetNumberOfViews")); |
| 193 if (!set_number_of_views) | 219 if (!set_number_of_views) |
| 194 return; | 220 return; |
| 195 } | 221 } |
| 196 (set_number_of_views)(number_of_views); | 222 (set_number_of_views)(number_of_views); |
| 197 } | 223 } |
| 198 | 224 |
| 199 } // namespace child_process_logging | 225 } // namespace child_process_logging |
| OLD | NEW |