• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_COMMON_CRASH_KEYS_H_
6 #define CHROME_COMMON_CRASH_KEYS_H_
7 
8 #include <set>
9 #include <string>
10 #include <vector>
11 
12 #include "base/debug/crash_logging.h"
13 
14 namespace base {
15 class CommandLine;
16 }
17 
18 namespace crash_keys {
19 
20 // Registers all of the potential crash keys that can be sent to the crash
21 // reporting server. Returns the size of the union of all keys.
22 size_t RegisterChromeCrashKeys();
23 
24 // Sets the GUID by which this crash reporting client can be identified.
25 void SetClientID(const std::string& client_id);
26 
27 // Sets the kSwitch and kNumSwitches keys based on the given |command_line|.
28 void SetSwitchesFromCommandLine(const base::CommandLine* command_line);
29 
30 // Sets the list of active experiment/variations info.
31 void SetVariationsList(const std::vector<std::string>& variations);
32 
33 // Sets the list of "active" extensions in this process. We overload "active" to
34 // mean different things depending on the process type:
35 // - browser: all enabled extensions
36 // - renderer: the unique set of extension ids from all content scripts
37 // - extension: the id of each extension running in this process (there can be
38 //   multiple because of process collapsing).
39 void SetActiveExtensions(const std::set<std::string>& extensions);
40 
41 // Sets the printer info. Data should be separated by ';' up to
42 // kPrinterInfoCount substrings. Each substring will be truncated if necessary.
43 class ScopedPrinterInfo {
44  public:
45   explicit ScopedPrinterInfo(const base::StringPiece& data);
46   ~ScopedPrinterInfo();
47 
48  private:
49   DISALLOW_COPY_AND_ASSIGN(ScopedPrinterInfo);
50 };
51 
52 // Crash Key Name Constants ////////////////////////////////////////////////////
53 
54 // The GUID used to identify this client to the crash system.
55 extern const char kClientID[];
56 
57 // The product release/distribution channel.
58 extern const char kChannel[];
59 
60 // The URL of the active tab.
61 extern const char kActiveURL[];
62 
63 // Process command line switches. |kSwitch| should be formatted with an integer,
64 // in the range [1, kSwitchesMaxCount].
65 const size_t kSwitchesMaxCount = 15;
66 extern const char kSwitch[];
67 // The total number of switches, used to report the total in case more than
68 // |kSwitchesMaxCount| are present.
69 extern const char kNumSwitches[];
70 
71 // The total number of experiments the instance has.
72 extern const char kNumVariations[];
73 // The experiments chunk. Hashed experiment names separated by |,|. This is
74 // typically set by SetExperimentList.
75 extern const char kVariations[];
76 
77 // Installed extensions. |kExtensionID| should be formatted with an integer,
78 // in the range [0, kExtensionIDMaxCount).
79 const size_t kExtensionIDMaxCount = 10;
80 extern const char kExtensionID[];
81 // The total number of installed extensions, recorded in case it exceeds
82 // kExtensionIDMaxCount. Also used in chrome/app, but defined here to avoid
83 // a common->app dependency.
84 extern const char kNumExtensionsCount[];
85 
86 // The number of render views/tabs open in a renderer process.
87 extern const char kNumberOfViews[];
88 
89 // Type of shutdown. The value is one of "close" for WINDOW_CLOSE,
90 // "exit" for BROWSER_EXIT, or "end" for END_SESSION.
91 extern const char kShutdownType[];
92 
93 // GPU information.
94 #if !defined(OS_ANDROID)
95 extern const char kGPUVendorID[];
96 extern const char kGPUDeviceID[];
97 #endif
98 extern const char kGPUDriverVersion[];
99 extern const char kGPUPixelShaderVersion[];
100 extern const char kGPUVertexShaderVersion[];
101 #if defined(OS_MACOSX)
102 extern const char kGPUGLVersion[];
103 #elif defined(OS_POSIX)
104 extern const char kGPUVendor[];
105 extern const char kGPURenderer[];
106 #endif
107 
108 // The user's printers, up to kPrinterInfoCount. Should be set with
109 // ScopedPrinterInfo.
110 const size_t kPrinterInfoCount = 4;
111 extern const char kPrinterInfo[];
112 
113 #if defined(OS_CHROMEOS)
114 // The number of simultaneous users in multi profile sessions.
115 extern const char kNumberOfUsers[];
116 #endif
117 
118 #if defined(OS_MACOSX)
119 namespace mac {
120 
121 // Used to report the first Cocoa/Mac NSException and its backtrace.
122 extern const char kFirstNSException[];
123 extern const char kFirstNSExceptionTrace[];
124 
125 // Used to report the last Cocoa/Mac NSException and its backtrace.
126 extern const char kLastNSException[];
127 extern const char kLastNSExceptionTrace[];
128 
129 // Records the current NSException as it is being created, and its backtrace.
130 extern const char kNSException[];
131 extern const char kNSExceptionTrace[];
132 
133 // In the CrApplication, records information about the current event's
134 // target-action.
135 extern const char kSendAction[];
136 
137 // Records Cocoa zombie/used-after-freed objects that resulted in a
138 // deliberate crash.
139 extern const char kZombie[];
140 extern const char kZombieTrace[];
141 
142 }  // namespace mac
143 #endif
144 
145 }  // namespace crash_keys
146 
147 #endif  // CHROME_COMMON_CRASH_KEYS_H_
148