| OLD | NEW |
| 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 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/debug/crash_logging.h" | 13 #include "base/debug/crash_logging.h" |
| 14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 | 15 |
| 16 class CommandLine; | 16 class CommandLine; |
| 17 | 17 |
| 18 // The maximum number of active extensions we will report. | |
| 19 // Also used in chrome/app, but we define it here to avoid a common->app | |
| 20 // dependency. | |
| 21 static const size_t kMaxReportedActiveExtensions = 10; | |
| 22 | |
| 23 // The maximum number of variation chunks we will report. | 18 // The maximum number of variation chunks we will report. |
| 24 // Also used in chrome/app, but we define it here to avoid a common->app | 19 // Also used in chrome/app, but we define it here to avoid a common->app |
| 25 // dependency. | 20 // dependency. |
| 26 static const size_t kMaxReportedVariationChunks = 15; | 21 static const size_t kMaxReportedVariationChunks = 15; |
| 27 | 22 |
| 28 // The maximum size of a variation chunk. This size was picked to be | 23 // The maximum size of a variation chunk. This size was picked to be |
| 29 // consistent between platforms and the value was chosen from the Windows | 24 // consistent between platforms and the value was chosen from the Windows |
| 30 // limit of google_breakpad::CustomInfoEntry::kValueMaxLength. | 25 // limit of google_breakpad::CustomInfoEntry::kValueMaxLength. |
| 31 static const size_t kMaxVariationChunkSize = 64; | 26 static const size_t kMaxVariationChunkSize = 64; |
| 32 | 27 |
| 33 // The maximum number of prn-info-* records. | 28 // The maximum number of prn-info-* records. |
| 34 static const size_t kMaxReportedPrinterRecords = 4; | 29 static const size_t kMaxReportedPrinterRecords = 4; |
| 35 | 30 |
| 36 // The maximum number of command line switches to include in the crash | 31 // The maximum number of command line switches to include in the crash |
| 37 // report's metadata. Note that the mini-dump itself will also contain the | 32 // report's metadata. Note that the mini-dump itself will also contain the |
| 38 // (original) command line arguments within the PEB. | 33 // (original) command line arguments within the PEB. |
| 39 // Also used in chrome/app, but we define it here to avoid a common->app | 34 // Also used in chrome/app, but we define it here to avoid a common->app |
| 40 // dependency. | 35 // dependency. |
| 41 static const size_t kMaxSwitches = 15; | 36 static const size_t kMaxSwitches = 15; |
| 42 | 37 |
| 43 namespace child_process_logging { | 38 namespace child_process_logging { |
| 44 | 39 |
| 45 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 40 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 46 // These are declared here so the crash reporter can access them directly in | 41 // These are declared here so the crash reporter can access them directly in |
| 47 // compromised context without going through the standard library. | 42 // compromised context without going through the standard library. |
| 48 extern char g_channel[]; | 43 extern char g_channel[]; |
| 49 extern char g_client_id[]; | 44 extern char g_client_id[]; |
| 50 extern char g_extension_ids[]; | |
| 51 extern char g_num_extensions[]; | |
| 52 extern char g_num_switches[]; | 45 extern char g_num_switches[]; |
| 53 extern char g_num_variations[]; | 46 extern char g_num_variations[]; |
| 54 extern char g_num_views[]; | 47 extern char g_num_views[]; |
| 55 extern char g_printer_info[]; | 48 extern char g_printer_info[]; |
| 56 extern char g_switches[]; | 49 extern char g_switches[]; |
| 57 extern char g_variation_chunks[]; | 50 extern char g_variation_chunks[]; |
| 58 | 51 |
| 59 // Assume IDs are 32 bytes long. | |
| 60 static const size_t kExtensionLen = 32; | |
| 61 | |
| 62 // Assume command line switches are less than 64 chars. | 52 // Assume command line switches are less than 64 chars. |
| 63 static const size_t kSwitchLen = 64; | 53 static const size_t kSwitchLen = 64; |
| 64 | 54 |
| 65 // Assume printer info strings are less than 64 chars. | 55 // Assume printer info strings are less than 64 chars. |
| 66 static const size_t kPrinterInfoStrLen = 64; | 56 static const size_t kPrinterInfoStrLen = 64; |
| 67 #endif | 57 #endif |
| 68 | 58 |
| 69 // Sets the Client ID that is used as GUID if a Chrome process crashes. | 59 // Sets the Client ID that is used as GUID if a Chrome process crashes. |
| 70 void SetClientId(const std::string& client_id); | 60 void SetClientId(const std::string& client_id); |
| 71 | 61 |
| 72 // Gets the Client ID to be used as GUID for crash reporting. Returns the client | 62 // Gets the Client ID to be used as GUID for crash reporting. Returns the client |
| 73 // id in |client_id| if it's known, an empty string otherwise. | 63 // id in |client_id| if it's known, an empty string otherwise. |
| 74 std::string GetClientId(); | 64 std::string GetClientId(); |
| 75 | 65 |
| 76 // Sets the list of "active" extensions in this process. We overload "active" to | |
| 77 // mean different things depending on the process type: | |
| 78 // - browser: all enabled extensions | |
| 79 // - renderer: the unique set of extension ids from all content scripts | |
| 80 // - extension: the id of each extension running in this process (there can be | |
| 81 // multiple because of process collapsing). | |
| 82 void SetActiveExtensions(const std::set<std::string>& extension_ids); | |
| 83 | |
| 84 // Sets a number of views/tabs opened in this process. | 66 // Sets a number of views/tabs opened in this process. |
| 85 void SetNumberOfViews(int number_of_views); | 67 void SetNumberOfViews(int number_of_views); |
| 86 | 68 |
| 87 // Sets the data on the printer to send along with crash reports. Data may be | 69 // Sets the data on the printer to send along with crash reports. Data may be |
| 88 // separated by ';' up to kMaxReportedPrinterRecords strings. Each substring | 70 // separated by ';' up to kMaxReportedPrinterRecords strings. Each substring |
| 89 // would be cut to 63 chars. | 71 // would be cut to 63 chars. |
| 90 void SetPrinterInfo(const char* printer_info); | 72 void SetPrinterInfo(const char* printer_info); |
| 91 | 73 |
| 92 // Sets the command line arguments to send along with crash reports to the | 74 // Sets the command line arguments to send along with crash reports to the |
| 93 // values in |command_line|. | 75 // values in |command_line|. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 121 #if defined(OS_WIN) | 103 #if defined(OS_WIN) |
| 122 namespace child_process_logging { | 104 namespace child_process_logging { |
| 123 | 105 |
| 124 // Sets up the base/debug/crash_logging.h mechanism. | 106 // Sets up the base/debug/crash_logging.h mechanism. |
| 125 void Init(); | 107 void Init(); |
| 126 | 108 |
| 127 } // namespace child_process_logging | 109 } // namespace child_process_logging |
| 128 #endif // defined(OS_WIN) | 110 #endif // defined(OS_WIN) |
| 129 | 111 |
| 130 #endif // CHROME_COMMON_CHILD_PROCESS_LOGGING_H_ | 112 #endif // CHROME_COMMON_CHILD_PROCESS_LOGGING_H_ |
| OLD | NEW |