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