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" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
15 #include "chrome/installer/util/google_update_settings.h" | 15 #include "chrome/installer/util/google_update_settings.h" |
16 #include "content/public/common/gpu_info.h" | 16 #include "content/public/common/gpu_info.h" |
17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
18 | 18 |
19 namespace child_process_logging { | 19 namespace child_process_logging { |
| 20 |
| 21 namespace { |
| 22 |
20 // exported in breakpad_win.cc: void __declspec(dllexport) __cdecl SetActiveURL. | 23 // exported in breakpad_win.cc: void __declspec(dllexport) __cdecl SetActiveURL. |
21 typedef void (__cdecl *MainSetActiveURL)(const wchar_t*); | 24 typedef void (__cdecl *MainSetActiveURL)(const wchar_t*); |
22 | 25 |
23 // exported in breakpad_win.cc: void __declspec(dllexport) __cdecl SetClientId. | 26 // exported in breakpad_win.cc: void __declspec(dllexport) __cdecl SetClientId. |
24 typedef void (__cdecl *MainSetClientId)(const wchar_t*); | 27 typedef void (__cdecl *MainSetClientId)(const wchar_t*); |
25 | 28 |
26 // exported in breakpad_win.cc: | 29 // exported in breakpad_win.cc: |
27 // void __declspec(dllexport) __cdecl SetNumberOfExtensions. | 30 // void __declspec(dllexport) __cdecl SetNumberOfExtensions. |
28 typedef void (__cdecl *MainSetNumberOfExtensions)(int); | 31 typedef void (__cdecl *MainSetNumberOfExtensions)(int); |
29 | 32 |
30 // exported in breakpad_win.cc: | 33 // exported in breakpad_win.cc: |
31 // void __declspec(dllexport) __cdecl SetExtensionID. | 34 // void __declspec(dllexport) __cdecl SetExtensionID. |
32 typedef void (__cdecl *MainSetExtensionID)(size_t, const wchar_t*); | 35 typedef void (__cdecl *MainSetExtensionID)(size_t, const wchar_t*); |
33 | 36 |
34 // exported in breakpad_win.cc: void __declspec(dllexport) __cdecl SetGpuInfo. | 37 // exported in breakpad_win.cc: void __declspec(dllexport) __cdecl SetGpuInfo. |
35 typedef void (__cdecl *MainSetGpuInfo)(const wchar_t*, const wchar_t*, | 38 typedef void (__cdecl *MainSetGpuInfo)(const wchar_t*, const wchar_t*, |
36 const wchar_t*, const wchar_t*, | 39 const wchar_t*, const wchar_t*, |
37 const wchar_t*); | 40 const wchar_t*); |
38 | 41 |
39 // exported in breakpad_win.cc: | 42 // exported in breakpad_win.cc: |
40 // void __declspec(dllexport) __cdecl SetPrinterInfo. | 43 // void __declspec(dllexport) __cdecl SetPrinterInfo. |
41 typedef void (__cdecl *MainSetPrinterInfo)(const wchar_t*); | 44 typedef void (__cdecl *MainSetPrinterInfo)(const wchar_t*); |
42 | 45 |
43 // exported in breakpad_win.cc: | 46 // exported in breakpad_win.cc: |
44 // void __declspec(dllexport) __cdecl SetNumberOfViews. | 47 // void __declspec(dllexport) __cdecl SetNumberOfViews. |
45 typedef void (__cdecl *MainSetNumberOfViews)(int); | 48 typedef void (__cdecl *MainSetNumberOfViews)(int); |
46 | 49 |
47 // exported in breakpad_win.cc: | 50 // exported in breakpad_win.cc: |
48 // void __declspec(dllexport) __cdecl SetCommandLine | 51 // void __declspec(dllexport) __cdecl SetCommandLine |
49 typedef void (__cdecl *MainSetCommandLine)(const CommandLine*); | 52 typedef void (__cdecl *MainSetCommandLine)(const wchar_t**, size_t); |
50 | 53 |
51 // exported in breakpad_field_trial_win.cc: | 54 // exported in breakpad_field_trial_win.cc: |
52 // void __declspec(dllexport) __cdecl SetExperimentList | 55 // void __declspec(dllexport) __cdecl SetExperimentList |
53 typedef void (__cdecl *MainSetExperimentList)(const std::vector<string16>&); | 56 typedef void (__cdecl *MainSetExperimentList)(const wchar_t**, size_t); |
| 57 |
| 58 // Copied from breakpad_win.cc. |
| 59 void StringVectorToCStringVector(const std::vector<std::wstring>& wstrings, |
| 60 std::vector<const wchar_t*>* cstrings) { |
| 61 cstrings->clear(); |
| 62 cstrings->reserve(wstrings.size()); |
| 63 for (size_t i = 0; i < wstrings.size(); ++i) |
| 64 cstrings->push_back(wstrings[i].c_str()); |
| 65 } |
| 66 |
| 67 } // namespace |
54 | 68 |
55 void SetActiveURL(const GURL& url) { | 69 void SetActiveURL(const GURL& url) { |
56 static MainSetActiveURL set_active_url = NULL; | 70 static MainSetActiveURL set_active_url = NULL; |
57 // note: benign race condition on set_active_url. | 71 // note: benign race condition on set_active_url. |
58 if (!set_active_url) { | 72 if (!set_active_url) { |
59 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 73 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
60 if (!exe_module) | 74 if (!exe_module) |
61 return; | 75 return; |
62 set_active_url = reinterpret_cast<MainSetActiveURL>( | 76 set_active_url = reinterpret_cast<MainSetActiveURL>( |
63 GetProcAddress(exe_module, "SetActiveURL")); | 77 GetProcAddress(exe_module, "SetActiveURL")); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // note: benign race condition on set_command_line. | 196 // note: benign race condition on set_command_line. |
183 if (!set_command_line) { | 197 if (!set_command_line) { |
184 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 198 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
185 if (!exe_module) | 199 if (!exe_module) |
186 return; | 200 return; |
187 set_command_line = reinterpret_cast<MainSetCommandLine>( | 201 set_command_line = reinterpret_cast<MainSetCommandLine>( |
188 GetProcAddress(exe_module, "SetCommandLine")); | 202 GetProcAddress(exe_module, "SetCommandLine")); |
189 if (!set_command_line) | 203 if (!set_command_line) |
190 return; | 204 return; |
191 } | 205 } |
192 (set_command_line)(command_line); | 206 |
| 207 std::vector<const wchar_t*> cstrings; |
| 208 StringVectorToCStringVector(command_line->argv(), &cstrings); |
| 209 (set_command_line)(&cstrings[0], cstrings.size()); |
193 } | 210 } |
194 | 211 |
195 void SetExperimentList(const std::vector<string16>& state) { | 212 void SetExperimentList(const std::vector<string16>& state) { |
196 static MainSetExperimentList set_experiment_list = NULL; | 213 static MainSetExperimentList set_experiment_list = NULL; |
197 // note: benign race condition on set_experiment_list. | 214 // note: benign race condition on set_experiment_list. |
198 if (!set_experiment_list) { | 215 if (!set_experiment_list) { |
199 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 216 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
200 if (!exe_module) | 217 if (!exe_module) |
201 return; | 218 return; |
202 set_experiment_list = reinterpret_cast<MainSetExperimentList>( | 219 set_experiment_list = reinterpret_cast<MainSetExperimentList>( |
203 GetProcAddress(exe_module, "SetExperimentList")); | 220 GetProcAddress(exe_module, "SetExperimentList")); |
204 if (!set_experiment_list) | 221 if (!set_experiment_list) |
205 return; | 222 return; |
206 } | 223 } |
207 (set_experiment_list)(state); | 224 |
| 225 std::vector<const wchar_t*> cstrings; |
| 226 StringVectorToCStringVector(state, &cstrings); |
| 227 (set_experiment_list)(&cstrings[0], cstrings.size()); |
208 } | 228 } |
209 | 229 |
210 void SetNumberOfViews(int number_of_views) { | 230 void SetNumberOfViews(int number_of_views) { |
211 static MainSetNumberOfViews set_number_of_views = NULL; | 231 static MainSetNumberOfViews set_number_of_views = NULL; |
212 // note: benign race condition on set_number_of_views. | 232 // note: benign race condition on set_number_of_views. |
213 if (!set_number_of_views) { | 233 if (!set_number_of_views) { |
214 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 234 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
215 if (!exe_module) | 235 if (!exe_module) |
216 return; | 236 return; |
217 set_number_of_views = reinterpret_cast<MainSetNumberOfViews>( | 237 set_number_of_views = reinterpret_cast<MainSetNumberOfViews>( |
218 GetProcAddress(exe_module, "SetNumberOfViews")); | 238 GetProcAddress(exe_module, "SetNumberOfViews")); |
219 if (!set_number_of_views) | 239 if (!set_number_of_views) |
220 return; | 240 return; |
221 } | 241 } |
222 (set_number_of_views)(number_of_views); | 242 (set_number_of_views)(number_of_views); |
223 } | 243 } |
224 | 244 |
225 } // namespace child_process_logging | 245 } // namespace child_process_logging |
OLD | NEW |