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/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/common/chrome_constants.h" | 13 #include "chrome/common/chrome_constants.h" |
14 #include "chrome/common/crash_keys.h" | 14 #include "chrome/common/crash_keys.h" |
15 #include "chrome/common/metrics/variations/variations_util.h" | 15 #include "chrome/common/metrics/variations/variations_util.h" |
16 #include "chrome/installer/util/google_update_settings.h" | 16 #include "chrome/installer/util/google_update_settings.h" |
17 | 17 |
18 namespace child_process_logging { | 18 namespace child_process_logging { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // exported in breakpad_win.cc: void __declspec(dllexport) __cdecl SetClientId. | 22 // exported in breakpad_win.cc: void __declspec(dllexport) __cdecl SetClientId. |
23 typedef void (__cdecl *MainSetClientId)(const wchar_t*); | 23 typedef void (__cdecl *MainSetClientId)(const wchar_t*); |
24 | 24 |
25 // exported in breakpad_win.cc: | 25 // exported in breakpad_win.cc: |
| 26 // void __declspec(dllexport) __cdecl SetPrinterInfo. |
| 27 typedef void (__cdecl *MainSetPrinterInfo)(const wchar_t*); |
| 28 |
| 29 // exported in breakpad_win.cc: |
26 // void __declspec(dllexport) __cdecl SetCommandLine2 | 30 // void __declspec(dllexport) __cdecl SetCommandLine2 |
27 typedef void (__cdecl *MainSetCommandLine)(const wchar_t**, size_t); | 31 typedef void (__cdecl *MainSetCommandLine)(const wchar_t**, size_t); |
28 | 32 |
29 // exported in breakpad_field_trial_win.cc: | 33 // exported in breakpad_field_trial_win.cc: |
30 // void __declspec(dllexport) __cdecl SetExperimentList3 | 34 // void __declspec(dllexport) __cdecl SetExperimentList3 |
31 typedef void (__cdecl *MainSetExperimentList)(const wchar_t**, size_t, size_t); | 35 typedef void (__cdecl *MainSetExperimentList)(const wchar_t**, size_t, size_t); |
32 | 36 |
33 // exported in breakpad_win.cc: | 37 // exported in breakpad_win.cc: |
34 // void __declspec(dllexport) __cdecl SetCrashKeyValueImpl. | 38 // void __declspec(dllexport) __cdecl SetCrashKeyValueImpl. |
35 typedef void (__cdecl *SetCrashKeyValue)(const wchar_t*, const wchar_t*); | 39 typedef void (__cdecl *SetCrashKeyValue)(const wchar_t*, const wchar_t*); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 83 } |
80 | 84 |
81 std::string GetClientId() { | 85 std::string GetClientId() { |
82 std::wstring wstr_client_id; | 86 std::wstring wstr_client_id; |
83 if (GoogleUpdateSettings::GetMetricsId(&wstr_client_id)) | 87 if (GoogleUpdateSettings::GetMetricsId(&wstr_client_id)) |
84 return WideToASCII(wstr_client_id); | 88 return WideToASCII(wstr_client_id); |
85 else | 89 else |
86 return std::string(); | 90 return std::string(); |
87 } | 91 } |
88 | 92 |
| 93 void SetPrinterInfo(const char* printer_info) { |
| 94 static MainSetPrinterInfo set_printer_info = NULL; |
| 95 // note: benign race condition on set_printer_info. |
| 96 if (!set_printer_info) { |
| 97 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 98 if (!exe_module) |
| 99 return; |
| 100 set_printer_info = reinterpret_cast<MainSetPrinterInfo>( |
| 101 GetProcAddress(exe_module, "SetPrinterInfo")); |
| 102 if (!set_printer_info) |
| 103 return; |
| 104 } |
| 105 (set_printer_info)(UTF8ToWide(printer_info).c_str()); |
| 106 } |
| 107 |
89 void SetCommandLine(const CommandLine* command_line) { | 108 void SetCommandLine(const CommandLine* command_line) { |
90 static MainSetCommandLine set_command_line = NULL; | 109 static MainSetCommandLine set_command_line = NULL; |
91 // note: benign race condition on set_command_line. | 110 // note: benign race condition on set_command_line. |
92 if (!set_command_line) { | 111 if (!set_command_line) { |
93 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 112 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
94 if (!exe_module) | 113 if (!exe_module) |
95 return; | 114 return; |
96 set_command_line = reinterpret_cast<MainSetCommandLine>( | 115 set_command_line = reinterpret_cast<MainSetCommandLine>( |
97 GetProcAddress(exe_module, "SetCommandLine2")); | 116 GetProcAddress(exe_module, "SetCommandLine2")); |
98 if (!set_command_line) | 117 if (!set_command_line) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 void Init() { | 190 void Init() { |
172 // Note: on other platforms, this is set up during Breakpad initialization, | 191 // Note: on other platforms, this is set up during Breakpad initialization, |
173 // in ChromeBreakpadClient. But on Windows, that is before the DLL module is | 192 // in ChromeBreakpadClient. But on Windows, that is before the DLL module is |
174 // loaded, which is a prerequisite of the crash key system. | 193 // loaded, which is a prerequisite of the crash key system. |
175 crash_keys::RegisterChromeCrashKeys(); | 194 crash_keys::RegisterChromeCrashKeys(); |
176 base::debug::SetCrashKeyReportingFunctions( | 195 base::debug::SetCrashKeyReportingFunctions( |
177 &SetCrashKeyValueTrampoline, &ClearCrashKeyValueTrampoline); | 196 &SetCrashKeyValueTrampoline, &ClearCrashKeyValueTrampoline); |
178 } | 197 } |
179 | 198 |
180 } // namespace child_process_logging | 199 } // namespace child_process_logging |
OLD | NEW |