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