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

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

Issue 9600060: SetPrinterInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments Created 8 years, 9 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 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/mac/crash_logging.h" 13 #include "base/mac/crash_logging.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 15
16 class CommandLine; 16 class CommandLine;
17 17
18 namespace content { 18 namespace content {
19 struct GPUInfo; 19 struct GPUInfo;
20 } 20 }
21 21
22 // The maximum number of active extensions we will report. 22 // The maximum number of active extensions we will report.
23 // Also used in chrome/app, but we define it here to avoid a common->app 23 // Also used in chrome/app, but we define it here to avoid a common->app
24 // dependency. 24 // dependency.
25 static const int kMaxReportedActiveExtensions = 10; 25 static const int kMaxReportedActiveExtensions = 10;
26 26
27 // The maximum number of prn-info-* records.
28 static const size_t kMaxReportedPrinterRecords = 4;
29
27 // The maximum number of command line switches to include in the crash 30 // The maximum number of command line switches to include in the crash
28 // report's metadata. Note that the mini-dump itself will also contain the 31 // report's metadata. Note that the mini-dump itself will also contain the
29 // (original) command line arguments within the PEB. 32 // (original) command line arguments within the PEB.
30 // Also used in chrome/app, but we define it here to avoid a common->app 33 // Also used in chrome/app, but we define it here to avoid a common->app
31 // dependency. 34 // dependency.
32 static const size_t kMaxSwitches = 15; 35 static const size_t kMaxSwitches = 15;
33 36
34 namespace child_process_logging { 37 namespace child_process_logging {
35 38
36 #if defined(OS_POSIX) && !defined(OS_MACOSX) 39 #if defined(OS_POSIX) && !defined(OS_MACOSX)
37 // These are declared here so the crash reporter can access them directly in 40 // These are declared here so the crash reporter can access them directly in
38 // compromised context without going through the standard library. 41 // compromised context without going through the standard library.
39 extern char g_active_url[]; 42 extern char g_active_url[];
40 extern char g_channel[]; 43 extern char g_channel[];
41 extern char g_client_id[]; 44 extern char g_client_id[];
42 extern char g_extension_ids[]; 45 extern char g_extension_ids[];
43 extern char g_gpu_vendor_id[]; 46 extern char g_gpu_vendor_id[];
44 extern char g_gpu_device_id[]; 47 extern char g_gpu_device_id[];
45 extern char g_gpu_driver_ver[]; 48 extern char g_gpu_driver_ver[];
46 extern char g_gpu_ps_ver[]; 49 extern char g_gpu_ps_ver[];
47 extern char g_gpu_vs_ver[]; 50 extern char g_gpu_vs_ver[];
48 extern char g_num_extensions[]; 51 extern char g_num_extensions[];
49 extern char g_num_switches[]; 52 extern char g_num_switches[];
50 extern char g_num_views[]; 53 extern char g_num_views[];
54 extern char g_prn_info[];
51 extern char g_switches[]; 55 extern char g_switches[];
52 56
53 // Assume IDs are 32 bytes long. 57 // Assume IDs are 32 bytes long.
54 static const size_t kExtensionLen = 32; 58 static const size_t kExtensionLen = 32;
55 59
56 // Assume command line switches are less than 64 chars. 60 // Assume command line switches are less than 64 chars.
57 static const size_t kSwitchLen = 64; 61 static const size_t kSwitchLen = 64;
62
63 // Assume printer info strings are less than 64 chars.
64 static const size_t kPrinterInfoStrLen = 64;
58 #endif 65 #endif
59 66
60 // Sets the URL that is logged if the child process crashes. Use GURL() to clear 67 // Sets the URL that is logged if the child process crashes. Use GURL() to clear
61 // the URL. 68 // the URL.
62 void SetActiveURL(const GURL& url); 69 void SetActiveURL(const GURL& url);
63 70
64 // Sets the Client ID that is used as GUID if a Chrome process crashes. 71 // Sets the Client ID that is used as GUID if a Chrome process crashes.
65 void SetClientId(const std::string& client_id); 72 void SetClientId(const std::string& client_id);
66 73
67 // Gets the Client ID to be used as GUID for crash reporting. Returns the client 74 // Gets the Client ID to be used as GUID for crash reporting. Returns the client
68 // id in |client_id| if it's known, an empty string otherwise. 75 // id in |client_id| if it's known, an empty string otherwise.
69 std::string GetClientId(); 76 std::string GetClientId();
70 77
71 // Sets the list of "active" extensions in this process. We overload "active" to 78 // Sets the list of "active" extensions in this process. We overload "active" to
72 // mean different things depending on the process type: 79 // mean different things depending on the process type:
73 // - browser: all enabled extensions 80 // - browser: all enabled extensions
74 // - renderer: the unique set of extension ids from all content scripts 81 // - renderer: the unique set of extension ids from all content scripts
75 // - extension: the id of each extension running in this process (there can be 82 // - extension: the id of each extension running in this process (there can be
76 // multiple because of process collapsing). 83 // multiple because of process collapsing).
77 void SetActiveExtensions(const std::set<std::string>& extension_ids); 84 void SetActiveExtensions(const std::set<std::string>& extension_ids);
78 85
79 // Sets a number of views/tabs opened in this process. 86 // Sets a number of views/tabs opened in this process.
80 void SetNumberOfViews(int number_of_views); 87 void SetNumberOfViews(int number_of_views);
81 88
82 // Sets the data on the gpu to send along with crash reports. 89 // Sets the data on the gpu to send along with crash reports.
83 void SetGpuInfo(const content::GPUInfo& gpu_info); 90 void SetGpuInfo(const content::GPUInfo& gpu_info);
84 91
92 // Sets the data on the printer to send along with crash reports. Data may be
93 // separated by ';' up to kMaxReportedPrinterRecords strings. Each substring
94 // would be cut to 63 chars.
95 void SetPrinterInfo(const char* printer_info);
96
85 // Sets the command line arguments to send along with crash reports to the 97 // Sets the command line arguments to send along with crash reports to the
86 // values in |command_line|. 98 // values in |command_line|.
87 void SetCommandLine(const CommandLine* command_line); 99 void SetCommandLine(const CommandLine* command_line);
88 100
89 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_MACOSX) 101 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_MACOSX)
90 // Sets the product channel data to send along with crash reports to |channel|. 102 // Sets the product channel data to send along with crash reports to |channel|.
91 void SetChannel(const std::string& channel); 103 void SetChannel(const std::string& channel);
92 #endif 104 #endif
93 105
94 // Simple wrapper class that sets the active URL in it's constructor and clears 106 // Simple wrapper class that sets the active URL in it's constructor and clears
95 // the active URL in the destructor. 107 // the active URL in the destructor.
96 class ScopedActiveURLSetter { 108 class ScopedActiveURLSetter {
97 public: 109 public:
98 explicit ScopedActiveURLSetter(const GURL& url) { 110 explicit ScopedActiveURLSetter(const GURL& url) {
99 SetActiveURL(url); 111 SetActiveURL(url);
100 } 112 }
101 113
102 ~ScopedActiveURLSetter() { 114 ~ScopedActiveURLSetter() {
103 SetActiveURL(GURL()); 115 SetActiveURL(GURL());
104 } 116 }
105 117
106 private: 118 private:
107 DISALLOW_COPY_AND_ASSIGN(ScopedActiveURLSetter); 119 DISALLOW_COPY_AND_ASSIGN(ScopedActiveURLSetter);
108 }; 120 };
109 121
122 // Set/clear information about currently accessed printer.
123 class ScopedPrinterInfoSetter {
124 public:
125 explicit ScopedPrinterInfoSetter(const char* printer_info) {
126 SetPrinterInfo(printer_info);
127 }
128
129 ~ScopedPrinterInfoSetter() {
130 SetPrinterInfo("");
131 }
132
133 private:
134 DISALLOW_COPY_AND_ASSIGN(ScopedPrinterInfoSetter);
135 };
136
110 } // namespace child_process_logging 137 } // namespace child_process_logging
111 138
112 #if defined(OS_MACOSX) 139 #if defined(OS_MACOSX)
113 140
114 namespace child_process_logging { 141 namespace child_process_logging {
115 142
116 void SetActiveURLImpl(const GURL& url, 143 void SetActiveURLImpl(const GURL& url,
117 base::mac::SetCrashKeyValueFuncPtr set_key_func, 144 base::mac::SetCrashKeyValueFuncPtr set_key_func,
118 base::mac::ClearCrashKeyValueFuncPtr clear_key_func); 145 base::mac::ClearCrashKeyValueFuncPtr clear_key_func);
119 146
120 extern const int kMaxNumCrashURLChunks; 147 extern const int kMaxNumCrashURLChunks;
121 extern const int kMaxNumURLChunkValueLength; 148 extern const int kMaxNumURLChunkValueLength;
122 extern const char *kUrlChunkFormatStr; 149 extern const char *kUrlChunkFormatStr;
123 150
124 } // namespace child_process_logging 151 } // namespace child_process_logging
125 152
126 #endif // defined(OS_MACOSX) 153 #endif // defined(OS_MACOSX)
127 154
128 #endif // CHROME_COMMON_CHILD_PROCESS_LOGGING_H_ 155 #endif // CHROME_COMMON_CHILD_PROCESS_LOGGING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698