summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-15 08:53:24 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-15 08:53:24 +0000
commit19a12a1f568c2b16a0d2ebdd52c7d286858acdce (patch)
treecd8e05d9d71e9a3c3c11575724ca872e5301d975 /chrome
parentebb7c1fd09da624d9cd44570ff8086e5051b1811 (diff)
downloadchromium_src-19a12a1f568c2b16a0d2ebdd52c7d286858acdce.zip
chromium_src-19a12a1f568c2b16a0d2ebdd52c7d286858acdce.tar.gz
chromium_src-19a12a1f568c2b16a0d2ebdd52c7d286858acdce.tar.bz2
Added SetPrinterInfo to include information about printer driver. This information will be added by Chrome (in different CL) just before performing error-prone printer related operations.
BUG=108194 TEST=none Review URL: http://codereview.chromium.org/9600060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126866 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/breakpad_linux.cc13
-rw-r--r--chrome/app/breakpad_win.cc76
-rw-r--r--chrome/common/child_process_logging.h27
-rw-r--r--chrome/common/child_process_logging_mac.mm15
-rw-r--r--chrome/common/child_process_logging_posix.cc20
-rw-r--r--chrome/common/child_process_logging_win.cc20
6 files changed, 143 insertions, 28 deletions
diff --git a/chrome/app/breakpad_linux.cc b/chrome/app/breakpad_linux.cc
index 4ab5f48..eff3a12 100644
--- a/chrome/app/breakpad_linux.cc
+++ b/chrome/app/breakpad_linux.cc
@@ -574,6 +574,19 @@ void HandleCrashDump(const BreakpadInfo& info) {
false /* Don't strip whitespace. */);
}
+ unsigned printer_info_len =
+ my_strlen(child_process_logging::g_printer_info);
+ if (printer_info_len) {
+ static const char printer_info_msg[] = "prn-info-";
+ static const unsigned kMaxPrnInfoLen =
+ kMaxReportedPrinterRecords * child_process_logging::kPrinterInfoStrLen;
+ writer.AddPairDataInChunks(printer_info_msg, sizeof(printer_info_msg) - 1,
+ child_process_logging::g_printer_info,
+ std::min(printer_info_len, kMaxPrnInfoLen),
+ child_process_logging::kPrinterInfoStrLen,
+ true);
+ }
+
if (my_strlen(child_process_logging::g_num_switches)) {
writer.AddPairString("num-switches",
child_process_logging::g_num_switches);
diff --git a/chrome/app/breakpad_win.cc b/chrome/app/breakpad_win.cc
index 9bd8e1e..6c0cdf7 100644
--- a/chrome/app/breakpad_win.cc
+++ b/chrome/app/breakpad_win.cc
@@ -74,6 +74,7 @@ static size_t g_num_of_extensions_offset;
static size_t g_extension_ids_offset;
static size_t g_client_id_offset;
static size_t g_gpu_info_offset;
+static size_t g_printer_info_offset;
static size_t g_num_of_views_offset;
static size_t g_num_switches_offset;
static size_t g_switches_offset;
@@ -257,19 +258,29 @@ google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& exe_path,
base::StringPrintf(L"extension-%i", i + 1).c_str(), L""));
}
- // Add empty values for the gpu_info. We'll put the actual values
- // when we collect them at this location.
+ // Add empty values for the gpu_info. We'll put the actual values when we
+ // collect them at this location.
g_gpu_info_offset = g_custom_entries->size();
- g_custom_entries->push_back(
- google_breakpad::CustomInfoEntry(L"gpu-venid", L""));
- g_custom_entries->push_back(
- google_breakpad::CustomInfoEntry(L"gpu-devid", L""));
- g_custom_entries->push_back(
- google_breakpad::CustomInfoEntry(L"gpu-driver", L""));
- g_custom_entries->push_back(
- google_breakpad::CustomInfoEntry(L"gpu-psver", L""));
- g_custom_entries->push_back(
- google_breakpad::CustomInfoEntry(L"gpu-vsver", L""));
+ static const wchar_t* const kGpuEntries[] = {
+ L"gpu-venid",
+ L"gpu-devid",
+ L"gpu-driver",
+ L"gpu-psver",
+ L"gpu-vsver",
+ };
+ for (size_t i = 0; i < arraysize(kGpuEntries); ++i) {
+ g_custom_entries->push_back(
+ google_breakpad::CustomInfoEntry(kGpuEntries[i], L""));
+ }
+
+ // Add empty values for the prn_info-*. We'll put the actual values when we
+ // collect them at this location.
+ g_printer_info_offset = g_custom_entries->size();
+ for (size_t i = 0; i < kMaxReportedPrinterRecords; ++i) {
+ g_custom_entries->push_back(
+ google_breakpad::CustomInfoEntry(
+ base::StringPrintf(L"prn-info-%d", i + 1).c_str(), L""));
+ }
// Read the id from registry. If reporting has never been enabled
// the result will be empty string. Its OK since when user enables reporting
@@ -487,21 +498,34 @@ extern "C" void __declspec(dllexport) __cdecl SetGpuInfo(
if (!g_custom_entries)
return;
- base::wcslcpy((*g_custom_entries)[g_gpu_info_offset].value,
- vendor_id,
- google_breakpad::CustomInfoEntry::kValueMaxLength);
- base::wcslcpy((*g_custom_entries)[g_gpu_info_offset+1].value,
- device_id,
- google_breakpad::CustomInfoEntry::kValueMaxLength);
- base::wcslcpy((*g_custom_entries)[g_gpu_info_offset+2].value,
- driver_version,
- google_breakpad::CustomInfoEntry::kValueMaxLength);
- base::wcslcpy((*g_custom_entries)[g_gpu_info_offset+3].value,
- pixel_shader_version,
- google_breakpad::CustomInfoEntry::kValueMaxLength);
- base::wcslcpy((*g_custom_entries)[g_gpu_info_offset+4].value,
- vertex_shader_version,
+ const wchar_t* info[] = {
+ vendor_id,
+ device_id,
+ driver_version,
+ pixel_shader_version,
+ vertex_shader_version
+ };
+
+ for (size_t i = 0; i < arraysize(info); ++i) {
+ base::wcslcpy((*g_custom_entries)[g_gpu_info_offset + i].value,
+ info[i],
+ google_breakpad::CustomInfoEntry::kValueMaxLength);
+ }
+}
+
+extern "C" void __declspec(dllexport) __cdecl SetPrinterInfo(
+ const wchar_t* printer_info) {
+ if (!g_custom_entries)
+ return;
+ std::vector<string16> info;
+ base::SplitString(printer_info, L';', &info);
+ DCHECK_LE(info.size(), kMaxReportedPrinterRecords);
+ info.resize(kMaxReportedPrinterRecords);
+ for (size_t i = 0; i < info.size(); ++i) {
+ base::wcslcpy((*g_custom_entries)[g_printer_info_offset + i].value,
+ info[i].c_str(),
google_breakpad::CustomInfoEntry::kValueMaxLength);
+ }
}
extern "C" void __declspec(dllexport) __cdecl SetNumberOfViews(
diff --git a/chrome/common/child_process_logging.h b/chrome/common/child_process_logging.h
index 6b68d8c..15a5b92 100644
--- a/chrome/common/child_process_logging.h
+++ b/chrome/common/child_process_logging.h
@@ -24,6 +24,9 @@ struct GPUInfo;
// dependency.
static const int kMaxReportedActiveExtensions = 10;
+// The maximum number of prn-info-* records.
+static const size_t kMaxReportedPrinterRecords = 4;
+
// The maximum number of command line switches to include in the crash
// report's metadata. Note that the mini-dump itself will also contain the
// (original) command line arguments within the PEB.
@@ -48,6 +51,7 @@ extern char g_gpu_vs_ver[];
extern char g_num_extensions[];
extern char g_num_switches[];
extern char g_num_views[];
+extern char g_prn_info[];
extern char g_switches[];
// Assume IDs are 32 bytes long.
@@ -55,6 +59,9 @@ static const size_t kExtensionLen = 32;
// Assume command line switches are less than 64 chars.
static const size_t kSwitchLen = 64;
+
+// Assume printer info strings are less than 64 chars.
+static const size_t kPrinterInfoStrLen = 64;
#endif
// Sets the URL that is logged if the child process crashes. Use GURL() to clear
@@ -82,6 +89,11 @@ void SetNumberOfViews(int number_of_views);
// Sets the data on the gpu to send along with crash reports.
void SetGpuInfo(const content::GPUInfo& gpu_info);
+// Sets the data on the printer to send along with crash reports. Data may be
+// separated by ';' up to kMaxReportedPrinterRecords strings. Each substring
+// would be cut to 63 chars.
+void SetPrinterInfo(const char* printer_info);
+
// Sets the command line arguments to send along with crash reports to the
// values in |command_line|.
void SetCommandLine(const CommandLine* command_line);
@@ -107,6 +119,21 @@ class ScopedActiveURLSetter {
DISALLOW_COPY_AND_ASSIGN(ScopedActiveURLSetter);
};
+// Set/clear information about currently accessed printer.
+class ScopedPrinterInfoSetter {
+ public:
+ explicit ScopedPrinterInfoSetter(const char* printer_info) {
+ SetPrinterInfo(printer_info);
+ }
+
+ ~ScopedPrinterInfoSetter() {
+ SetPrinterInfo("");
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScopedPrinterInfoSetter);
+};
+
} // namespace child_process_logging
#if defined(OS_MACOSX)
diff --git a/chrome/common/child_process_logging_mac.mm b/chrome/common/child_process_logging_mac.mm
index 0541977..b8c57e1 100644
--- a/chrome/common/child_process_logging_mac.mm
+++ b/chrome/common/child_process_logging_mac.mm
@@ -8,6 +8,7 @@
#include "base/command_line.h"
#include "base/string_number_conversions.h"
+#include "base/string_split.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/sys_string_conversions.h"
@@ -36,6 +37,7 @@ const char *kGPUGLVersionParamName = "gpu-glver";
const char *kNumberOfViews = "num-views";
NSString* const kNumExtensionsName = @"num-extensions";
NSString* const kExtensionNameFormat = @"extension-%d";
+NSString* const kPrinterInfoNameFormat = @"prn-info-%d";
// Account for the terminating null character.
static const size_t kClientIdSize = 32 + 1;
@@ -163,6 +165,19 @@ void SetGpuInfo(const content::GPUInfo& gpu_info) {
SetGpuInfoImpl(gpu_info, SetCrashKeyValue);
}
+void SetPrinterInfo(const char* printer_info) {
+ std::vector<std::string> info;
+ base::SplitString(printer_info, L';', &info);
+ info.resize(kMaxReportedPrinterRecords);
+ for (size_t i = 0; i < info.size(); ++i) {
+ NSString* key = [NSString stringWithFormat:kPrinterInfoNameFormat, i];
+ ClearCrashKey(key);
+ if (!info[i].empty()) {
+ NSString *value = [NSString stringWithUTF8String:info[i].c_str()];
+ SetCrashKeyValue(key, value);
+ }
+ }
+}
void SetNumberOfViewsImpl(int number_of_views,
SetCrashKeyValueFuncPtr set_key_func) {
diff --git a/chrome/common/child_process_logging_posix.cc b/chrome/common/child_process_logging_posix.cc
index 2015256..916d2e9 100644
--- a/chrome/common/child_process_logging_posix.cc
+++ b/chrome/common/child_process_logging_posix.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/format_macros.h"
#include "base/string_number_conversions.h"
+#include "base/string_split.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/installer/util/google_update_settings.h"
@@ -29,13 +30,14 @@ char g_client_id[kClientIdSize];
char g_channel[kChannelSize] = "";
static const size_t kGpuStringSize = 32;
-
char g_gpu_vendor_id[kGpuStringSize] = "";
char g_gpu_device_id[kGpuStringSize] = "";
char g_gpu_driver_ver[kGpuStringSize] = "";
char g_gpu_ps_ver[kGpuStringSize] = "";
char g_gpu_vs_ver[kGpuStringSize] = "";
+char g_printer_info[kPrinterInfoStrLen * kMaxReportedPrinterRecords + 1] = "";
+
static const size_t kNumSize = 32;
char g_num_extensions[kNumSize] = "";
char g_num_switches[kNumSize] = "";
@@ -103,6 +105,22 @@ void SetGpuInfo(const content::GPUInfo& gpu_info) {
g_gpu_vs_ver[kGpuStringSize - 1] = '\0';
}
+void SetPrinterInfo(const char* printer_info) {
+ std::string printer_info_str;
+ std::vector<std::string> info;
+ base::SplitString(printer_info, L';', &info);
+ DCHECK_LE(info.size(), kMaxReportedPrinterRecords);
+ info.resize(kMaxReportedPrinterRecords);
+ for (size_t i = 0; i < info.size(); ++i) {
+ printer_info_str += info[i];
+ // Truncate long switches, align short ones with spaces to be trimmed later.
+ printer_info_str.resize((i + 1) * kPrinterInfoStrLen, ' ');
+ }
+ strncpy(g_printer_info, printer_info_str.c_str(),
+ arraysize(g_printer_info) - 1);
+ g_printer_info[arraysize(g_printer_info) - 1] = '\0';
+}
+
void SetNumberOfViews(int number_of_views) {
snprintf(g_num_views, kNumSize - 1, "%d", number_of_views);
g_num_views[kNumSize - 1] = '\0';
diff --git a/chrome/common/child_process_logging_win.cc b/chrome/common/child_process_logging_win.cc
index b67d66a..5a1732e 100644
--- a/chrome/common/child_process_logging_win.cc
+++ b/chrome/common/child_process_logging_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -37,6 +37,10 @@ typedef void (__cdecl *MainSetGpuInfo)(const wchar_t*, const wchar_t*,
const wchar_t*);
// exported in breakpad_win.cc:
+// void __declspec(dllexport) __cdecl SetPrinterInfo.
+typedef void (__cdecl *MainSetPrinterInfo)(const wchar_t*);
+
+// exported in breakpad_win.cc:
// void __declspec(dllexport) __cdecl SetNumberOfViews.
typedef void (__cdecl *MainSetNumberOfViews)(int);
@@ -150,6 +154,20 @@ void SetGpuInfo(const content::GPUInfo& gpu_info) {
UTF8ToUTF16(gpu_info.vertex_shader_version).c_str());
}
+void SetPrinterInfo(const char* printer_info) {
+ static MainSetPrinterInfo set_printer_info = NULL;
+ if (!set_printer_info) {
+ HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName);
+ if (!exe_module)
+ return;
+ set_printer_info = reinterpret_cast<MainSetPrinterInfo>(
+ GetProcAddress(exe_module, "SetPrinterInfo"));
+ if (!set_printer_info)
+ return;
+ }
+ (set_printer_info)(UTF8ToWide(printer_info).c_str());
+}
+
void SetCommandLine(const CommandLine* command_line) {
static MainSetCommandLine set_command_line = NULL;
if (!set_command_line) {