@@ -150,14 +150,6 @@ bool ChromeBreakpadClient::AboutToRestart() {
150150 return true ;
151151}
152152
153- #if 0
154- base::string16 ChromeBreakpadClient::GetCrashGUID() {
155- std::wstring guid;
156- // GoogleUpdateSettings::GetMetricsId(&guid);
157- return base::WideToUTF16(guid);
158- }
159- #endif
160-
161153bool ChromeBreakpadClient::GetDeferredUploadsSupported (bool ) {
162154 return false ;
163155}
@@ -173,6 +165,86 @@ bool ChromeBreakpadClient::GetShouldDumpLargerDumps(bool is_per_user_install) {
173165int ChromeBreakpadClient::GetResultCodeRespawnFailed () {
174166 return chrome::RESULT_CODE_RESPAWN_FAILED;
175167}
168+
169+ void ChromeBreakpadClient::InitBrowserCrashDumpsRegKey () {
170+ DCHECK (g_browser_crash_dump_regkey == NULL );
171+
172+ base::win::RegKey regkey;
173+ if (regkey.Create (HKEY_CURRENT_USER,
174+ chrome::kBrowserCrashDumpAttemptsRegistryPath ,
175+ KEY_ALL_ACCESS) != ERROR_SUCCESS) {
176+ return ;
177+ }
178+
179+ // We use the current process id and the current tick count as a (hopefully)
180+ // unique combination for the crash dump value. There's a small chance that
181+ // across a reboot we might have a crash dump signal written, and the next
182+ // browser process might have the same process id and tick count, but crash
183+ // before consuming the signal (overwriting the signal with an identical one).
184+ // For now, we're willing to live with that risk.
185+ int length = base::strings::SafeSPrintf (g_browser_crash_dump_prefix,
186+ kBrowserCrashDumpPrefixTemplate ,
187+ chrome::kChromeVersion ,
188+ ::GetCurrentProcessId (),
189+ ::GetTickCount());
190+ if (length <= 0 ) {
191+ NOTREACHED ();
192+ g_browser_crash_dump_prefix[0 ] = ' \0 ' ;
193+ return ;
194+ }
195+
196+ // Hold the registry key in a global for update on crash dump.
197+ g_browser_crash_dump_regkey = regkey.Take ();
198+ }
199+
200+ void ChromeBreakpadClient::RecordCrashDumpAttempt (bool is_real_crash) {
201+ // If we're not a browser (or the registry is unavailable to us for some
202+ // reason) then there's nothing to do.
203+ if (g_browser_crash_dump_regkey == NULL )
204+ return ;
205+
206+ // Generate the final value name we'll use (appends the crash number to the
207+ // base value name).
208+ const size_t kMaxValueSize = 2 * kBrowserCrashDumpPrefixLength ;
209+ char value_name[kMaxValueSize + 1 ] = {};
210+ int length = base::strings::SafeSPrintf (
211+ value_name,
212+ " %s-%x" ,
213+ g_browser_crash_dump_prefix,
214+ base::subtle::NoBarrier_AtomicIncrement (&g_browser_crash_dump_count, 1 ));
215+
216+ if (length > 0 ) {
217+ DWORD value_dword = is_real_crash ? 1 : 0 ;
218+ ::RegSetValueExA (g_browser_crash_dump_regkey, value_name, 0 , REG_DWORD,
219+ reinterpret_cast <BYTE*>(&value_dword),
220+ sizeof(value_dword));
221+ }
222+ }
223+
224+ bool ChromeBreakpadClient::ReportingIsEnforcedByPolicy (bool * breakpad_enabled) {
225+ // Determine whether configuration management allows loading the crash reporter.
226+ // Since the configuration management infrastructure is not initialized at this
227+ // point, we read the corresponding registry key directly. The return status
228+ // indicates whether policy data was successfully read. If it is true,
229+ // |breakpad_enabled| contains the value set by policy.
230+ string16 key_name = UTF8ToUTF16 (policy::key::kMetricsReportingEnabled );
231+ DWORD value = 0 ;
232+ base::win::RegKey hklm_policy_key (HKEY_LOCAL_MACHINE,
233+ policy::kRegistryChromePolicyKey , KEY_READ);
234+ if (hklm_policy_key.ReadValueDW (key_name.c_str (), &value) == ERROR_SUCCESS) {
235+ *breakpad_enabled = value != 0 ;
236+ return true ;
237+ }
238+
239+ base::win::RegKey hkcu_policy_key (HKEY_CURRENT_USER,
240+ policy::kRegistryChromePolicyKey , KEY_READ);
241+ if (hkcu_policy_key.ReadValueDW (key_name.c_str (), &value) == ERROR_SUCCESS) {
242+ *breakpad_enabled = value != 0 ;
243+ return true ;
244+ }
245+
246+ return false ;
247+ }
176248#endif
177249
178250#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_IOS)
0 commit comments