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

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

Issue 23471007: Set active extension IDs for crash reports using the crash key logging system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments 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 SetNumberOfExtensions.
27 typedef void (__cdecl *MainSetNumberOfExtensions)(int);
28
29 // exported in breakpad_win.cc:
30 // void __declspec(dllexport) __cdecl SetExtensionID.
31 typedef void (__cdecl *MainSetExtensionID)(size_t, const wchar_t*);
32
33 // exported in breakpad_win.cc:
34 // void __declspec(dllexport) __cdecl SetPrinterInfo. 26 // void __declspec(dllexport) __cdecl SetPrinterInfo.
35 typedef void (__cdecl *MainSetPrinterInfo)(const wchar_t*); 27 typedef void (__cdecl *MainSetPrinterInfo)(const wchar_t*);
36 28
37 // exported in breakpad_win.cc: 29 // exported in breakpad_win.cc:
38 // void __declspec(dllexport) __cdecl SetNumberOfViews. 30 // void __declspec(dllexport) __cdecl SetNumberOfViews.
39 typedef void (__cdecl *MainSetNumberOfViews)(int); 31 typedef void (__cdecl *MainSetNumberOfViews)(int);
40 32
41 // exported in breakpad_win.cc: 33 // exported in breakpad_win.cc:
42 // void __declspec(dllexport) __cdecl SetCommandLine2 34 // void __declspec(dllexport) __cdecl SetCommandLine2
43 typedef void (__cdecl *MainSetCommandLine)(const wchar_t**, size_t); 35 typedef void (__cdecl *MainSetCommandLine)(const wchar_t**, size_t);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 87 }
96 88
97 std::string GetClientId() { 89 std::string GetClientId() {
98 std::wstring wstr_client_id; 90 std::wstring wstr_client_id;
99 if (GoogleUpdateSettings::GetMetricsId(&wstr_client_id)) 91 if (GoogleUpdateSettings::GetMetricsId(&wstr_client_id))
100 return WideToASCII(wstr_client_id); 92 return WideToASCII(wstr_client_id);
101 else 93 else
102 return std::string(); 94 return std::string();
103 } 95 }
104 96
105 void SetActiveExtensions(const std::set<std::string>& extension_ids) {
106 static MainSetNumberOfExtensions set_number_of_extensions = NULL;
107 // note: benign race condition on set_number_of_extensions.
108 if (!set_number_of_extensions) {
109 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName);
110 if (!exe_module)
111 return;
112 set_number_of_extensions = reinterpret_cast<MainSetNumberOfExtensions>(
113 GetProcAddress(exe_module, "SetNumberOfExtensions"));
114 if (!set_number_of_extensions)
115 return;
116 }
117
118 static MainSetExtensionID set_extension_id = NULL;
119 // note: benign race condition on set_extension_id.
120 if (!set_extension_id) {
121 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName);
122 if (!exe_module)
123 return;
124 set_extension_id = reinterpret_cast<MainSetExtensionID>(
125 GetProcAddress(exe_module, "SetExtensionID"));
126 if (!set_extension_id)
127 return;
128 }
129
130 (set_number_of_extensions)(static_cast<int>(extension_ids.size()));
131
132 std::set<std::string>::const_iterator iter = extension_ids.begin();
133 for (size_t i = 0; i < kMaxReportedActiveExtensions; ++i) {
134 if (iter != extension_ids.end()) {
135 (set_extension_id)(i, ASCIIToWide(iter->c_str()).c_str());
136 ++iter;
137 } else {
138 (set_extension_id)(i, L"");
139 }
140 }
141 }
142
143 void SetPrinterInfo(const char* printer_info) { 97 void SetPrinterInfo(const char* printer_info) {
144 static MainSetPrinterInfo set_printer_info = NULL; 98 static MainSetPrinterInfo set_printer_info = NULL;
145 // note: benign race condition on set_printer_info. 99 // note: benign race condition on set_printer_info.
146 if (!set_printer_info) { 100 if (!set_printer_info) {
147 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); 101 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName);
148 if (!exe_module) 102 if (!exe_module)
149 return; 103 return;
150 set_printer_info = reinterpret_cast<MainSetPrinterInfo>( 104 set_printer_info = reinterpret_cast<MainSetPrinterInfo>(
151 GetProcAddress(exe_module, "SetPrinterInfo")); 105 GetProcAddress(exe_module, "SetPrinterInfo"));
152 if (!set_printer_info) 106 if (!set_printer_info)
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 void Init() { 209 void Init() {
256 // Note: on other platforms, this is set up during Breakpad initialization, 210 // Note: on other platforms, this is set up during Breakpad initialization,
257 // in ChromeBreakpadClient. But on Windows, that is before the DLL module is 211 // in ChromeBreakpadClient. But on Windows, that is before the DLL module is
258 // loaded, which is a prerequisite of the crash key system. 212 // loaded, which is a prerequisite of the crash key system.
259 crash_keys::RegisterChromeCrashKeys(); 213 crash_keys::RegisterChromeCrashKeys();
260 base::debug::SetCrashKeyReportingFunctions( 214 base::debug::SetCrashKeyReportingFunctions(
261 &SetCrashKeyValueTrampoline, &ClearCrashKeyValueTrampoline); 215 &SetCrashKeyValueTrampoline, &ClearCrashKeyValueTrampoline);
262 } 216 }
263 217
264 } // namespace child_process_logging 218 } // 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