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

Side by Side Diff: chrome/common/child_process_logging.h

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
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 #ifndef CHROME_COMMON_CHILD_PROCESS_LOGGING_H_ 5 #ifndef CHROME_COMMON_CHILD_PROCESS_LOGGING_H_
6 #define CHROME_COMMON_CHILD_PROCESS_LOGGING_H_ 6 #define CHROME_COMMON_CHILD_PROCESS_LOGGING_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/debug/crash_logging.h" 13 #include "base/debug/crash_logging.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 15
16 class CommandLine; 16 class CommandLine;
17 17
18 // The maximum number of variation chunks we will report. 18 // The maximum number of variation chunks we will report.
19 // Also used in chrome/app, but we define it here to avoid a common->app 19 // Also used in chrome/app, but we define it here to avoid a common->app
20 // dependency. 20 // dependency.
21 static const size_t kMaxReportedVariationChunks = 15; 21 static const size_t kMaxReportedVariationChunks = 15;
22 22
23 // The maximum size of a variation chunk. This size was picked to be 23 // The maximum size of a variation chunk. This size was picked to be
24 // consistent between platforms and the value was chosen from the Windows 24 // consistent between platforms and the value was chosen from the Windows
25 // limit of google_breakpad::CustomInfoEntry::kValueMaxLength. 25 // limit of google_breakpad::CustomInfoEntry::kValueMaxLength.
26 static const size_t kMaxVariationChunkSize = 64; 26 static const size_t kMaxVariationChunkSize = 64;
27 27
28 // The maximum number of prn-info-* records.
29 static const size_t kMaxReportedPrinterRecords = 4;
30
31 // The maximum number of command line switches to include in the crash 28 // The maximum number of command line switches to include in the crash
32 // report's metadata. Note that the mini-dump itself will also contain the 29 // report's metadata. Note that the mini-dump itself will also contain the
33 // (original) command line arguments within the PEB. 30 // (original) command line arguments within the PEB.
34 // Also used in chrome/app, but we define it here to avoid a common->app 31 // Also used in chrome/app, but we define it here to avoid a common->app
35 // dependency. 32 // dependency.
36 static const size_t kMaxSwitches = 15; 33 static const size_t kMaxSwitches = 15;
37 34
38 namespace child_process_logging { 35 namespace child_process_logging {
39 36
40 #if defined(OS_POSIX) && !defined(OS_MACOSX) 37 #if defined(OS_POSIX) && !defined(OS_MACOSX)
41 // These are declared here so the crash reporter can access them directly in 38 // These are declared here so the crash reporter can access them directly in
42 // compromised context without going through the standard library. 39 // compromised context without going through the standard library.
43 extern char g_client_id[]; 40 extern char g_client_id[];
44 extern char g_num_switches[]; 41 extern char g_num_switches[];
45 extern char g_num_variations[]; 42 extern char g_num_variations[];
46 extern char g_printer_info[];
47 extern char g_switches[]; 43 extern char g_switches[];
48 extern char g_variation_chunks[]; 44 extern char g_variation_chunks[];
49 45
50 // Assume command line switches are less than 64 chars. 46 // Assume command line switches are less than 64 chars.
51 static const size_t kSwitchLen = 64; 47 static const size_t kSwitchLen = 64;
52
53 // Assume printer info strings are less than 64 chars.
54 static const size_t kPrinterInfoStrLen = 64;
55 #endif 48 #endif
56 49
57 // Sets the Client ID that is used as GUID if a Chrome process crashes. 50 // Sets the Client ID that is used as GUID if a Chrome process crashes.
58 void SetClientId(const std::string& client_id); 51 void SetClientId(const std::string& client_id);
59 52
60 // Gets the Client ID to be used as GUID for crash reporting. Returns the client 53 // Gets the Client ID to be used as GUID for crash reporting. Returns the client
61 // id in |client_id| if it's known, an empty string otherwise. 54 // id in |client_id| if it's known, an empty string otherwise.
62 std::string GetClientId(); 55 std::string GetClientId();
63 56
64 // Sets the data on the printer to send along with crash reports. Data may be
65 // separated by ';' up to kMaxReportedPrinterRecords strings. Each substring
66 // would be cut to 63 chars.
67 void SetPrinterInfo(const char* printer_info);
68
69 // Sets the command line arguments to send along with crash reports to the 57 // Sets the command line arguments to send along with crash reports to the
70 // values in |command_line|. 58 // values in |command_line|.
71 void SetCommandLine(const CommandLine* command_line); 59 void SetCommandLine(const CommandLine* command_line);
72 60
73 // Initialize the list of experiment info to send along with crash reports. 61 // Initialize the list of experiment info to send along with crash reports.
74 void SetExperimentList(const std::vector<string16>& state); 62 void SetExperimentList(const std::vector<string16>& state);
75 63
76 // Set/clear information about currently accessed printer.
77 class ScopedPrinterInfoSetter {
78 public:
79 explicit ScopedPrinterInfoSetter(const std::string& printer_info) {
80 SetPrinterInfo(printer_info.c_str());
81 }
82
83 ~ScopedPrinterInfoSetter() {
84 SetPrinterInfo("");
85 }
86
87 private:
88 DISALLOW_COPY_AND_ASSIGN(ScopedPrinterInfoSetter);
89 };
90
91 } // namespace child_process_logging 64 } // namespace child_process_logging
92 65
93 #if defined(OS_WIN) 66 #if defined(OS_WIN)
94 namespace child_process_logging { 67 namespace child_process_logging {
95 68
96 // Sets up the base/debug/crash_logging.h mechanism. 69 // Sets up the base/debug/crash_logging.h mechanism.
97 void Init(); 70 void Init();
98 71
99 } // namespace child_process_logging 72 } // namespace child_process_logging
100 #endif // defined(OS_WIN) 73 #endif // defined(OS_WIN)
101 74
102 #endif // CHROME_COMMON_CHILD_PROCESS_LOGGING_H_ 75 #endif // CHROME_COMMON_CHILD_PROCESS_LOGGING_H_
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_system_task_proxy.cc ('k') | chrome/common/child_process_logging_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698