OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_CRASH_CORE_COMMON_CRASH_KEYS_H_ | 5 #ifndef COMPONENTS_CRASH_CORE_COMMON_CRASH_KEYS_H_ |
6 #define COMPONENTS_CRASH_CORE_COMMON_CRASH_KEYS_H_ | 6 #define COMPONENTS_CRASH_CORE_COMMON_CRASH_KEYS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
| 11 #include "base/debug/crash_logging.h" |
11 #include "build/build_config.h" | 12 #include "build/build_config.h" |
12 | 13 |
| 14 namespace base { |
| 15 class CommandLine; |
| 16 } // namespace base |
| 17 |
13 namespace crash_keys { | 18 namespace crash_keys { |
14 | 19 |
15 // Sets the ID (which may either be a full GUID or a GUID that was already | 20 // Sets the ID (which may either be a full GUID or a GUID that was already |
16 // stripped from its dashes -- in either case this method will strip remaining | 21 // stripped from its dashes -- in either case this method will strip remaining |
17 // dashes before setting the crash key). | 22 // dashes before setting the crash key). |
18 void SetMetricsClientIdFromGUID(const std::string& metrics_client_guid); | 23 void SetMetricsClientIdFromGUID(const std::string& metrics_client_guid); |
19 void ClearMetricsClientId(); | 24 void ClearMetricsClientId(); |
20 | 25 |
21 // Sets the list of active experiment/variations info. | 26 // Sets the list of active experiment/variations info. |
22 void SetVariationsList(const std::vector<std::string>& variations); | 27 void SetVariationsList(const std::vector<std::string>& variations); |
23 | 28 |
| 29 // Adds a common set of crash keys for holding command-line switches to |keys|. |
| 30 void GetCrashKeysForCommandLineSwitches( |
| 31 std::vector<base::debug::CrashKey>* keys); |
| 32 |
| 33 // A function returning true if |flag| is a switch that should be filtered out |
| 34 // of crash keys. |
| 35 using SwitchFilterFunction = bool (*)(const std::string& flag); |
| 36 |
| 37 // Sets the kNumSwitches key and a set of keys named using kSwitchFormat based |
| 38 // on the given |command_line|. If |skip_filter| is not null, ignore any switch |
| 39 // for which it returns true. |
| 40 void SetSwitchesFromCommandLine(const base::CommandLine& command_line, |
| 41 SwitchFilterFunction skip_filter); |
| 42 |
24 // Crash Key Constants ///////////////////////////////////////////////////////// | 43 // Crash Key Constants ///////////////////////////////////////////////////////// |
25 | 44 |
26 // kChunkMaxLength is the platform-specific maximum size that a value in a | 45 // kChunkMaxLength is the platform-specific maximum size that a value in a |
27 // single chunk can be; see base::debug::InitCrashKeys. The maximum lengths | 46 // single chunk can be; see base::debug::InitCrashKeys. The maximum lengths |
28 // specified by breakpad include the trailing NULL, so the actual length of the | 47 // specified by breakpad include the trailing NULL, so the actual length of the |
29 // chunk is one less. | 48 // chunk is one less. |
30 #if defined(OS_MACOSX) | 49 #if defined(OS_MACOSX) |
31 const size_t kChunkMaxLength = 255; | 50 const size_t kChunkMaxLength = 255; |
32 #else // OS_MACOSX | 51 #else // OS_MACOSX |
33 const size_t kChunkMaxLength = 63; | 52 const size_t kChunkMaxLength = 63; |
(...skipping 27 matching lines...) Expand all Loading... |
61 // The product release/distribution channel. | 80 // The product release/distribution channel. |
62 extern const char kChannel[]; | 81 extern const char kChannel[]; |
63 | 82 |
64 // The total number of experiments the instance has. | 83 // The total number of experiments the instance has. |
65 extern const char kNumVariations[]; | 84 extern const char kNumVariations[]; |
66 | 85 |
67 // The experiments chunk. Hashed experiment names separated by |,|. This is | 86 // The experiments chunk. Hashed experiment names separated by |,|. This is |
68 // typically set by SetExperimentList. | 87 // typically set by SetExperimentList. |
69 extern const char kVariations[]; | 88 extern const char kVariations[]; |
70 | 89 |
| 90 // The maximum number of command line switches to process. |kSwitchFormat| |
| 91 // should be formatted with an integer in the range [1, kSwitchesMaxCount]. |
| 92 const size_t kSwitchesMaxCount = 15; |
| 93 |
| 94 // A printf-style format string naming the set of crash keys corresponding to |
| 95 // at most |kSwitchesMaxCount| command line switches. |
| 96 extern const char kSwitchFormat[]; |
| 97 |
| 98 // The total number of switches, used to report the total in case more than |
| 99 // |kSwitchesMaxCount| are present. |
| 100 extern const char kNumSwitches[]; |
| 101 |
71 // Used to help investigate bug 464926. | 102 // Used to help investigate bug 464926. |
72 extern const char kBug464926CrashKey[]; | 103 extern const char kBug464926CrashKey[]; |
73 | 104 |
74 #if defined(OS_MACOSX) | 105 #if defined(OS_MACOSX) |
75 namespace mac { | 106 namespace mac { |
76 | 107 |
77 // Records Cocoa zombie/used-after-freed objects that resulted in a | 108 // Records Cocoa zombie/used-after-freed objects that resulted in a |
78 // deliberate crash. | 109 // deliberate crash. |
79 extern const char kZombie[]; | 110 extern const char kZombie[]; |
80 extern const char kZombieTrace[]; | 111 extern const char kZombieTrace[]; |
81 | 112 |
82 } // namespace mac | 113 } // namespace mac |
83 #endif | 114 #endif |
84 | 115 |
85 } // namespace crash_keys | 116 } // namespace crash_keys |
86 | 117 |
87 #endif // COMPONENTS_CRASH_CORE_COMMON_CRASH_KEYS_H_ | 118 #endif // COMPONENTS_CRASH_CORE_COMMON_CRASH_KEYS_H_ |
OLD | NEW |