Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(602)

Side by Side Diff: chrome/common/child_process_logging_win.cc

Issue 23604061: Set the printer info in crash reports using the crash key logging system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory issue Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/child_process_logging_posix.cc ('k') | chrome/common/crash_keys.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:
30 // void __declspec(dllexport) __cdecl SetCommandLine2 26 // void __declspec(dllexport) __cdecl SetCommandLine2
31 typedef void (__cdecl *MainSetCommandLine)(const wchar_t**, size_t); 27 typedef void (__cdecl *MainSetCommandLine)(const wchar_t**, size_t);
32 28
33 // exported in breakpad_field_trial_win.cc: 29 // exported in breakpad_field_trial_win.cc:
34 // void __declspec(dllexport) __cdecl SetExperimentList3 30 // void __declspec(dllexport) __cdecl SetExperimentList3
35 typedef void (__cdecl *MainSetExperimentList)(const wchar_t**, size_t, size_t); 31 typedef void (__cdecl *MainSetExperimentList)(const wchar_t**, size_t, size_t);
36 32
37 // exported in breakpad_win.cc: 33 // exported in breakpad_win.cc:
38 // void __declspec(dllexport) __cdecl SetCrashKeyValueImpl. 34 // void __declspec(dllexport) __cdecl SetCrashKeyValueImpl.
39 typedef void (__cdecl *SetCrashKeyValue)(const wchar_t*, const wchar_t*); 35 typedef void (__cdecl *SetCrashKeyValue)(const wchar_t*, const wchar_t*);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 79 }
84 80
85 std::string GetClientId() { 81 std::string GetClientId() {
86 std::wstring wstr_client_id; 82 std::wstring wstr_client_id;
87 if (GoogleUpdateSettings::GetMetricsId(&wstr_client_id)) 83 if (GoogleUpdateSettings::GetMetricsId(&wstr_client_id))
88 return WideToASCII(wstr_client_id); 84 return WideToASCII(wstr_client_id);
89 else 85 else
90 return std::string(); 86 return std::string();
91 } 87 }
92 88
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
108 void SetCommandLine(const CommandLine* command_line) { 89 void SetCommandLine(const CommandLine* command_line) {
109 static MainSetCommandLine set_command_line = NULL; 90 static MainSetCommandLine set_command_line = NULL;
110 // note: benign race condition on set_command_line. 91 // note: benign race condition on set_command_line.
111 if (!set_command_line) { 92 if (!set_command_line) {
112 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); 93 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName);
113 if (!exe_module) 94 if (!exe_module)
114 return; 95 return;
115 set_command_line = reinterpret_cast<MainSetCommandLine>( 96 set_command_line = reinterpret_cast<MainSetCommandLine>(
116 GetProcAddress(exe_module, "SetCommandLine2")); 97 GetProcAddress(exe_module, "SetCommandLine2"));
117 if (!set_command_line) 98 if (!set_command_line)
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 void Init() { 171 void Init() {
191 // Note: on other platforms, this is set up during Breakpad initialization, 172 // Note: on other platforms, this is set up during Breakpad initialization,
192 // in ChromeBreakpadClient. But on Windows, that is before the DLL module is 173 // in ChromeBreakpadClient. But on Windows, that is before the DLL module is
193 // loaded, which is a prerequisite of the crash key system. 174 // loaded, which is a prerequisite of the crash key system.
194 crash_keys::RegisterChromeCrashKeys(); 175 crash_keys::RegisterChromeCrashKeys();
195 base::debug::SetCrashKeyReportingFunctions( 176 base::debug::SetCrashKeyReportingFunctions(
196 &SetCrashKeyValueTrampoline, &ClearCrashKeyValueTrampoline); 177 &SetCrashKeyValueTrampoline, &ClearCrashKeyValueTrampoline);
197 } 178 }
198 179
199 } // namespace child_process_logging 180 } // namespace child_process_logging
OLDNEW
« no previous file with comments | « chrome/common/child_process_logging_posix.cc ('k') | chrome/common/crash_keys.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698