| 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 "chrome/browser/metrics/plugin_metrics_provider.h" | 5 #include "chrome/browser/metrics/plugin_metrics_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 GetChildProcessStats(data).process_crashes++; | 359 GetChildProcessStats(data).process_crashes++; |
| 360 RecordCurrentStateWithDelay(kRecordStateDelayMs); | 360 RecordCurrentStateWithDelay(kRecordStateDelayMs); |
| 361 } | 361 } |
| 362 | 362 |
| 363 void PluginMetricsProvider::BrowserChildProcessInstanceCreated( | 363 void PluginMetricsProvider::BrowserChildProcessInstanceCreated( |
| 364 const content::ChildProcessData& data) { | 364 const content::ChildProcessData& data) { |
| 365 GetChildProcessStats(data).instances++; | 365 GetChildProcessStats(data).instances++; |
| 366 RecordCurrentStateWithDelay(kRecordStateDelayMs); | 366 RecordCurrentStateWithDelay(kRecordStateDelayMs); |
| 367 } | 367 } |
| 368 | 368 |
| 369 void PluginMetricsProvider::BrowserChildProcessHostDisconnected( |
| 370 const content::ChildProcessData& data) { |
| 371 // Treat a disconnect as a crash. |
| 372 GetChildProcessStats(data).process_crashes++; |
| 373 RecordCurrentStateWithDelay(kRecordStateDelayMs); |
| 374 } |
| 375 |
| 369 bool PluginMetricsProvider::RecordCurrentStateWithDelay(int delay_sec) { | 376 bool PluginMetricsProvider::RecordCurrentStateWithDelay(int delay_sec) { |
| 370 if (weak_ptr_factory_.HasWeakPtrs()) | 377 if (weak_ptr_factory_.HasWeakPtrs()) |
| 371 return false; | 378 return false; |
| 372 | 379 |
| 373 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 380 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 374 FROM_HERE, | 381 FROM_HERE, |
| 375 base::Bind(&PluginMetricsProvider::RecordCurrentState, | 382 base::Bind(&PluginMetricsProvider::RecordCurrentState, |
| 376 weak_ptr_factory_.GetWeakPtr()), | 383 weak_ptr_factory_.GetWeakPtr()), |
| 377 base::TimeDelta::FromMilliseconds(delay_sec)); | 384 base::TimeDelta::FromMilliseconds(delay_sec)); |
| 378 return true; | 385 return true; |
| 379 } | 386 } |
| 380 | 387 |
| 381 bool PluginMetricsProvider::RecordCurrentStateIfPending() { | 388 bool PluginMetricsProvider::RecordCurrentStateIfPending() { |
| 382 if (!weak_ptr_factory_.HasWeakPtrs()) | 389 if (!weak_ptr_factory_.HasWeakPtrs()) |
| 383 return false; | 390 return false; |
| 384 | 391 |
| 385 weak_ptr_factory_.InvalidateWeakPtrs(); | 392 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 386 RecordCurrentState(); | 393 RecordCurrentState(); |
| 387 return true; | 394 return true; |
| 388 } | 395 } |
| OLD | NEW |