OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "components/crash/app/crash_keys_win.h" | 5 #include "components/crash/app/crash_keys_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "components/crash/app/breakpad_client.h" | 15 #include "components/crash/app/crash_reporter_client.h" |
16 | |
17 | 16 |
18 namespace breakpad { | 17 namespace breakpad { |
19 | 18 |
| 19 using crash_reporter::CrashReporterClient; |
| 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 const size_t kMaxPluginPathLength = 256; | 23 const size_t kMaxPluginPathLength = 256; |
23 const size_t kMaxDynamicEntries = 256; | 24 const size_t kMaxDynamicEntries = 256; |
24 | 25 |
25 } // namespace | 26 } // namespace |
26 | 27 |
27 CrashKeysWin* CrashKeysWin::keeper_; | 28 CrashKeysWin* CrashKeysWin::keeper_; |
28 | 29 |
29 CrashKeysWin::CrashKeysWin() : dynamic_keys_offset_(0) { | 30 CrashKeysWin::CrashKeysWin() : dynamic_keys_offset_(0) { |
(...skipping 27 matching lines...) Expand all Loading... |
57 | 58 |
58 custom_entries_.push_back(google_breakpad::CustomInfoEntry( | 59 custom_entries_.push_back(google_breakpad::CustomInfoEntry( |
59 base::StringPrintf(L"plugin-path-chunk-%i", chunk_index + 1).c_str(), | 60 base::StringPrintf(L"plugin-path-chunk-%i", chunk_index + 1).c_str(), |
60 path.substr(chunk_start, chunk_length).c_str())); | 61 path.substr(chunk_start, chunk_length).c_str())); |
61 | 62 |
62 chunk_start += chunk_length; | 63 chunk_start += chunk_length; |
63 } | 64 } |
64 } | 65 } |
65 | 66 |
66 // Appends the breakpad dump path to |g_custom_entries|. | 67 // Appends the breakpad dump path to |g_custom_entries|. |
67 void CrashKeysWin::SetBreakpadDumpPath(BreakpadClient* breakpad_client) { | 68 void CrashKeysWin::SetBreakpadDumpPath(CrashReporterClient* crash_client) { |
68 | |
69 base::FilePath crash_dumps_dir_path; | 69 base::FilePath crash_dumps_dir_path; |
70 if (breakpad_client->GetAlternativeCrashDumpLocation( | 70 if (crash_client->GetAlternativeCrashDumpLocation(&crash_dumps_dir_path)) { |
71 &crash_dumps_dir_path)) { | |
72 custom_entries_.push_back(google_breakpad::CustomInfoEntry( | 71 custom_entries_.push_back(google_breakpad::CustomInfoEntry( |
73 L"breakpad-dump-location", crash_dumps_dir_path.value().c_str())); | 72 L"breakpad-dump-location", crash_dumps_dir_path.value().c_str())); |
74 } | 73 } |
75 } | 74 } |
76 | 75 |
77 // Returns the custom info structure based on the dll in parameter and the | 76 // Returns the custom info structure based on the dll in parameter and the |
78 // process type. | 77 // process type. |
79 google_breakpad::CustomClientInfo* | 78 google_breakpad::CustomClientInfo* |
80 CrashKeysWin::GetCustomInfo(const std::wstring& exe_path, | 79 CrashKeysWin::GetCustomInfo(const std::wstring& exe_path, |
81 const std::wstring& type, | 80 const std::wstring& type, |
82 const std::wstring& profile_type, | 81 const std::wstring& profile_type, |
83 base::CommandLine* cmd_line, | 82 base::CommandLine* cmd_line, |
84 BreakpadClient* breakpad_client) { | 83 CrashReporterClient* crash_client) { |
85 base::string16 version, product; | 84 base::string16 version, product; |
86 base::string16 special_build; | 85 base::string16 special_build; |
87 base::string16 channel_name; | 86 base::string16 channel_name; |
88 | 87 |
89 breakpad_client->GetProductNameAndVersion( | 88 crash_client->GetProductNameAndVersion( |
90 base::FilePath(exe_path), | 89 base::FilePath(exe_path), |
91 &product, | 90 &product, |
92 &version, | 91 &version, |
93 &special_build, | 92 &special_build, |
94 &channel_name); | 93 &channel_name); |
95 | 94 |
96 // We only expect this method to be called once per process. | 95 // We only expect this method to be called once per process. |
97 // Common enties | 96 // Common enties |
98 custom_entries_.push_back( | 97 custom_entries_.push_back( |
99 google_breakpad::CustomInfoEntry(L"ver", | 98 google_breakpad::CustomInfoEntry(L"ver", |
(...skipping 18 matching lines...) Expand all Loading... |
118 | 117 |
119 if (type == L"plugin" || type == L"ppapi") { | 118 if (type == L"plugin" || type == L"ppapi") { |
120 std::wstring plugin_path = cmd_line->GetSwitchValueNative("plugin-path"); | 119 std::wstring plugin_path = cmd_line->GetSwitchValueNative("plugin-path"); |
121 if (!plugin_path.empty()) | 120 if (!plugin_path.empty()) |
122 SetPluginPath(plugin_path); | 121 SetPluginPath(plugin_path); |
123 } | 122 } |
124 | 123 |
125 | 124 |
126 // Check whether configuration management controls crash reporting. | 125 // Check whether configuration management controls crash reporting. |
127 bool crash_reporting_enabled = true; | 126 bool crash_reporting_enabled = true; |
128 bool controlled_by_policy = breakpad_client->ReportingIsEnforcedByPolicy( | 127 bool controlled_by_policy = crash_client->ReportingIsEnforcedByPolicy( |
129 &crash_reporting_enabled); | 128 &crash_reporting_enabled); |
130 bool use_crash_service = !controlled_by_policy && | 129 bool use_crash_service = !controlled_by_policy && |
131 (cmd_line->HasSwitch(switches::kNoErrorDialogs) || | 130 (cmd_line->HasSwitch(switches::kNoErrorDialogs) || |
132 breakpad_client->IsRunningUnattended()); | 131 crash_client->IsRunningUnattended()); |
133 if (use_crash_service) | 132 if (use_crash_service) |
134 SetBreakpadDumpPath(breakpad_client); | 133 SetBreakpadDumpPath(crash_client); |
135 | 134 |
136 // Create space for dynamic ad-hoc keys. The names and values are set using | 135 // Create space for dynamic ad-hoc keys. The names and values are set using |
137 // the API defined in base/debug/crash_logging.h. | 136 // the API defined in base/debug/crash_logging.h. |
138 dynamic_keys_offset_ = custom_entries_.size(); | 137 dynamic_keys_offset_ = custom_entries_.size(); |
139 for (size_t i = 0; i < kMaxDynamicEntries; ++i) { | 138 for (size_t i = 0; i < kMaxDynamicEntries; ++i) { |
140 // The names will be mutated as they are set. Un-numbered since these are | 139 // The names will be mutated as they are set. Un-numbered since these are |
141 // merely placeholders. The name cannot be empty because Breakpad's | 140 // merely placeholders. The name cannot be empty because Breakpad's |
142 // HTTPUpload will interpret that as an invalid parameter. | 141 // HTTPUpload will interpret that as an invalid parameter. |
143 custom_entries_.push_back( | 142 custom_entries_.push_back( |
144 google_breakpad::CustomInfoEntry(L"unspecified-crash-key", L"")); | 143 google_breakpad::CustomInfoEntry(L"unspecified-crash-key", L"")); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 184 |
186 std::wstring key_string(key); | 185 std::wstring key_string(key); |
187 DynamicEntriesMap::iterator it = dynamic_entries_.find(key_string); | 186 DynamicEntriesMap::iterator it = dynamic_entries_.find(key_string); |
188 if (it == dynamic_entries_.end()) | 187 if (it == dynamic_entries_.end()) |
189 return; | 188 return; |
190 | 189 |
191 it->second->set_value(NULL); | 190 it->second->set_value(NULL); |
192 } | 191 } |
193 | 192 |
194 } // namespace breakpad | 193 } // namespace breakpad |
OLD | NEW |